Skip to content

Commit

Permalink
(#301) Поправил тесты
Browse files Browse the repository at this point in the history
  • Loading branch information
Danila Knyazikhin committed Dec 27, 2023
1 parent 3a4ce1a commit ab36078
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
2 changes: 0 additions & 2 deletions apps/MetamorphicTestsApp/src/MetamorphicTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ TEST(TestNFA, Test_equivalent_nfa_negative) {
for (int i = 0; i < 30; i++) {
string str = rg.generate_regex();
Regex r1(str), r2(str);
std::cout << r2.to_txt() << std::endl << r1.to_txt()<< std::endl;
std::cout << "Томпсон:\n" << r1.to_thompson().minimize().to_txt() << std::endl << "Антимирова:\n" << r2.to_antimirov().minimize().to_txt() << std::endl;
ASSERT_TRUE(FiniteAutomaton::equivalent(r1.to_thompson().minimize(), r2.to_antimirov().minimize()));
}
}
36 changes: 18 additions & 18 deletions apps/UnitTestsApp/src/UnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,37 @@ TEST(ParseStringTest, Test_regex_lexer) {

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

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

states[1].set_transition(4, Symbol::epsilon());
states[1].set_transition(2, "a");
states[1].set_transition(3, "b");
states[1].set_transition(3, "c");
states[1].set_transition(4, Symbol::epsilon());
states[1].set_transition(2, Symbol::epsilon());

states[2].set_transition(3, "a");
states[2].set_transition(3, "b");
states[2].set_transition(3, "c");
states[2].set_transition(4, "b");
states[2].set_transition(4, "c");
states[2].set_transition(5, Symbol::epsilon());

states[3].set_transition(3, "a");
states[3].set_transition(3, "b");
states[3].set_transition(3, "c");
states[3].set_transition(4, Symbol::epsilon());
states[3].set_transition(4, "a");
states[3].set_transition(4, "b");
states[3].set_transition(4, "c");

states[4].set_transition(7, Symbol::epsilon());
states[4].set_transition(4, "a");
states[4].set_transition(4, "b");
states[4].set_transition(4, "c");
states[4].set_transition(5, Symbol::epsilon());

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

states[5].set_transition(6, "b");
states[5].set_transition(8, Symbol::epsilon());

states[6].set_transition(7, Symbol::epsilon());
states[6].set_transition(7, "b");

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

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

0 comments on commit ab36078

Please sign in to comment.