Skip to content
Snippets Groups Projects
Commit 9677971e authored by Jan Trávníček's avatar Jan Trávníček
Browse files

algo: add epsilon loop test to PDARun test

Also make the test section names more clear
parent 6256b0a7
No related branches found
No related tags found
1 merge request!169NPDA and NPDTA run
Pipeline #105301 passed with warnings
......@@ -7,7 +7,7 @@
#include <automaton/run/Translate.h>
 
TEST_CASE ( "PDARun", "[unit][algo][automaton][run]" ) {
SECTION ( "Test run of PDA" ) {
SECTION ( "Test run of DPDA vs NPDA" ) {
automaton::DPDA < char, std::string, int > automaton ( 0, "S" );
 
automaton.addState(0);
......@@ -61,4 +61,32 @@ TEST_CASE ( "PDARun", "[unit][algo][automaton][run]" ) {
std::cout << automaton::run::Translate::translate ( automaton, string::LinearString < char > ( "ab" ) ) << std::endl;
CHECK ( automaton::run::Translate::translate ( automaton, string::LinearString < char > ( "ab" ) ).contains ( string::LinearString < char > ( "abc" ) ) );
}
SECTION ( "Epsilon loop test in run of PDA" ) {
automaton::NPDA < char, char, int > automaton ( 0, '#' );
automaton.addState(0);
automaton.addState(1);
automaton.addState(2);
automaton.addState(3);
automaton.addState(4);
automaton.addInputSymbol('a');
automaton.addPushdownStoreSymbol('#');
automaton.addPushdownStoreSymbol('a');
automaton.addTransition(0, 'a', { }, 1, { } );
automaton.addTransition(1, /* eps, */ { '#'}, 2, { } );
automaton.addTransition(2, /* eps, */ { }, 3, { 'a' } );
automaton.addTransition(3, /* eps, */ { 'a' }, 2, { } );
automaton.addTransition(3, /* eps, */ { 'a' }, 4, { } );
automaton.addTransition(4, /* eps, */ { }, 3, { 'a' } );
automaton.addFinalState(2);
automaton.addFinalState(4);
CHECK ( automaton::run::Accept::accept ( automaton, string::LinearString < char > ( "a" ) ) == true );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment