mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
Temp (#123)
* Coverage * added fixes * removed spacing * removed junk * removed print * removed coverage * removed useless stuff * fix --------- Co-authored-by: Saikari <lin@sz.cn.eu.org>
This commit is contained in:
28
tests/general/unit_test_pattern_scan_extra.cpp
Normal file
28
tests/general/unit_test_pattern_scan_extra.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Extra tests for PatternScanner behavior
|
||||
#include <gtest/gtest.h>
|
||||
#include <omath/utility/pattern_scan.hpp>
|
||||
|
||||
using namespace omath;
|
||||
|
||||
TEST(unit_test_pattern_scan_extra, IteratorScanFound)
|
||||
{
|
||||
std::vector<std::byte> buf = {std::byte(0xDE), std::byte(0xAD), std::byte(0xBE), std::byte(0xEF), std::byte(0x00)};
|
||||
auto it = PatternScanner::scan_for_pattern(buf.begin(), buf.end(), "DE AD BE EF");
|
||||
EXPECT_NE(it, buf.end());
|
||||
EXPECT_EQ(std::distance(buf.begin(), it), 0);
|
||||
}
|
||||
|
||||
TEST(unit_test_pattern_scan_extra, IteratorScanNotFound)
|
||||
{
|
||||
std::vector<std::byte> buf = {std::byte(0x00), std::byte(0x11), std::byte(0x22)};
|
||||
auto it = PatternScanner::scan_for_pattern(buf.begin(), buf.end(), "FF EE DD");
|
||||
EXPECT_EQ(it, buf.end());
|
||||
}
|
||||
|
||||
TEST(unit_test_pattern_scan_extra, ParseInvalidPattern)
|
||||
{
|
||||
// invalid hex token should cause the public scan to return end (no match)
|
||||
std::vector<std::byte> buf = {std::byte(0x00), std::byte(0x11)};
|
||||
auto it = PatternScanner::scan_for_pattern(buf.begin(), buf.end(), "GG HH");
|
||||
EXPECT_EQ(it, buf.end());
|
||||
}
|
||||
Reference in New Issue
Block a user