Files
FEX-Emu--FEX/unittests/APITests/WildcardMatcher.cpp
T
badumbatish 81d4e8fe9d Initial implementation for regex engine
Add support for question mark and plus mark in regex, supply testing for star

Added more characters to the regex alphabets, add more test case

Added support for regex matching of configs, awaiting reviews

Rename variable to CamelCase

Addresses PR reviews

Remove unnecessary features and test cases

Rewrite to naive regex with dp

Addresses PR reviews

Build fixes

Code Review
2026-04-01 10:45:59 -07:00

49 lines
1.3 KiB
C++

#include <FEXCore/fextl/string.h>
#include <FEXCore/Utils/Allocator.h>
#include <FEXCore/Utils/WildcardMatcher.h>
#include <catch2/catch_test_macros.hpp>
using namespace FEXCore::Utils::Wildcard;
TEST_CASE("Singular regex") {
CHECK(Matches("a", "a"));
CHECK(Matches("a*", "a*"));
CHECK(Matches("a*", "aaaaaaa"));
}
TEST_CASE("Concat regex") {
CHECK(Matches("aaa", "aaa"));
CHECK(Matches("ab", "ab"));
CHECK(!Matches("a", "ab"));
CHECK(!Matches("ab", "a"));
}
TEST_CASE("Wildcard beginning end") {
CHECK(Matches("a*", "a"));
CHECK(Matches("*a", "a"));
CHECK(Matches("*a*", "a"));
}
TEST_CASE("Wildcard middle") {
CHECK(Matches("test*pattern", "test__pattern"));
}
TEST_CASE("Wildcard mult") {
CHECK(Matches("test*pattern*more", "test__pattern__more"));
CHECK(Matches("test**pattern", "test_pattern"));
}
TEST_CASE("Wildcard regex simple") {
CHECK(Matches("*", ""));
CHECK(Matches("*", "setup.json"));
CHECK(Matches("test*pattern", "test__pattern"));
CHECK(!Matches("setup.*", "setupjson"));
CHECK(Matches("setup*", "setup.json"));
CHECK(Matches("setup*", "setup/setup.json"));
CHECK(Matches("*setup*", "setup/setup.json"));
}
TEST_CASE("FEX regex") {
CHECK(Matches("*Config*", "/home/ubuntu/.fex-emu/Config.json"));
CHECK(Matches("*Config.json", "/home/ubuntu/.fex-emu/Config.json"));
}