mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 23:13:26 +00:00
Adds new test cases to cover additional scenarios for pattern scanning, including tests for leading/trailing whitespace and spacing variations to ensure robustness.
47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
//
|
|
// Created by Vlad on 10/4/2025.
|
|
//
|
|
#include "gtest/gtest.h"
|
|
#include <omath/utility/pattern_scan.hpp>
|
|
#include <source_location>
|
|
|
|
|
|
TEST(unit_test_pattern_scan, read_test)
|
|
{
|
|
const auto result = omath::PatternScanner::parse_pattern("FF ? ?? E9");
|
|
|
|
EXPECT_EQ(result->at(0), static_cast<std::byte>(0xFF));
|
|
EXPECT_EQ(result->at(1), std::nullopt);
|
|
EXPECT_EQ(result->at(2), std::nullopt);
|
|
EXPECT_EQ(result->at(3), static_cast<std::byte>(0xE9));
|
|
}
|
|
|
|
TEST(unit_test_pattern_scan, corner_case_1)
|
|
{
|
|
const auto result = omath::PatternScanner::parse_pattern(" FF ? ?? E9");
|
|
|
|
EXPECT_EQ(result->at(0), static_cast<std::byte>(0xFF));
|
|
EXPECT_EQ(result->at(1), std::nullopt);
|
|
EXPECT_EQ(result->at(2), std::nullopt);
|
|
EXPECT_EQ(result->at(3), static_cast<std::byte>(0xE9));
|
|
}
|
|
|
|
TEST(unit_test_pattern_scan, corner_case_2)
|
|
{
|
|
const auto result = omath::PatternScanner::parse_pattern(" FF ? ?? E9 ");
|
|
|
|
EXPECT_EQ(result->at(0), static_cast<std::byte>(0xFF));
|
|
EXPECT_EQ(result->at(1), std::nullopt);
|
|
EXPECT_EQ(result->at(2), std::nullopt);
|
|
EXPECT_EQ(result->at(3), static_cast<std::byte>(0xE9));
|
|
}
|
|
|
|
TEST(unit_test_pattern_scan, corner_case_3)
|
|
{
|
|
const auto result = omath::PatternScanner::parse_pattern(" FF ? ?? E9 ");
|
|
|
|
EXPECT_EQ(result->at(0), static_cast<std::byte>(0xFF));
|
|
EXPECT_EQ(result->at(1), std::nullopt);
|
|
EXPECT_EQ(result->at(2), std::nullopt);
|
|
EXPECT_EQ(result->at(3), static_cast<std::byte>(0xE9));
|
|
} |