Skip to content

Commit

Permalink
Test replace single symbol using regex approach
Browse files Browse the repository at this point in the history
  • Loading branch information
Adda0 committed Mar 4, 2024
1 parent c02fb8b commit cfba8c4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/nft/strings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ TEST_CASE("mata::nft::strings::replace_reluctant_regex()") {
Nft expected{};
EnumAlphabet alphabet{ 'a', 'b', 'c' };

SECTION("'a' replace with 'b' replace all") {
SECTION("'a+b+c' replace with 'dd' replace all") {
// Use replace symbol with symbol.
nft = nft::strings::replace_reluctant_regex("a+b+c", Word{ 'd', 'd' }, &alphabet, ReplaceMode::All);
nft.print_to_DOT(std::cout);
Expand All @@ -824,6 +824,19 @@ TEST_CASE("mata::nft::strings::replace_reluctant_regex()") {
{ 'd', 'd', 'a', 'a', 'a', 'b', 'b', 'd', 'd', 'c', 'a', 'b', 'a', 'c' } }));
// expected = nft::builder::parse_from_mata(std::string(
// ));
// CHECK(nft::are_equivalent(nft, expected));
}

SECTION("'a' replace with 'd' replace all") {
// Use replace symbol with symbol.
nft = nft::strings::replace_reluctant_regex("a", Word{ 'd' }, &alphabet, ReplaceMode::All);
nft.print_to_DOT(std::cout);
CHECK(nft.is_tuple_in_lang({ { 'a', 'a', 'a', 'b', 'a', 'a', 'a', 'b', 'a', 'c', 'a' },
{ 'd', 'd', 'd', 'b', 'd', 'd', 'd', 'b', 'd', 'c', 'd' } }));
CHECK(nft.is_tuple_in_lang({ {},
{} }));
// expected = nft::builder::parse_from_mata(std::string(
// ));
// CHECK(nft::are_equivalent(nft, expected));
}
// TODO(nft): Test dropping regex, correctly replacing shortest/longest match, ...
Expand Down

0 comments on commit cfba8c4

Please sign in to comment.