Skip to content

Commit

Permalink
(#290) unit тест на томпсона с отрицанием
Browse files Browse the repository at this point in the history
  • Loading branch information
dak151449 committed Nov 20, 2023
1 parent 7361e3e commit 72073c8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions apps/UnitTestsApp/src/UnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,37 @@ TEST(ParseStringTest, Test_regex_lexer) {
}
}

TEST(TestCaseThompsonNegative, Test_thompson_negative) {
vector<State> states;
for (int i = 0; i < 9; i++) {
states.emplace_back(i, set<int>{i}, std::to_string(i), false, map<alphabet_symbol, set<int>>());
}

states[0].set_transition(1, alphabet_symbol::epsilon());
states[0].set_transition(5, alphabet_symbol::epsilon());

states[1].set_transition(4, alphabet_symbol::epsilon());
states[1].set_transition(2, "a");

states[2].set_transition(3, "a");

states[3].set_transition(3, "a");
states[3].set_transition(4, alphabet_symbol::epsilon());

states[4].set_transition(7, alphabet_symbol::epsilon());

states[7].set_transition(8, "c");

states[5].set_transition(6, "b");

states[6].set_transition(7, alphabet_symbol::epsilon());

states[8].is_terminal = true;
FiniteAutomaton fa(0, states, {"a", "b", "c"});

ASSERT_TRUE(FiniteAutomaton::equal(fa, Regex("(^a|b)c").to_thompson()));
}

TEST(TestCaseName, Test_random_regex_parsing) {
RegexGenerator rg(15, 10, 5, 3);
for (int i = 0; i < 30; i++) {
Expand Down

0 comments on commit 72073c8

Please sign in to comment.