mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
Adds pattern scanning functionality and corner case tests
Implements a pattern scanning feature that allows searching for byte patterns within a byte range. Adds `scan_for_pattern` method to `PatternScanner` to locate a pattern within a byte span. Adds corner case tests to verify functionality and handle invalid inputs.
This commit is contained in:
@@ -7,12 +7,20 @@
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <span>
|
||||
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_read_test_Test;
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_corner_case_1_Test;
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_corner_case_2_Test;
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_corner_case_3_Test;
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
class unit_test_pattern_scan_corner_case_4_Test;
|
||||
|
||||
|
||||
namespace omath
|
||||
{
|
||||
enum class PatternScanError
|
||||
@@ -25,7 +33,11 @@ namespace omath
|
||||
friend unit_test_pattern_scan_corner_case_1_Test;
|
||||
friend unit_test_pattern_scan_corner_case_2_Test;
|
||||
friend unit_test_pattern_scan_corner_case_3_Test;
|
||||
friend unit_test_pattern_scan_corner_case_4_Test;
|
||||
public:
|
||||
[[nodiscard]]
|
||||
static std::optional<std::span<std::byte>::const_iterator>
|
||||
scan_for_pattern(const std::string_view& pattern, const std::span<std::byte>& range);
|
||||
private:
|
||||
[[nodiscard]]
|
||||
static std::expected<std::vector<std::optional<std::byte>>, PatternScanError>
|
||||
|
||||
Reference in New Issue
Block a user