mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 14:00:16 +02:00
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
49 lines
1.3 KiB
C++
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"));
|
|
}
|