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

adapt glushkov rte tests to changes in algo implementation

parent f3c970c4
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ TEST_CASE ( "GlushkovRTE", "[integration]" ) {
for ( size_t i = 0; i < TESTCASES; i++ ) {
ext::vector < std::string > qs = {
"execute < " + file + " | rte::convert::ToPostfixPushdownAutomatonGlushkov - | automaton::determinize::Determinize - > $pda",
"execute \"\\\"" + m_Generators.at ( base ) -> generate ( ) + "\\\"\" | string::Parse @string::String ^ - > $string",
"execute \"" + m_Generators.at ( base ) -> generate ( ) + "\" | string::Parse @tree::Tree ^ - | string::StringConcatenate ( PostfixRankedTree ) - <(string::Parse @string::String \"\\\"#$\\\"\") > $string",
"quit automaton::run::Accept $pda $string",
};
 
......
......@@ -11,8 +11,8 @@ class TreeGenerator {
public:
std::string generate ( ) {
m_Str.clear ( );
m_Str += "RANKED_TREE ";
S ( );
m_Str += "#$";
return m_Str;
}
 
......@@ -27,16 +27,18 @@ size_t TreeGenerator::MAX_LENGTH = 1000;
class TreeGenerator1 : public TreeGenerator {
private:
void S ( size_t depth = 1 ) {
m_Str += ( depth > MAX_DEPTH || randint ( 0, 1 ) == 0 ) ? "b " : "c ";
S2 ( depth + 1 );
m_Str += ( depth > MAX_DEPTH || randint ( 0, 1 ) == 0 ) ? "b 0 " : "c 0 ";
}
 
void S2 ( size_t depth ) {
if ( depth > MAX_DEPTH || randint ( 0, 1 ) == 0 )
return;
 
m_Str += "b a d ";
m_Str += "d 1 ";
m_Str += "a 2 ";
S2 ( depth + 1 );
m_Str += randint ( 0, 1 ) == 0 ? "b 0 " : "c 0 ";
}
};
 
......@@ -44,7 +46,7 @@ class TreeGenerator1 : public TreeGenerator {
class TreeGenerator2 : public TreeGenerator {
private:
void S ( size_t /* depth = 1 */ ) {
m_Str += "b b a ";
m_Str += "a 2 b 0 b 0 ";
}
};
 
......@@ -53,13 +55,13 @@ class TreeGenerator3 : public TreeGenerator {
private:
void S ( size_t depth = 1 ) {
if ( depth > MAX_DEPTH || randint ( 0, 1 ) == 0 ) {
m_Str += "b ";
m_Str += "b 0 ";
return;
}
 
m_Str += "a 2 ";
S ( depth + 1 );
S ( depth + 1 );
m_Str += "a ";
}
};
 
......@@ -68,13 +70,13 @@ class TreeGenerator4 : public TreeGenerator {
private:
void S ( size_t depth = 1 ) {
if ( depth > MAX_DEPTH || randint ( 0, 1 ) == 0 ) {
m_Str += "b b a ";
m_Str += "a 2 b 0 b 0 ";
return;
}
 
m_Str += "a 2 ";
S ( depth + 1 );
S ( depth + 1 );
m_Str += "a ";
}
};
 
......@@ -82,7 +84,7 @@ class TreeGenerator4 : public TreeGenerator {
class TreeGenerator5 : public TreeGenerator {
private:
void S ( size_t /* depth = 1 */ ) {
m_Str += "a ";
m_Str += "a 0 ";
}
};
 
......@@ -90,15 +92,15 @@ class TreeGenerator5 : public TreeGenerator {
class TreeGenerator6 : public TreeGenerator {
private:
void S ( size_t depth = 1 ) {
m_Str += "a 2 ";
SL ( depth + 1 );
SR ( depth + 1 );
m_Str += "a ";
}
 
void SL ( size_t depth ) {
int r = randint ( 0, 1 );
if ( r == 0 || depth > MAX_DEPTH )
m_Str += "b ";
m_Str += "b 0 ";
else if ( r == 1 )
S ( depth + 1 );
}
......@@ -106,7 +108,7 @@ class TreeGenerator6 : public TreeGenerator {
void SR ( size_t depth ) {
int r = randint ( 0, 1 );
if ( r == 0 || depth > MAX_DEPTH )
m_Str += "c ";
m_Str += "c 0 ";
else if ( r == 1 )
S ( depth + 1 );
}
......@@ -116,15 +118,15 @@ class TreeGenerator6 : public TreeGenerator {
class TreeGenerator7 : public TreeGenerator {
private:
void S ( size_t depth = 1 ) {
m_Str += "c b a ";
S2 ( depth + 1 );
m_Str += "a 2 c 0 b 0 ";
}
 
void S2 ( size_t depth ) {
if ( depth > MAX_DEPTH || randint ( 0, 2 ) == 0 )
return;
 
m_Str += "d ";
m_Str += "d 1 ";
S2 ( depth + 1 );
}
};
......@@ -134,13 +136,13 @@ class TreeGenerator8 : public TreeGenerator {
private:
void S ( size_t depth = 1 ) {
if ( depth > MAX_DEPTH || randint ( 0, 1 ) == 0 ) {
m_Str += std::string ( 1, 'b' + randint ( 0, 3 ) ) + ' ';
m_Str += std::string ( 1, 'b' + randint ( 0, 3 ) ) + " 0 ";
return;
}
 
m_Str += "a 2 ";
S ( depth + 1 );
S ( depth + 1 );
m_Str += "a ";
}
};
 
......@@ -149,11 +151,11 @@ class TreeGenerator9 : public TreeGenerator {
private:
void S ( size_t depth = 1 ) {
if ( depth > MAX_DEPTH || randint ( 0, 1 ) == 0 ) {
m_Str += "b ";
m_Str += "b 0 ";
} else {
m_Str += "a 2 ";
S ( depth + 1 );
S ( depth + 1 );
m_Str += "a ";
}
}
};
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