mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
* added constexpr * fix * improved stuff * added const * improvement * fix * fix * patch
32 lines
1.3 KiB
C++
32 lines
1.3 KiB
C++
// 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 = {static_cast<std::byte>(0xDE), static_cast<std::byte>(0xAD),
|
|
static_cast<std::byte>(0xBE), static_cast<std::byte>(0xEF),
|
|
static_cast<std::byte>(0x00)};
|
|
const 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 = {static_cast<std::byte>(0x00), static_cast<std::byte>(0x11),
|
|
static_cast<std::byte>(0x22)};
|
|
const 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 = {static_cast<std::byte>(0x00), static_cast<std::byte>(0x11)};
|
|
const auto it = PatternScanner::scan_for_pattern(buf.begin(), buf.end(), "GG HH");
|
|
EXPECT_EQ(it, buf.end());
|
|
}
|