diff --git a/alib2/test-src/automaton/AutomatonTest.cpp b/alib2/test-src/automaton/AutomatonTest.cpp index 5d5c6587149addf3030e448b07c33ded690c6d5c..4670477bf3a4508590f48ffb14b66d6259715306 100644 --- a/alib2/test-src/automaton/AutomatonTest.cpp +++ b/alib2/test-src/automaton/AutomatonTest.cpp @@ -8,6 +8,8 @@ #include "automaton/AutomatonFromXMLParser.h" #include "automaton/AutomatonToXMLComposer.h" +#include "factory/AutomatonFactory.h" + #define CPPUNIT_IMPLY(x, y) CPPUNIT_ASSERT(!(x) || (y)) CPPUNIT_TEST_SUITE_REGISTRATION( AutomatonTest ); @@ -24,17 +26,26 @@ void AutomatonTest::testXMLParser() { automaton.setInputSymbols({alphabet::Symbol("a"), alphabet::Symbol("b")}); automaton.addTransition(automaton::UnknownTransition()); - automaton::AutomatonToXMLComposer composer; - std::list<sax::Token> tokens = composer.compose(automaton); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + CPPUNIT_ASSERT( automaton == automaton ); + { + automaton::AutomatonToXMLComposer composer; + std::list<sax::Token> tokens = composer.compose(automaton); + std::string tmp; + sax::SaxComposeInterface::printMemory(tmp, tokens); - std::list<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); - automaton::AutomatonFromXMLParser parser; - automaton::UnknownAutomaton automaton2 = parser.parse(tokens2); + std::list<sax::Token> tokens2; + sax::SaxParseInterface::parseMemory(tmp, tokens2); + automaton::AutomatonFromXMLParser parser; + automaton::UnknownAutomaton automaton2 = parser.parse(tokens2); - CPPUNIT_ASSERT( automaton == automaton ); - CPPUNIT_ASSERT( automaton == automaton2 ); + CPPUNIT_ASSERT( automaton == automaton2 ); + } + { + std::string tmp = automaton::AutomatonFactory::toString(automaton); + automaton::UnknownAutomaton automaton2 = automaton::AutomatonFactory::fromString(tmp); + + CPPUNIT_ASSERT( automaton == automaton2 ); + + } } diff --git a/alib2/test-src/regexp/RegExpTest.cpp b/alib2/test-src/regexp/RegExpTest.cpp index a4cdd33d213d27afb923cddfc99def5923553e93..b330ccf7177a7b2f48553b57ca3efb024f419d5d 100644 --- a/alib2/test-src/regexp/RegExpTest.cpp +++ b/alib2/test-src/regexp/RegExpTest.cpp @@ -10,6 +10,8 @@ #include "regexp/RegExpFromXMLParser.h" #include "regexp/RegExpToXMLComposer.h" +#include "factory/RegExpFactory.h" + #define CPPUNIT_IMPLY(x, y) CPPUNIT_ASSERT(!(x) || (y)) CPPUNIT_TEST_SUITE_REGISTRATION( RegExpTest ); @@ -73,17 +75,25 @@ void RegExpTest::testXMLParser() { ) ); - regexp::RegExpToXMLComposer composer; - std::list<sax::Token> tokens = composer.compose(regexp); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); - - std::list<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); - regexp::RegExpFromXMLParser parser; - regexp::RegExp regexp2 = parser.parse(tokens2); - - CPPUNIT_ASSERT( regexp == regexp2 ); + { + regexp::RegExpToXMLComposer composer; + std::list<sax::Token> tokens = composer.compose(regexp); + std::string tmp; + sax::SaxComposeInterface::printMemory(tmp, tokens); + + std::list<sax::Token> tokens2; + sax::SaxParseInterface::parseMemory(tmp, tokens2); + regexp::RegExpFromXMLParser parser; + regexp::RegExp regexp2 = parser.parse(tokens2); + + CPPUNIT_ASSERT( regexp == regexp2 ); + } + { + std::string tmp = regexp::RegExpFactory::toString(regexp); + regexp::RegExp regexp2 = regexp::RegExpFactory::fromString(tmp); + + CPPUNIT_ASSERT( regexp == regexp2 ); + } } void RegExpTest::testOrder() {