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

test factory classes

parent 04282b30
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "automaton/AutomatonFromXMLParser.h" #include "automaton/AutomatonFromXMLParser.h"
#include "automaton/AutomatonToXMLComposer.h" #include "automaton/AutomatonToXMLComposer.h"
   
#include "factory/AutomatonFactory.h"
#define CPPUNIT_IMPLY(x, y) CPPUNIT_ASSERT(!(x) || (y)) #define CPPUNIT_IMPLY(x, y) CPPUNIT_ASSERT(!(x) || (y))
   
CPPUNIT_TEST_SUITE_REGISTRATION( AutomatonTest ); CPPUNIT_TEST_SUITE_REGISTRATION( AutomatonTest );
...@@ -24,17 +26,26 @@ void AutomatonTest::testXMLParser() { ...@@ -24,17 +26,26 @@ void AutomatonTest::testXMLParser() {
automaton.setInputSymbols({alphabet::Symbol("a"), alphabet::Symbol("b")}); automaton.setInputSymbols({alphabet::Symbol("a"), alphabet::Symbol("b")});
automaton.addTransition(automaton::UnknownTransition()); automaton.addTransition(automaton::UnknownTransition());
automaton::AutomatonToXMLComposer composer; CPPUNIT_ASSERT( automaton == automaton );
std::list<sax::Token> tokens = composer.compose(automaton); {
std::string tmp; automaton::AutomatonToXMLComposer composer;
sax::SaxComposeInterface::printMemory(tmp, tokens); std::list<sax::Token> tokens = composer.compose(automaton);
std::string tmp;
sax::SaxComposeInterface::printMemory(tmp, tokens);
std::list<sax::Token> tokens2; std::list<sax::Token> tokens2;
sax::SaxParseInterface::parseMemory(tmp, tokens2); sax::SaxParseInterface::parseMemory(tmp, tokens2);
automaton::AutomatonFromXMLParser parser; automaton::AutomatonFromXMLParser parser;
automaton::UnknownAutomaton automaton2 = parser.parse(tokens2); 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 );
}
} }
   
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "regexp/RegExpFromXMLParser.h" #include "regexp/RegExpFromXMLParser.h"
#include "regexp/RegExpToXMLComposer.h" #include "regexp/RegExpToXMLComposer.h"
   
#include "factory/RegExpFactory.h"
#define CPPUNIT_IMPLY(x, y) CPPUNIT_ASSERT(!(x) || (y)) #define CPPUNIT_IMPLY(x, y) CPPUNIT_ASSERT(!(x) || (y))
   
CPPUNIT_TEST_SUITE_REGISTRATION( RegExpTest ); CPPUNIT_TEST_SUITE_REGISTRATION( RegExpTest );
...@@ -73,17 +75,25 @@ void RegExpTest::testXMLParser() { ...@@ -73,17 +75,25 @@ void RegExpTest::testXMLParser() {
) )
); );
   
regexp::RegExpToXMLComposer composer; {
std::list<sax::Token> tokens = composer.compose(regexp); regexp::RegExpToXMLComposer composer;
std::string tmp; std::list<sax::Token> tokens = composer.compose(regexp);
sax::SaxComposeInterface::printMemory(tmp, tokens); std::string tmp;
sax::SaxComposeInterface::printMemory(tmp, tokens);
std::list<sax::Token> tokens2;
sax::SaxParseInterface::parseMemory(tmp, tokens2); std::list<sax::Token> tokens2;
regexp::RegExpFromXMLParser parser; sax::SaxParseInterface::parseMemory(tmp, tokens2);
regexp::RegExp regexp2 = parser.parse(tokens2); regexp::RegExpFromXMLParser parser;
regexp::RegExp regexp2 = parser.parse(tokens2);
CPPUNIT_ASSERT( regexp == regexp2 );
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() { void RegExpTest::testOrder() {
......
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