* 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:
2025-12-23 02:47:12 +03:00
committed by GitHub
parent a03620c18f
commit 897484bea1
39 changed files with 2482 additions and 145 deletions

View 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());
}