From 9677971e8a4556dc437c459a43d3dff6e586bb19 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sun, 29 Nov 2020 20:38:52 +0100
Subject: [PATCH] algo: add epsilon loop test to PDARun test

Also make the test section names more clear
---
 alib2algo/test-src/automaton/run/PDARun.cpp | 30 ++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/alib2algo/test-src/automaton/run/PDARun.cpp b/alib2algo/test-src/automaton/run/PDARun.cpp
index 41649bb37f..c270e09ab8 100644
--- a/alib2algo/test-src/automaton/run/PDARun.cpp
+++ b/alib2algo/test-src/automaton/run/PDARun.cpp
@@ -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 );
+	}
+
 }
-- 
GitLab