diff --git a/alib2data/test-src/alphabet/SymbolTest.cpp b/alib2data/test-src/alphabet/SymbolTest.cpp index 13d1e7ead195b9c77c3c295e75772311c4aa55d3..e8a83eab7ae5bb70a3ddc86f548f937b060aa72f 100644 --- a/alib2data/test-src/alphabet/SymbolTest.cpp +++ b/alib2data/test-src/alphabet/SymbolTest.cpp @@ -1,5 +1,6 @@ +#include <catch2/catch.hpp> + #include <alib/list> -#include "SymbolTest.h" #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -13,37 +14,29 @@ #include "factory/XmlDataFactory.hpp" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( SymbolTest, "alphabet" ); -CPPUNIT_TEST_SUITE_REGISTRATION ( SymbolTest ); - -void SymbolTest::setUp ( ) { -} - -void SymbolTest::tearDown ( ) { -} - -void SymbolTest::testOrder ( ) { - common::ranked_symbol < > rs1 ( DefaultSymbolType ( alphabet::BarSymbol { } ), DefaultRankType ( 0 ) ); - common::ranked_symbol < > rs2 ( DefaultSymbolType ( alphabet::BarSymbol { } ), DefaultRankType ( 0 ) ); - - CPPUNIT_ASSERT ( rs1 == rs2 ); -} namespace alphabet { + template < > + inline int BarSymbol::instance < int > ( ) { + return -1; + } +} /* namespace alphabet */ -template < > -inline int BarSymbol::instance < int > ( ) { - return -1; -} +TEST_CASE ( "Alphabet symbols test", "[unit][data][alphabet]" ) { + SECTION ( "Order" ) { + common::ranked_symbol < > rs1 ( DefaultSymbolType ( alphabet::BarSymbol { } ), DefaultRankType ( 0 ) ); + common::ranked_symbol < > rs2 ( DefaultSymbolType ( alphabet::BarSymbol { } ), DefaultRankType ( 0 ) ); -} /* namespace alphabet */ + CHECK ( rs1 == rs2 ); + } -void SymbolTest::testDefaultValues ( ) { - CPPUNIT_ASSERT ( alphabet::BarSymbol::instance < int > ( ) == -1 ); - CPPUNIT_ASSERT ( alphabet::BarSymbol::instance < char > ( ) == '|'); - std::cout << alphabet::BarSymbol::instance < std::string > ( ) << std::endl; - CPPUNIT_ASSERT ( alphabet::BarSymbol::instance < std::string > ( ) == "|"); - CPPUNIT_ASSERT ( alphabet::BarSymbol::instance < alphabet::BarSymbol > ( ) == alphabet::BarSymbol ( ) ); - CPPUNIT_ASSERT ( alphabet::BarSymbol::instance < object::Object > ( ) == object::Object ( alphabet::BarSymbol ( ) ) ); + SECTION ( "Default values" ) { + CHECK ( alphabet::BarSymbol::instance < int > ( ) == -1 ); + CHECK ( alphabet::BarSymbol::instance < char > ( ) == '|'); + INFO ( alphabet::BarSymbol::instance < std::string > ( ) ); + CHECK ( alphabet::BarSymbol::instance < std::string > ( ) == "|"); + CHECK ( alphabet::BarSymbol::instance < alphabet::BarSymbol > ( ) == alphabet::BarSymbol ( ) ); + CHECK ( alphabet::BarSymbol::instance < object::Object > ( ) == object::Object ( alphabet::BarSymbol ( ) ) ); + } } diff --git a/alib2data/test-src/alphabet/SymbolTest.h b/alib2data/test-src/alphabet/SymbolTest.h deleted file mode 100644 index a5f1948739e093b2d91bfa3bee7455f72e7b0291..0000000000000000000000000000000000000000 --- a/alib2data/test-src/alphabet/SymbolTest.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef SYMBOL_TEST_H_ -#define SYMBOL_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class SymbolTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( SymbolTest ); - CPPUNIT_TEST( testOrder ); - CPPUNIT_TEST( testDefaultValues ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testOrder(); - void testDefaultValues(); -}; - -#endif // SYMBOL_TEST_H_ diff --git a/alib2data/test-src/automaton/AutomatonTemplatesTest.cpp b/alib2data/test-src/automaton/AutomatonTemplatesTest.cpp index 4c02c74a77f5850926967eb001f505c5f473f866..184f2415255eddc3cce1eaff84528764fc747ca2 100644 --- a/alib2data/test-src/automaton/AutomatonTemplatesTest.cpp +++ b/alib2data/test-src/automaton/AutomatonTemplatesTest.cpp @@ -1,4 +1,4 @@ -#include "AutomatonTemplatesTest.h" +#include <catch2/catch.hpp> #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -15,59 +15,52 @@ #include <object/Object.h> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( AutomatonTemplatesTest, "automaton" ); -CPPUNIT_TEST_SUITE_REGISTRATION ( AutomatonTemplatesTest ); +TEST_CASE ( "Automaton Templates", "[unit][data][automaton]" ) { + SECTION ( "DFA Parser" ) { + automaton::DFA < char, int > automaton ( 1 ); -void AutomatonTemplatesTest::setUp ( ) { -} - -void AutomatonTemplatesTest::tearDown ( ) { -} + automaton.addState ( 2 ); + automaton.addState ( 3 ); + automaton.addInputSymbol ( 'a' ); + automaton.addInputSymbol ( 'b' ); -void AutomatonTemplatesTest::testDFAParser ( ) { - automaton::DFA < char, int > automaton ( 1 ); + automaton.addTransition ( 1, 'a', 2 ); + automaton.addTransition ( 2, 'b', 1 ); - automaton.addState ( 2 ); - automaton.addState ( 3 ); - automaton.addInputSymbol ( 'a' ); - automaton.addInputSymbol ( 'b' ); + automaton.addFinalState ( 3 ); - automaton.addTransition ( 1, 'a', 2 ); - automaton.addTransition ( 2, 'b', 1 ); + CHECK ( automaton == automaton ); + { + ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( automaton ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - automaton.addFinalState ( 3 ); + ext::deque < sax::Token > tokens2; + sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); + automaton::DFA < char, int > automaton2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); - CPPUNIT_ASSERT ( automaton == automaton ); - { - ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( automaton ); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - - ext::deque < sax::Token > tokens2; - sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); - automaton::DFA < char, int > automaton2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); - - CPPUNIT_ASSERT ( automaton == automaton2 ); - } - { - ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( automaton ); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK ( automaton == automaton2 ); + } + { + ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( automaton ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque < sax::Token > tokens2; - sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); - automaton::DFA < object::Object, object::Object > automaton2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); + ext::deque < sax::Token > tokens2; + sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); + automaton::DFA < object::Object, object::Object > automaton2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); - automaton::DFA < object::Object, object::Object > automaton3 ( object::Object ( object::AnyObject < int > ( 1 ) ) ); + automaton::DFA < object::Object, object::Object > automaton3 ( object::Object ( object::AnyObject < int > ( 1 ) ) ); - automaton3.addState ( object::Object ( object::AnyObject < int > ( 2 ) ) ); - automaton3.addState ( object::Object ( object::AnyObject < int > ( 3 ) ) ); - automaton3.addInputSymbol ( object::Object ( object::AnyObject < char > ( 'a' ) ) ); - automaton3.addInputSymbol ( object::Object ( object::AnyObject < char > ( 'b' ) ) ); + automaton3.addState ( object::Object ( object::AnyObject < int > ( 2 ) ) ); + automaton3.addState ( object::Object ( object::AnyObject < int > ( 3 ) ) ); + automaton3.addInputSymbol ( object::Object ( object::AnyObject < char > ( 'a' ) ) ); + automaton3.addInputSymbol ( object::Object ( object::AnyObject < char > ( 'b' ) ) ); - automaton3.addTransition ( object::Object ( object::AnyObject < int > ( 1 ) ), object::Object ( object::AnyObject < char > ( 'a' ) ), object::Object ( object::AnyObject < int > ( 2 ) ) ); - automaton3.addTransition ( object::Object ( object::AnyObject < int > ( 2 ) ), object::Object ( object::AnyObject < char > ( 'b' ) ), object::Object ( object::AnyObject < int > ( 1 ) ) ); + automaton3.addTransition ( object::Object ( object::AnyObject < int > ( 1 ) ), object::Object ( object::AnyObject < char > ( 'a' ) ), object::Object ( object::AnyObject < int > ( 2 ) ) ); + automaton3.addTransition ( object::Object ( object::AnyObject < int > ( 2 ) ), object::Object ( object::AnyObject < char > ( 'b' ) ), object::Object ( object::AnyObject < int > ( 1 ) ) ); - automaton3.addFinalState ( object::Object ( object::AnyObject < int > ( 3 ) ) ); + automaton3.addFinalState ( object::Object ( object::AnyObject < int > ( 3 ) ) ); - CPPUNIT_ASSERT ( automaton2 == automaton3 ); + CHECK ( automaton2 == automaton3 ); + } } } diff --git a/alib2data/test-src/automaton/AutomatonTemplatesTest.h b/alib2data/test-src/automaton/AutomatonTemplatesTest.h deleted file mode 100644 index 549040f12f8b8d96c972759ec5b752537293d01e..0000000000000000000000000000000000000000 --- a/alib2data/test-src/automaton/AutomatonTemplatesTest.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef AUTOMATON_TEST_H_ -#define AUTOMATON_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class AutomatonTemplatesTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE ( AutomatonTemplatesTest ); - CPPUNIT_TEST ( testDFAParser ); - CPPUNIT_TEST_SUITE_END ( ); - -public: - void setUp ( ); - void tearDown ( ); - - void testDFAParser ( ); -}; - -#endif // AUTOMATON_TEST_H_ diff --git a/alib2data/test-src/automaton/AutomatonTest.cpp b/alib2data/test-src/automaton/AutomatonTest.cpp index 4f003c6601f89b2e7db19d9e8431e39614d717c7..7bc59427584215cb30625c41f72b36226e79f0e8 100644 --- a/alib2data/test-src/automaton/AutomatonTest.cpp +++ b/alib2data/test-src/automaton/AutomatonTest.cpp @@ -1,4 +1,4 @@ -#include "AutomatonTest.h" +#include <catch2/catch.hpp> #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -32,16 +32,8 @@ #include <primitive/xml/Character.h> #include <primitive/xml/Unsigned.h> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( AutomatonTest, "automaton" ); -CPPUNIT_TEST_SUITE_REGISTRATION( AutomatonTest ); - -void AutomatonTest::setUp() { -} - -void AutomatonTest::tearDown() { -} - -void AutomatonTest::testDFAParser() { +TEST_CASE ( "Automaton", "[unit][data][automaton]" ) { + SECTION ( "DFA Parser" ) { automaton::DFA < char, int > automaton ( 1 ); automaton.addState ( 1 ); @@ -55,7 +47,7 @@ void AutomatonTest::testDFAParser() { automaton.addFinalState ( 3 ); - CPPUNIT_ASSERT( automaton == automaton ); + CHECK( automaton == automaton ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(automaton); std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); @@ -63,11 +55,11 @@ void AutomatonTest::testDFAParser() { ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); automaton::DFA < char, int > automaton2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( automaton == automaton2 ); + CHECK( automaton == automaton2 ); } } -void AutomatonTest::testNFAInsertTransitions() { +SECTION ( "NFA Insert transitions" ) { automaton::NFA < char, int > automaton ( 1 ); automaton.addState ( 1 ); @@ -97,10 +89,10 @@ void AutomatonTest::testNFAInsertTransitions() { automaton2.addFinalState ( 3 ); - CPPUNIT_ASSERT ( automaton == automaton2 ); + CHECK ( automaton == automaton2 ); } -void AutomatonTest::SinglePopDPDATransitions() { +SECTION ( "SinglePopDPDA Transitions" ) { automaton::SinglePopDPDA < char, void, char, int > automaton ( 1, 'S' ); automaton.addState(1); @@ -116,11 +108,11 @@ void AutomatonTest::SinglePopDPDATransitions() { automaton.addTransition(3, /* eps, */ 'X', 1, { 'X' } ); - CPPUNIT_ASSERT(!automaton.addTransition(3, /* eps, */ 'X', 1, { 'X' } ) ); + CHECK(!automaton.addTransition(3, /* eps, */ 'X', 1, { 'X' } ) ); automaton.addTransition(3, 'a', 'Y', 1, { 'X' } ); - CPPUNIT_ASSERT_THROW( + CHECK_THROWS_AS( automaton.addTransition(3, 'a', 'X', 1, { 'X' } ), automaton::AutomatonException ); @@ -130,7 +122,7 @@ void AutomatonTest::SinglePopDPDATransitions() { automaton.addTransition(1, /* eps, */ 'Y', 2, { 'Y' } ); automaton.addTransition(2, 'b', 'X', 1, { 'X' } ); - CPPUNIT_ASSERT_THROW( + CHECK_THROWS_AS( automaton.addTransition(2, /* eps, */ 'X', 1, { 'X' } ), automaton::AutomatonException ); @@ -138,7 +130,7 @@ void AutomatonTest::SinglePopDPDATransitions() { automaton.addFinalState(3); } -void AutomatonTest::DPDATransitions() { +SECTION ( "DPDA Transitions" ) { automaton::DPDA < char, void, char, int > automaton ( 1, 'S' ); automaton.addState(1); @@ -155,11 +147,11 @@ void AutomatonTest::DPDATransitions() { automaton.addTransition(3, /* eps, */ { 'X' }, 1, { 'X' } ); - CPPUNIT_ASSERT(!automaton.addTransition(3, /* eps, */ { 'X' }, 1, { 'X' } ) ); + CHECK(!automaton.addTransition(3, /* eps, */ { 'X' }, 1, { 'X' } ) ); automaton.addTransition(3, 'a', { 'Y' }, 1, { 'X' } ); - CPPUNIT_ASSERT_THROW( + CHECK_THROWS_AS( automaton.addTransition(3, 'a', { 'X' }, 1, { 'X' } ), automaton::AutomatonException ); @@ -169,7 +161,7 @@ void AutomatonTest::DPDATransitions() { automaton.addTransition(1, /* eps, */ { 'Y' }, 2, { 'Y' } ); automaton.addTransition(2, 'b', { 'X' }, 1, { 'X' } ); - CPPUNIT_ASSERT_THROW( + CHECK_THROWS_AS( automaton.addTransition(2, /* eps, */ { 'X' }, 1, { 'X' } ), automaton::AutomatonException ); @@ -177,13 +169,13 @@ void AutomatonTest::DPDATransitions() { automaton.addTransition(4, 'a', { 'X', 'Y' }, 2, { 'Y' } ); automaton.addTransition(4, 'a', { 'X', 'S' }, 2, { 'Y' } ); automaton.addTransition(4, /* eps, */ { 'X', 'X' }, 2, { 'Y' } ); - CPPUNIT_ASSERT(!automaton.addTransition(4, /* eps, */ { 'X', 'X' }, 2, { 'Y' } )); - CPPUNIT_ASSERT_THROW( + CHECK(!automaton.addTransition(4, /* eps, */ { 'X', 'X' }, 2, { 'Y' } )); + CHECK_THROWS_AS( automaton.addTransition(4, /* eps, */ { 'X', 'Y' }, 2, { 'Y' } ), automaton::AutomatonException ); automaton.addTransition(4, 'b', { 'X', 'Y' }, 2, { 'Y' } ); - CPPUNIT_ASSERT_THROW( + CHECK_THROWS_AS( automaton.addTransition(4, 'a', { 'X' }, 2, { 'Y' } ), automaton::AutomatonException ); @@ -191,7 +183,7 @@ void AutomatonTest::DPDATransitions() { automaton.addFinalState(3); } -void AutomatonTest::testExtendedNFAAlphabet() { +SECTION ( "Extended NFA Alphabet" ) { automaton::ExtendedNFA < char, int > automaton (0); automaton.addState(0); automaton.addState(1); @@ -210,13 +202,13 @@ void AutomatonTest::testExtendedNFAAlphabet() { badConcat.appendElement(regexp::UnboundedRegExpSymbol < char > ('b')); badConcat.appendElement(regexp::UnboundedRegExpSymbol < char > (char('d'))); - CPPUNIT_ASSERT_THROW(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (badConcat), 1), automaton::AutomatonException); - CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (goodConcat1), 1)); - CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (goodConcat2), 1)); - CPPUNIT_ASSERT_NO_THROW(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (regexp::UnboundedRegExpEpsilon < char > ()), 1)); + CHECK_THROWS_AS(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (badConcat), 1), automaton::AutomatonException); + CHECK_NOTHROW(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (goodConcat1), 1)); + CHECK_NOTHROW(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (goodConcat2), 1)); + CHECK_NOTHROW(automaton.addTransition(0, regexp::UnboundedRegExpStructure < char > (regexp::UnboundedRegExpEpsilon < char > ()), 1)); } -void AutomatonTest::testNPDATransitions() { +SECTION ( "NPDA Transitions" ) { automaton::NPDA < common::ranked_symbol < char, unsigned >, void, char, unsigned > automaton(0, 'T'); common::ranked_symbol < char, unsigned > a2 ( 'a', 2 ); @@ -252,11 +244,11 @@ void AutomatonTest::testNPDATransitions() { automaton.setFinalStates({4}); factory::XmlDataFactory::toStdout(automaton); - CPPUNIT_ASSERT(!(automaton < automaton)); - CPPUNIT_ASSERT(automaton == automaton); + CHECK(!(automaton < automaton)); + CHECK(automaton == automaton); } -void AutomatonTest::testRHPDATransitions() { +SECTION ( "RHPDA Transitions" ) { automaton::RealTimeHeightDeterministicNPDA < char, void, char, unsigned > automaton { 'S' }; automaton.setStates({1, 2, 3}); automaton.setInitialStates({1}); @@ -271,11 +263,11 @@ void AutomatonTest::testRHPDATransitions() { automaton.setFinalStates({3}); factory::XmlDataFactory::toStdout(automaton); - CPPUNIT_ASSERT(!(automaton < automaton)); - CPPUNIT_ASSERT(automaton == automaton); + CHECK(!(automaton < automaton)); + CHECK(automaton == automaton); } -void AutomatonTest::testNFTAParser() { +SECTION ( "NFTA Parser" ) { common::ranked_symbol < char, unsigned > a ( 'a', 2 ); common::ranked_symbol < char, unsigned > b ( 'b', 1 ); common::ranked_symbol < char, unsigned > c ( 'c', 0 ); @@ -300,7 +292,7 @@ void AutomatonTest::testNFTAParser() { automaton.addFinalState(2); - CPPUNIT_ASSERT( automaton == automaton ); + CHECK( automaton == automaton ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(automaton); std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); @@ -309,11 +301,11 @@ void AutomatonTest::testNFTAParser() { ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); automaton::NFTA < char, unsigned, int > automaton2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( automaton == automaton2 ); + CHECK( automaton == automaton2 ); } } -void AutomatonTest::testNFTATransitions() { +SECTION ( "NFTA Transitions" ) { common::ranked_symbol < char, unsigned > a ( 'a', 2 ); common::ranked_symbol < char, unsigned > b ( 'b', 1 ); common::ranked_symbol < char, unsigned > c ( 'c', 0 ); @@ -339,10 +331,11 @@ void AutomatonTest::testNFTATransitions() { automaton.addFinalState ( 2 ); - CPPUNIT_ASSERT_THROW(automaton.removeInputSymbol(a), exception::CommonException); - CPPUNIT_ASSERT_NO_THROW(automaton.removeInputSymbol(d)); - CPPUNIT_ASSERT_NO_THROW(automaton.removeTransition(b, states1, 2)); - CPPUNIT_ASSERT_THROW(automaton.addTransition(b, states1, 1), exception::CommonException); - CPPUNIT_ASSERT_THROW(automaton.addTransition(a, states2, 1), exception::CommonException); - CPPUNIT_ASSERT_THROW(automaton.addTransition(d, states3, 0), exception::CommonException); + CHECK_THROWS_AS(automaton.removeInputSymbol(a), exception::CommonException); + CHECK_NOTHROW(automaton.removeInputSymbol(d)); + CHECK_NOTHROW(automaton.removeTransition(b, states1, 2)); + CHECK_THROWS_AS(automaton.addTransition(b, states1, 1), exception::CommonException); + CHECK_THROWS_AS(automaton.addTransition(a, states2, 1), exception::CommonException); + CHECK_THROWS_AS(automaton.addTransition(d, states3, 0), exception::CommonException); +} } diff --git a/alib2data/test-src/automaton/AutomatonTest.h b/alib2data/test-src/automaton/AutomatonTest.h deleted file mode 100644 index d0b4a48afebafcc3ce301e76ef2d5cee5aadb088..0000000000000000000000000000000000000000 --- a/alib2data/test-src/automaton/AutomatonTest.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef AUTOMATON_TEST_H_ -#define AUTOMATON_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class AutomatonTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( AutomatonTest ); - CPPUNIT_TEST( testDFAParser ); - CPPUNIT_TEST( testNFAInsertTransitions ); - CPPUNIT_TEST( SinglePopDPDATransitions ); - CPPUNIT_TEST( DPDATransitions ); - CPPUNIT_TEST( testExtendedNFAAlphabet ); - CPPUNIT_TEST( testRHPDATransitions ); - CPPUNIT_TEST( testNPDATransitions ); - CPPUNIT_TEST( testNFTAParser ); - CPPUNIT_TEST( testNFTATransitions ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testDFAParser(); - void testNFAInsertTransitions(); - void SinglePopDPDATransitions(); - void DPDATransitions(); - void testExtendedNFAAlphabet(); - void testRHPDATransitions(); - void testNPDATransitions(); - void testNFTAParser(); - void testNFTATransitions(); -}; - -#endif // AUTOMATON_TEST_H_ diff --git a/alib2data/test-src/common/SparseBoolVectorTest.cpp b/alib2data/test-src/common/SparseBoolVectorTest.cpp index d4f8f4255c3241b39e6e4de05752efb99d4de305..6bb878ab57c652278e7c7613006804baf2e4b69c 100644 --- a/alib2data/test-src/common/SparseBoolVectorTest.cpp +++ b/alib2data/test-src/common/SparseBoolVectorTest.cpp @@ -1,61 +1,11 @@ -#include "SparseBoolVectorTest.h" +#include <catch2/catch.hpp> #include <common/SparseBoolVector.hpp> #include <common/xml/SparseBoolVector.hpp> #include <factory/XmlDataFactory.hpp> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( SparseBoolVectorTest, "common" ); -CPPUNIT_TEST_SUITE_REGISTRATION ( SparseBoolVectorTest ); - -void SparseBoolVectorTest::setUp ( ) { -} - -void SparseBoolVectorTest::tearDown ( ) { -} - -void SparseBoolVectorTest::testVectorCompatibility() { - ext::vector < bool > orig; - for ( int i = 0; i < 1000; ++i ) { - orig.push_back ( false ); - } - for ( int i = 0; i < 20; ++i ) { - orig.push_back ( true ); - orig.push_back ( true ); - orig.push_back ( false ); - orig.push_back ( true ); - orig.push_back ( true ); - orig.push_back ( false ); - orig.push_back ( true ); - orig.push_back ( false ); - orig.push_back ( false ); - orig.push_back ( true ); - } - for ( int i = 0; i < 1000; ++i ) { - orig.push_back ( false ); - } - orig.push_back ( true ); - orig.push_back ( true ); - orig.push_back ( false ); - orig.push_back ( true ); - orig.push_back ( true ); - orig.push_back ( false ); - orig.push_back ( true ); - orig.push_back ( false ); - orig.push_back ( false ); - orig.push_back ( true ); - - common::SparseBoolVector compressed ( orig ); - ext::vector < bool > copy ( compressed ); - -/* std::cout << orig << std::endl; - std::cout << copy << std::endl; - std::cout << compressed.data ( ) << std::endl;*/ - - CPPUNIT_ASSERT ( orig == copy ); -} - -ext::vector < bool > createTestVectorBool ( size_t size ) { +static ext::vector < bool > createTestVectorBool ( size_t size ) { unsigned long long shadow = 0x2A76B147D6521C87ULL; ext::vector < bool > ref; while ( ref.size ( ) < size ) { @@ -70,83 +20,20 @@ ext::vector < bool > createTestVectorBool ( size_t size ) { return ref; } -void testOffset2 ( size_t size, size_t shift ) { + +static void testOffset2 ( size_t size, size_t shift ) { ext::vector < bool > ref = createTestVectorBool ( size ); common::SparseBoolVector data = ref; data <<= shift; ref <<= shift; -/* std::cout << "size = " << size << std::endl; - std::cout << "shift = " << shift << std::endl; - std::cout << "data = " << data.data ( ) << std::endl; - std::cout << "ref = " << common::SparseBoolVector ( ref ).data ( ) << std::endl;*/ - - CPPUNIT_ASSERT ( data == common::SparseBoolVector ( ref ) ); -} - -void SparseBoolVectorTest::testShifts4() { - for ( size_t shift = 0 ; shift < 100; ++ shift ) { - testOffset2 ( 0, shift ); - testOffset2 ( 31, shift ); - testOffset2 ( 32, shift ); - testOffset2 ( 33, shift ); - testOffset2 ( 63, shift ); - testOffset2 ( 64, shift ); - testOffset2 ( 65, shift ); - testOffset2 ( 1023, shift ); - testOffset2 ( 1024, shift ); - testOffset2 ( 1025, shift ); - testOffset2 ( 2000, shift ); - - } -} - -void SparseBoolVectorTest::testShifts5() { - unsigned long long shadow = 0x2A76B147D6521C87ULL; - common::SparseBoolVector data; - - for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { - data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); - } - for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { - data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); - } - for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { - data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); - } + /* std::cout << "size = " << size << std::endl; + std::cout << "shift = " << shift << std::endl; + std::cout << "data = " << data.data ( ) << std::endl; + std::cout << "ref = " << common::SparseBoolVector ( ref ).data ( ) << std::endl;*/ - common::SparseBoolVector data2 = data; - data2 <<= 64; - - data <<= 32; - data <<= 16; - data <<= 8; - data <<= 4; - data <<= 2; - data <<= 1; - data <<= 1; - -/* std::cout << "data = " << data.data ( ) << std::endl; - std::cout << "data2 = " << data2.data ( ) << std::endl;*/ - - data2 <<= 1; - data2 <<= 2; - data2 <<= 4; - data2 <<= 8; - data2 <<= 16; - data2 <<= 32; - data2 <<= 1; - - data <<= 27; - data <<= 17; - data <<= 13; - data <<= 7; - -/* std::cout << "data = " << data.data ( ) << std::endl; - std::cout << "data2 = " << data2.data ( ) << std::endl;*/ - - CPPUNIT_ASSERT ( data2 == data ); + CHECK ( data == common::SparseBoolVector ( ref ) ); } void testIterator ( size_t size ) { @@ -160,150 +47,260 @@ void testIterator ( size_t size ) { for ( size_t onePosition : data ) { --count; - CPPUNIT_ASSERT ( ref [ onePosition ] ); + CHECK ( ref [ onePosition ] ); } - CPPUNIT_ASSERT ( count == 0 ); + CHECK ( count == 0 ); } -void SparseBoolVectorTest::testOnesIterator() { - for ( size_t i = 0; i < 1000; i++ ) { - testIterator ( i ); + +TEST_CASE ( "Sparse Bool Vector", "[unit][data][string]" ) { + SECTION ( "Compatibility with Vector" ) { + ext::vector < bool > orig; + for ( int i = 0; i < 1000; ++i ) { + orig.push_back ( false ); + } + for ( int i = 0; i < 20; ++i ) { + orig.push_back ( true ); + orig.push_back ( true ); + orig.push_back ( false ); + orig.push_back ( true ); + orig.push_back ( true ); + orig.push_back ( false ); + orig.push_back ( true ); + orig.push_back ( false ); + orig.push_back ( false ); + orig.push_back ( true ); + } + for ( int i = 0; i < 1000; ++i ) { + orig.push_back ( false ); + } + orig.push_back ( true ); + orig.push_back ( true ); + orig.push_back ( false ); + orig.push_back ( true ); + orig.push_back ( true ); + orig.push_back ( false ); + orig.push_back ( true ); + orig.push_back ( false ); + orig.push_back ( false ); + orig.push_back ( true ); + + common::SparseBoolVector compressed ( orig ); + ext::vector < bool > copy ( compressed ); + + /* std::cout << orig << std::endl; + std::cout << copy << std::endl; + std::cout << compressed.data ( ) << std::endl;*/ + + CHECK ( orig == copy ); } - common::SparseBoolVector empty; - CPPUNIT_ASSERT ( empty.begin ( ) == empty.end ( ) ); - empty.push_back ( false ); - CPPUNIT_ASSERT ( empty.begin ( ) == empty.end ( ) ); -} + SECTION ( "Shifts 4" ) { + for ( size_t shift = 0 ; shift < 100; ++ shift ) { + testOffset2 ( 0, shift ); + testOffset2 ( 31, shift ); + testOffset2 ( 32, shift ); + testOffset2 ( 33, shift ); + testOffset2 ( 63, shift ); + testOffset2 ( 64, shift ); + testOffset2 ( 65, shift ); + testOffset2 ( 1023, shift ); + testOffset2 ( 1024, shift ); + testOffset2 ( 1025, shift ); + testOffset2 ( 2000, shift ); + + } + } + + SECTION ( "Shifts 5" ) { + unsigned long long shadow = 0x2A76B147D6521C87ULL; + common::SparseBoolVector data; + + for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { + data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); + } + for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { + data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); + } + for ( unsigned i = 0; i < sizeof ( unsigned long long ) * 8; ++ i ) { + data.push_back ( ( bool ) ( shadow & ( 1ULL << i ) ) ); + } -void SparseBoolVectorTest::testCompare() { - common::SparseBoolVector first; - common::SparseBoolVector second; - common::SparseBoolVector third; - common::SparseBoolVector fourth; - common::SparseBoolVector fifth; - common::SparseBoolVector sixth; + common::SparseBoolVector data2 = data; + data2 <<= 64; + + data <<= 32; + data <<= 16; + data <<= 8; + data <<= 4; + data <<= 2; + data <<= 1; + data <<= 1; + + /* std::cout << "data = " << data.data ( ) << std::endl; + std::cout << "data2 = " << data2.data ( ) << std::endl;*/ + + data2 <<= 1; + data2 <<= 2; + data2 <<= 4; + data2 <<= 8; + data2 <<= 16; + data2 <<= 32; + data2 <<= 1; + + data <<= 27; + data <<= 17; + data <<= 13; + data <<= 7; + + /* std::cout << "data = " << data.data ( ) << std::endl; + std::cout << "data2 = " << data2.data ( ) << std::endl;*/ + + CHECK ( data2 == data ); + } - first.push_back ( false ); + SECTION ( "Ones Iterator" ) { + for ( size_t i = 0; i < 1000; i++ ) { + testIterator ( i ); + } - second.push_back ( true ); + common::SparseBoolVector empty; + CHECK ( empty.begin ( ) == empty.end ( ) ); + empty.push_back ( false ); + CHECK ( empty.begin ( ) == empty.end ( ) ); + } - third.push_back ( false ); - third.push_back ( false ); + SECTION ( "Compare" ) { + common::SparseBoolVector first; + common::SparseBoolVector second; + common::SparseBoolVector third; + common::SparseBoolVector fourth; + common::SparseBoolVector fifth; + common::SparseBoolVector sixth; - fourth.push_back ( false ); - fourth.push_back ( true ); + first.push_back ( false ); - fifth.push_back ( true ); - fifth.push_back ( false ); + second.push_back ( true ); - sixth.push_back ( true ); - sixth.push_back ( true ); + third.push_back ( false ); + third.push_back ( false ); - ext::compare < common::SparseBoolVector > comp; - CPPUNIT_ASSERT ( comp ( first, first ) == 0 ); - CPPUNIT_ASSERT ( comp ( first, second ) < 0 ); + fourth.push_back ( false ); + fourth.push_back ( true ); - CPPUNIT_ASSERT ( comp ( second, first ) > 0 ); - CPPUNIT_ASSERT ( comp ( second, second ) == 0 ); + fifth.push_back ( true ); + fifth.push_back ( false ); - CPPUNIT_ASSERT ( comp ( third, third ) == 0 ); - CPPUNIT_ASSERT ( comp ( third, fourth ) < 0 ); - CPPUNIT_ASSERT ( comp ( third, fifth ) < 0 ); - CPPUNIT_ASSERT ( comp ( third, sixth ) < 0 ); + sixth.push_back ( true ); + sixth.push_back ( true ); - CPPUNIT_ASSERT ( comp ( fourth, third ) > 0 ); - CPPUNIT_ASSERT ( comp ( fourth, fourth ) == 0 ); - CPPUNIT_ASSERT ( comp ( fourth, fifth ) < 0 ); - CPPUNIT_ASSERT ( comp ( fourth, sixth ) < 0 ); + ext::compare < common::SparseBoolVector > comp; + CHECK ( comp ( first, first ) == 0 ); + CHECK ( comp ( first, second ) < 0 ); - CPPUNIT_ASSERT ( comp ( fifth, third ) > 0 ); - CPPUNIT_ASSERT ( comp ( fifth, fourth ) > 0 ); - CPPUNIT_ASSERT ( comp ( fifth, fifth ) == 0 ); - CPPUNIT_ASSERT ( comp ( fifth, sixth ) < 0 ); + CHECK ( comp ( second, first ) > 0 ); + CHECK ( comp ( second, second ) == 0 ); - CPPUNIT_ASSERT ( comp ( sixth, third ) > 0 ); - CPPUNIT_ASSERT ( comp ( sixth, fourth ) > 0 ); - CPPUNIT_ASSERT ( comp ( sixth, fifth ) > 0 ); - CPPUNIT_ASSERT ( comp ( sixth, sixth ) == 0 ); -} + CHECK ( comp ( third, third ) == 0 ); + CHECK ( comp ( third, fourth ) < 0 ); + CHECK ( comp ( third, fifth ) < 0 ); + CHECK ( comp ( third, sixth ) < 0 ); -void SparseBoolVectorTest::testSubscript() { - ext::vector < bool > ref = createTestVectorBool ( 2000 ); - common::SparseBoolVector data ( ref ); + CHECK ( comp ( fourth, third ) > 0 ); + CHECK ( comp ( fourth, fourth ) == 0 ); + CHECK ( comp ( fourth, fifth ) < 0 ); + CHECK ( comp ( fourth, sixth ) < 0 ); -/* std::cout << ref << std::endl; - std::cout << data.data ( ) << std::endl;*/ + CHECK ( comp ( fifth, third ) > 0 ); + CHECK ( comp ( fifth, fourth ) > 0 ); + CHECK ( comp ( fifth, fifth ) == 0 ); + CHECK ( comp ( fifth, sixth ) < 0 ); - for ( size_t i = 0; i < ref.size ( ); ++ i ) - CPPUNIT_ASSERT_EQUAL_MESSAGE ( "Failed on index " + ext::to_string ( i ), ( bool ) ref [ i ], ( bool ) data [ i ] ); -} + CHECK ( comp ( sixth, third ) > 0 ); + CHECK ( comp ( sixth, fourth ) > 0 ); + CHECK ( comp ( sixth, fifth ) > 0 ); + CHECK ( comp ( sixth, sixth ) == 0 ); + } -void SparseBoolVectorTest::testSubscript2() { - ext::vector < bool > ref; - common::SparseBoolVector data; + SECTION ( "Array Subscript" ) { + { + ext::vector < bool > ref = createTestVectorBool ( 2000 ); + common::SparseBoolVector data ( ref ); - ref.resize ( 2000 ); - data.resize ( 2000 ); + /* std::cout << ref << std::endl; + std::cout << data.data ( ) << std::endl;*/ - ref[520] = true; - data[520] = true; + for ( size_t i = 0; i < ref.size ( ); ++ i ) { + INFO ( "Failed on index " << i ); + CHECK ( ( bool ) ref [ i ] == ( bool ) data [ i ] ); + } + } + { + ext::vector < bool > ref; + common::SparseBoolVector data; - CPPUNIT_ASSERT ( ( ext::vector < bool > ) data == ref ); + ref.resize ( 2000 ); + data.resize ( 2000 ); - ref[521] = true; - data[521] = true; + ref[520] = true; + data[520] = true; - CPPUNIT_ASSERT ( ( ext::vector < bool > ) data == ref ); + CHECK ( ( ext::vector < bool > ) data == ref ); - ref[128] = true; - data[128] = true; + ref[521] = true; + data[521] = true; - CPPUNIT_ASSERT ( ( ext::vector < bool > ) data == ref ); + CHECK ( ( ext::vector < bool > ) data == ref ); - ref[255] = true; - data[255] = true; + ref[128] = true; + data[128] = true; - CPPUNIT_ASSERT ( ( ext::vector < bool > ) data == ref ); + CHECK ( ( ext::vector < bool > ) data == ref ); - ref[256] = true; - data[256] = true; + ref[255] = true; + data[255] = true; - CPPUNIT_ASSERT ( ( ext::vector < bool > ) data == ref ); -} + CHECK ( ( ext::vector < bool > ) data == ref ); -void SparseBoolVectorTest::testOperatorAnd ( ) { - ext::vector < bool > first; - ext::vector < bool > second; - ext::vector < bool > ref; + ref[256] = true; + data[256] = true; - first.resize ( 2000 ); - second.resize ( 2000 ); - ref.resize ( 2000 ); + CHECK ( ( ext::vector < bool > ) data == ref ); + } - first[520] = first[1] = first[3] = first[512] = first[511] = first[128] = first[127] = first[17] = first[53] = first[1999] = true; - second[80] = second[1] = second[5] = second[51] = second[5] = second[7] = second[127] = second[1] = second[77] = second[999] = true; + SECTION ( "Overloaded bitwise and" ) { + ext::vector < bool > first; + ext::vector < bool > second; + ext::vector < bool > ref; - ref[1] = ref[127] = true; + first.resize ( 2000 ); + second.resize ( 2000 ); + ref.resize ( 2000 ); - common::SparseBoolVector data; - CPPUNIT_ASSERT ( ( first & second ) == ref ); -} + first[520] = first[1] = first[3] = first[512] = first[511] = first[128] = first[127] = first[17] = first[53] = first[1999] = true; + second[80] = second[1] = second[5] = second[51] = second[5] = second[7] = second[127] = second[1] = second[77] = second[999] = true; -void SparseBoolVectorTest::testXmlApi() { - ext::vector < bool > ref = createTestVectorBool ( 2000 ); - common::SparseBoolVector data ( ref ); + ref[1] = ref[127] = true; + + common::SparseBoolVector data; + CHECK ( ( first & second ) == ref ); + } - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens( data ); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); -// std::cout << tmp << std::endl; + SECTION ( "Xml Api" ) { + ext::vector < bool > ref = createTestVectorBool ( 2000 ); + common::SparseBoolVector data ( ref ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - common::SparseBoolVector data2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens( data ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + // std::cout << tmp << std::endl; -/* std::cout << data.data ( ) << std::endl; - std::cout << data2.data ( ) << std::endl;*/ - CPPUNIT_ASSERT( data == data2 ); -} + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + common::SparseBoolVector data2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); + /* std::cout << data.data ( ) << std::endl; + std::cout << data2.data ( ) << std::endl;*/ + CHECK( data == data2 ); + } + } +} diff --git a/alib2data/test-src/common/SparseBoolVectorTest.h b/alib2data/test-src/common/SparseBoolVectorTest.h deleted file mode 100644 index 0a2347f9698d978f2b10f8925704328a77ca7004..0000000000000000000000000000000000000000 --- a/alib2data/test-src/common/SparseBoolVectorTest.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef SPARSE_BOOL_VECTOR_TEST_H_ -#define SPARSE_BOOL_VECTOR_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class SparseBoolVectorTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( SparseBoolVectorTest ); - CPPUNIT_TEST( testVectorCompatibility ); - CPPUNIT_TEST( testShifts4 ); - CPPUNIT_TEST( testShifts5 ); - CPPUNIT_TEST( testOnesIterator ); - CPPUNIT_TEST( testCompare ); - CPPUNIT_TEST( testSubscript ); - CPPUNIT_TEST( testSubscript2 ); - CPPUNIT_TEST( testOperatorAnd ); - CPPUNIT_TEST( testXmlApi ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testVectorCompatibility(); - void testShifts4(); - void testShifts5(); - void testOnesIterator(); - void testCompare(); - void testSubscript(); - void testSubscript2(); - void testOperatorAnd(); - void testXmlApi(); -}; - -#endif // SPARSE_BOOL_VECTOR_TEST_H_ diff --git a/alib2data/test-src/grammar/GrammarTest.cpp b/alib2data/test-src/grammar/GrammarTest.cpp index 66c9a2ebdb4862d097708c28b0d843b3262b335b..4d59e3ff8ef6b2d82de06fe361e96ff07ff50c70 100644 --- a/alib2data/test-src/grammar/GrammarTest.cpp +++ b/alib2data/test-src/grammar/GrammarTest.cpp @@ -1,5 +1,4 @@ -#include <alib/list> -#include "GrammarTest.h" +#include <catch2/catch.hpp> #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -40,364 +39,352 @@ #include <primitive/xml/Integer.h> #include <primitive/xml/String.h> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GrammarTest, "grammar" ); -CPPUNIT_TEST_SUITE_REGISTRATION( GrammarTest ); - -void GrammarTest::setUp() { -} - -void GrammarTest::tearDown() { -} - -void GrammarTest::testUnrestrictedParser() { - { - grammar::UnrestrictedGrammar < > grammar(DefaultSymbolType(1)); +TEST_CASE ( "Grammar test", "[unit][data][grammar]" ) { + SECTION ( "Unrestricted Parser" ) { + { + grammar::UnrestrictedGrammar < > grammar(DefaultSymbolType(1)); - grammar.addNonterminalSymbol(DefaultSymbolType(1)); - grammar.addNonterminalSymbol(DefaultSymbolType(2)); - grammar.addNonterminalSymbol(DefaultSymbolType(3)); - grammar.addTerminalSymbol(DefaultSymbolType("a")); - grammar.addTerminalSymbol(DefaultSymbolType("b")); + grammar.addNonterminalSymbol(DefaultSymbolType(1)); + grammar.addNonterminalSymbol(DefaultSymbolType(2)); + grammar.addNonterminalSymbol(DefaultSymbolType(3)); + grammar.addTerminalSymbol(DefaultSymbolType("a")); + grammar.addTerminalSymbol(DefaultSymbolType("b")); - grammar.addRule({DefaultSymbolType(1)}, {DefaultSymbolType("a"), DefaultSymbolType(2)}); - grammar.addRule({DefaultSymbolType(2)}, {DefaultSymbolType("b"), DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2), DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("b"), DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(1)}, ext::vector<DefaultSymbolType> {DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(1)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType(2)}); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {}); + grammar.addRule({DefaultSymbolType(1)}, {DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule({DefaultSymbolType(2)}, {DefaultSymbolType("b"), DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2), DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("b"), DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(1)}, ext::vector<DefaultSymbolType> {DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(1)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {}); - CPPUNIT_ASSERT( grammar == grammar ); + CHECK( grammar == grammar ); - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::UnrestrictedGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::UnrestrictedGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( grammar == grammar2 ); - } - { - grammar::ContextPreservingUnrestrictedGrammar < > grammar(DefaultSymbolType(1)); + CHECK( grammar == grammar2 ); + } + { + grammar::ContextPreservingUnrestrictedGrammar < > grammar(DefaultSymbolType(1)); - grammar.addNonterminalSymbol(DefaultSymbolType(1)); - grammar.addNonterminalSymbol(DefaultSymbolType(2)); - grammar.addNonterminalSymbol(DefaultSymbolType(3)); - grammar.addTerminalSymbol(DefaultSymbolType("a")); - grammar.addTerminalSymbol(DefaultSymbolType("b")); + grammar.addNonterminalSymbol(DefaultSymbolType(1)); + grammar.addNonterminalSymbol(DefaultSymbolType(2)); + grammar.addNonterminalSymbol(DefaultSymbolType(3)); + grammar.addTerminalSymbol(DefaultSymbolType("a")); + grammar.addTerminalSymbol(DefaultSymbolType("b")); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}); - grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(2), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType("b"), DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType(2)}); - grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(2), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(2), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType("b"), DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(2), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {}); - CPPUNIT_ASSERT( grammar == grammar ); + CHECK( grammar == grammar ); - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::ContextPreservingUnrestrictedGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::ContextPreservingUnrestrictedGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); + } } -} -void GrammarTest::testRegularParser() { - { - grammar::RightRG < signed char, int > grammar ( 1 ); + SECTION ( "Regular Parser" ) { + { + grammar::RightRG < signed char, int > grammar ( 1 ); - grammar.addTerminalSymbol ( 2 ); - CPPUNIT_ASSERT_THROW ( grammar.addNonterminalSymbol ( 2 ), exception::CommonException ); - } - { - grammar::RightRG < std::string, int > grammar ( 1 ); + grammar.addTerminalSymbol ( 2 ); + CHECK_THROWS_AS ( grammar.addNonterminalSymbol ( 2 ), exception::CommonException ); + } + { + grammar::RightRG < std::string, int > grammar ( 1 ); - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); - grammar.addRule ( 1, ext::make_pair ( "a", 2 ) ); - grammar.addRule ( 2, ext::make_pair ( "b", 3 ) ); + grammar.addRule ( 1, ext::make_pair ( "a", 2 ) ); + grammar.addRule ( 2, ext::make_pair ( "b", 3 ) ); - CPPUNIT_ASSERT( grammar == grammar ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::RightRG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::RightRG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); + } } - } - { - grammar::RightLG < std::string, int > grammar ( 1 ); + { + grammar::RightLG < std::string, int > grammar ( 1 ); - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); - grammar.addRule ( 1, ext::make_pair ( ext::vector < std::string > { "a" }, 2 ) ); - grammar.addRule ( 2, ext::make_pair ( ext::vector < std::string > { "b" }, 3 ) ); - grammar.addRule ( 1, ext::make_pair ( ext::vector < std::string > {}, 3 ) ); - grammar.addRule ( 1, ext::make_pair ( ext::vector < std::string > { "a", "a", "a" }, 2 ) ); + grammar.addRule ( 1, ext::make_pair ( ext::vector < std::string > { "a" }, 2 ) ); + grammar.addRule ( 2, ext::make_pair ( ext::vector < std::string > { "b" }, 3 ) ); + grammar.addRule ( 1, ext::make_pair ( ext::vector < std::string > {}, 3 ) ); + grammar.addRule ( 1, ext::make_pair ( ext::vector < std::string > { "a", "a", "a" }, 2 ) ); - CPPUNIT_ASSERT( grammar == grammar ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - std::cout << tmp << std::endl; + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::RightLG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::RightLG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); + } } - } - { - grammar::LeftRG < std::string, int > grammar ( 1 ); + { + grammar::LeftRG < std::string, int > grammar ( 1 ); - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); - grammar.addRule ( 1, ext::make_pair ( 2, "a" ) ); - grammar.addRule ( 2, ext::make_pair ( 3, "b" ) ); + grammar.addRule ( 1, ext::make_pair ( 2, "a" ) ); + grammar.addRule ( 2, ext::make_pair ( 3, "b" ) ); - CPPUNIT_ASSERT( grammar == grammar ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::LeftRG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::LeftRG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); + } } - } - { - grammar::LeftLG < std::string, int > grammar ( 1 ); - - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); + { + grammar::LeftLG < std::string, int > grammar ( 1 ); - grammar.addRule ( 1, ext::make_pair ( 2, ext::vector < std::string > { "a" } ) ); - grammar.addRule ( 2, ext::make_pair ( 3, ext::vector < std::string > { "b" } ) ); - grammar.addRule ( 1, ext::make_pair ( 3, ext::vector < std::string > {} ) ); - grammar.addRule ( 1, ext::make_pair ( 2, ext::vector < std::string > { "a", "a", "a" } ) ); + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); - CPPUNIT_ASSERT( grammar == grammar ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + grammar.addRule ( 1, ext::make_pair ( 2, ext::vector < std::string > { "a" } ) ); + grammar.addRule ( 2, ext::make_pair ( 3, ext::vector < std::string > { "b" } ) ); + grammar.addRule ( 1, ext::make_pair ( 3, ext::vector < std::string > {} ) ); + grammar.addRule ( 1, ext::make_pair ( 2, ext::vector < std::string > { "a", "a", "a" } ) ); - std::cout << tmp << std::endl; + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::LeftLG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::LeftLG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); + } } } -} -void GrammarTest::testContextFreeParser() { - { - grammar::LG < std::string, int > grammar ( 1 ); + SECTION ( "CFG Parser" ) { + { + grammar::LG < std::string, int > grammar ( 1 ); - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); - grammar.addRule ( 1, ext::make_tuple ( ext::vector < std::string > { "a" }, 2, ext::vector < std::string > { } ) ); - grammar.addRule ( 2, ext::make_tuple ( ext::vector < std::string > { "b" }, 3, ext::vector < std::string > { } ) ); - grammar.addRule ( 1, ext::make_tuple ( ext::vector < std::string > { }, 3, ext::vector < std::string > { } ) ); - grammar.addRule ( 1, ext::make_tuple ( ext::vector < std::string > { "a", "a", "a"}, 2, ext::vector < std::string > { } ) ); + grammar.addRule ( 1, ext::make_tuple ( ext::vector < std::string > { "a" }, 2, ext::vector < std::string > { } ) ); + grammar.addRule ( 2, ext::make_tuple ( ext::vector < std::string > { "b" }, 3, ext::vector < std::string > { } ) ); + grammar.addRule ( 1, ext::make_tuple ( ext::vector < std::string > { }, 3, ext::vector < std::string > { } ) ); + grammar.addRule ( 1, ext::make_tuple ( ext::vector < std::string > { "a", "a", "a"}, 2, ext::vector < std::string > { } ) ); - CPPUNIT_ASSERT( grammar == grammar ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::LG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::LG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); + } } - } - { - grammar::EpsilonFreeCFG < std::string, int > grammar ( 1 ); - - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); - grammar.setGeneratesEpsilon ( true ); - - grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { "a" }, { 2 } } ); - grammar.addRule ( 2, ext::vector < ext::variant < std::string, int > > { { "b" }, { 3 } } ); - grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { 3 } } ); - grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { "a" }, { "a" }, { "a" }, { 2 } } ); - - CPPUNIT_ASSERT( grammar == grammar ); { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::EpsilonFreeCFG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - - CPPUNIT_ASSERT( grammar == grammar2 ); + grammar::EpsilonFreeCFG < std::string, int > grammar ( 1 ); + + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); + grammar.setGeneratesEpsilon ( true ); + + grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { "a" }, { 2 } } ); + grammar.addRule ( 2, ext::vector < ext::variant < std::string, int > > { { "b" }, { 3 } } ); + grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { 3 } } ); + grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { "a" }, { "a" }, { "a" }, { 2 } } ); + + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::EpsilonFreeCFG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + + CHECK( grammar == grammar2 ); + } } - } - { - grammar::CFG < std::string, int > grammar ( 1 ); - - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); - - grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { "a" }, { 2 } } ); - grammar.addRule ( 2, ext::vector < ext::variant < std::string, int > > { { "b" }, { 3 } } ); - grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { 3 } } ); - grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { "a" }, { "a" }, { "a" }, { 2 } } ); - grammar.addRule ( 2, ext::vector < ext::variant < std::string, int > > { } ); - - CPPUNIT_ASSERT( grammar == grammar ); { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::CFG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - - CPPUNIT_ASSERT( grammar == grammar2 ); + grammar::CFG < std::string, int > grammar ( 1 ); + + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); + + grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { "a" }, { 2 } } ); + grammar.addRule ( 2, ext::vector < ext::variant < std::string, int > > { { "b" }, { 3 } } ); + grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { 3 } } ); + grammar.addRule ( 1, ext::vector < ext::variant < std::string, int > > { { "a" }, { "a" }, { "a" }, { 2 } } ); + grammar.addRule ( 2, ext::vector < ext::variant < std::string, int > > { } ); + + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::CFG < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + + CHECK( grammar == grammar2 ); + } } - } - { - grammar::CNF < std::string, int > grammar ( 1 ); - - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); - grammar.setGeneratesEpsilon ( true ); - - grammar.addRule ( 1, ext::make_pair ( 3, 2 ) ); - grammar.addRule ( 2, ext::make_pair ( 3, 3 ) ); - grammar.addRule ( 3, "a" ); - grammar.addRule ( 1, "a" ); - - CPPUNIT_ASSERT( grammar == grammar ); { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::CNF < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - - CPPUNIT_ASSERT( grammar == grammar2 ); + grammar::CNF < std::string, int > grammar ( 1 ); + + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); + grammar.setGeneratesEpsilon ( true ); + + grammar.addRule ( 1, ext::make_pair ( 3, 2 ) ); + grammar.addRule ( 2, ext::make_pair ( 3, 3 ) ); + grammar.addRule ( 3, "a" ); + grammar.addRule ( 1, "a" ); + + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::CNF < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + + CHECK( grammar == grammar2 ); + } } - } - { - grammar::GNF < std::string, int > grammar ( 1 ); - - grammar.addNonterminalSymbol ( 1 ); - grammar.addNonterminalSymbol ( 2 ); - grammar.addNonterminalSymbol ( 3 ); - grammar.addTerminalSymbol ( "a" ); - grammar.addTerminalSymbol ( "b" ); - grammar.setGeneratesEpsilon ( true ); - - grammar.addRule ( 1, ext::make_pair ( "a", ext::vector < int > { 2 } ) ); - grammar.addRule ( 2, ext::make_pair ( "b", ext::vector < int > { 3 } ) ); - grammar.addRule ( 3, ext::make_pair ( "a", ext::vector < int > { } ) ); - grammar.addRule ( 1, ext::make_pair ( "a", ext::vector < int > { } ) ); - - CPPUNIT_ASSERT( grammar == grammar ); { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::GNF < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - - CPPUNIT_ASSERT( grammar == grammar2 ); + grammar::GNF < std::string, int > grammar ( 1 ); + + grammar.addNonterminalSymbol ( 1 ); + grammar.addNonterminalSymbol ( 2 ); + grammar.addNonterminalSymbol ( 3 ); + grammar.addTerminalSymbol ( "a" ); + grammar.addTerminalSymbol ( "b" ); + grammar.setGeneratesEpsilon ( true ); + + grammar.addRule ( 1, ext::make_pair ( "a", ext::vector < int > { 2 } ) ); + grammar.addRule ( 2, ext::make_pair ( "b", ext::vector < int > { 3 } ) ); + grammar.addRule ( 3, ext::make_pair ( "a", ext::vector < int > { } ) ); + grammar.addRule ( 1, ext::make_pair ( "a", ext::vector < int > { } ) ); + + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::GNF < std::string, int > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + + CHECK( grammar == grammar2 ); + } } } -} -void GrammarTest::testContextSensitiveParser() { - { - grammar::CSG < > grammar(DefaultSymbolType(1)); + SECTION ( "CSG Parser" ) { + { + grammar::CSG < > grammar(DefaultSymbolType(1)); - grammar.addNonterminalSymbol(DefaultSymbolType(1)); - grammar.addNonterminalSymbol(DefaultSymbolType(2)); - grammar.addNonterminalSymbol(DefaultSymbolType(3)); - grammar.addTerminalSymbol(DefaultSymbolType("a")); - grammar.addTerminalSymbol(DefaultSymbolType("b")); + grammar.addNonterminalSymbol(DefaultSymbolType(1)); + grammar.addNonterminalSymbol(DefaultSymbolType(2)); + grammar.addNonterminalSymbol(DefaultSymbolType(3)); + grammar.addTerminalSymbol(DefaultSymbolType("a")); + grammar.addTerminalSymbol(DefaultSymbolType("b")); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}); - grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(2), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType("b"), DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(2), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType("b"), DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {}, DefaultSymbolType(1), ext::vector<DefaultSymbolType> {}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType(2)}); - CPPUNIT_ASSERT( grammar == grammar ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::CSG < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::CSG < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); + } } - } - { - grammar::NonContractingGrammar < > grammar(DefaultSymbolType(1)); + { + grammar::NonContractingGrammar < > grammar(DefaultSymbolType(1)); - grammar.addNonterminalSymbol(DefaultSymbolType(1)); - grammar.addNonterminalSymbol(DefaultSymbolType(2)); - grammar.addNonterminalSymbol(DefaultSymbolType(3)); - grammar.addTerminalSymbol(DefaultSymbolType("a")); - grammar.addTerminalSymbol(DefaultSymbolType("b")); + grammar.addNonterminalSymbol(DefaultSymbolType(1)); + grammar.addNonterminalSymbol(DefaultSymbolType(2)); + grammar.addNonterminalSymbol(DefaultSymbolType(3)); + grammar.addTerminalSymbol(DefaultSymbolType("a")); + grammar.addTerminalSymbol(DefaultSymbolType("b")); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2), DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("b"), DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(1)}, ext::vector<DefaultSymbolType> {DefaultSymbolType(3)}); - grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(1)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2), DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType(2)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(2)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("b"), DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(1)}, ext::vector<DefaultSymbolType> {DefaultSymbolType(3)}); + grammar.addRule(ext::vector<DefaultSymbolType> {DefaultSymbolType(1)}, ext::vector<DefaultSymbolType> {DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType("a"), DefaultSymbolType(2)}); - CPPUNIT_ASSERT( grammar == grammar ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( grammar == grammar ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - grammar::NonContractingGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + grammar::NonContractingGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); + } } } } - diff --git a/alib2data/test-src/grammar/GrammarTest.h b/alib2data/test-src/grammar/GrammarTest.h deleted file mode 100644 index 4a386d2ceb3171267063153ba79e4db71414c6c9..0000000000000000000000000000000000000000 --- a/alib2data/test-src/grammar/GrammarTest.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef GRAMMAR_TEST_H_ -#define GRAMMAR_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class GrammarTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( GrammarTest ); - CPPUNIT_TEST( testUnrestrictedParser ); - CPPUNIT_TEST( testContextSensitiveParser ); - CPPUNIT_TEST( testContextFreeParser ); - CPPUNIT_TEST( testRegularParser ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testUnrestrictedParser(); - void testContextSensitiveParser(); - void testContextFreeParser(); - void testRegularParser(); -}; - -#endif // GRAMMAR_TEST_H_ diff --git a/alib2data/test-src/main.cpp b/alib2data/test-src/main.cpp index adb58324a109835bfda91d246781668910521414..4ed06df1f7bea8cc18ee161389b9c3e2741b08a0 100644 --- a/alib2data/test-src/main.cpp +++ b/alib2data/test-src/main.cpp @@ -1,166 +1,2 @@ -#include <version.hpp> - -#include <tclap/CmdLine.h> - -#include <cppunit/CompilerOutputter.h> -#include <cppunit/extensions/TestFactoryRegistry.h> -#include <cppunit/ui/text/TestRunner.h> -#include <cppunit/TestResultCollector.h> -#include <cppunit/TestResult.h> -#include <cppunit/XmlOutputter.h> - -#include <cppunit/Test.h> -#include <cppunit/TestFailure.h> -#include <cppunit/portability/Stream.h> -#include <cppunit/TestListener.h> -#include <cppunit/SourceLine.h> -#include <cppunit/Exception.h> - -#include <exception/CommonException.h> - -CPPUNIT_NS_BEGIN - -class CPPUNIT_API TestProgressListener : public TestListener -{ -public: - TestProgressListener(); - - virtual ~TestProgressListener(); - - void startTest( Test *test ); - - void addFailure( const TestFailure &failure ); - - void endTest( Test *test ); - - int getResult() const; - - void printResults() const; - -private: - TestProgressListener( const TestProgressListener © ); - - void operator =( const TestProgressListener © ); - -private: - int m_Failures; - int m_Tests; - int m_Assertions; - bool m_lastTestFailed; -}; - -TestProgressListener::TestProgressListener() : m_Failures( 0 ), m_Tests(0), m_Assertions(0), m_lastTestFailed( false ) -{ -} - -TestProgressListener::~TestProgressListener() -{ -} - -void TestProgressListener::startTest( Test * test ) -{ - stdCOut() << test->getName() << ":" << "\n"; - stdCOut().flush(); - - m_lastTestFailed = false; - m_Tests++; -} - -void TestProgressListener::addFailure( const TestFailure &failure ) -{ - stdCOut() << (failure.isError() ? "error" : "assertion") << " : " << failure.failedTestName() << " : " << failure.sourceLine().lineNumber() << "\n"; - stdCOut() << "Exception " << failure.thrownException()->message().details(); - - m_lastTestFailed = true; - if(failure.isError()) m_Failures++; else m_Assertions++; -} - -void TestProgressListener::endTest( Test * test) -{ - stdCOut() << "Result (" << test->getName() << ")"; - stdCOut().flush(); - - if ( !m_lastTestFailed ) - stdCOut() << " : OK"; - else - stdCOut() << " : Fail"; - stdCOut() << "\n\n"; -} - -int TestProgressListener::getResult() const { - return m_Failures + m_Assertions; -} - -void TestProgressListener::printResults() const { - stdCOut() << "Overal result: Tests: " << m_Tests << " Assertions: " << m_Assertions << " Failures: " << m_Failures << "\n"; -} - -CPPUNIT_NS_END - -int main(int argc, char* argv[]) { - try { - TCLAP::CmdLine cmd("Main test binary.", ' ', ALIB_VERSION_INFO); - - TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" ); - cmd.add( testPathSegments ); - - cmd.parse(argc, argv); - - CppUnit::TestResult controller; - - CppUnit::TestResultCollector result; - controller.addListener( &result ); - - CppUnit::TestProgressListener progressListener; - controller.addListener( &progressListener ); - - CppUnit::Test *suite = NULL; - std::string testPath = ""; - if(testPathSegments.getValue().size() == 0) { - // Get the top level suite from the registry - suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - } else if(testPathSegments.getValue().size() == 1) { - suite = CppUnit::TestFactoryRegistry::getRegistry(testPathSegments.getValue()[0]).makeTest(); - } else { - suite = CppUnit::TestFactoryRegistry::getRegistry(testPathSegments.getValue()[0]).makeTest(); - bool first = true; - for(const std::string& path : testPathSegments.getValue()) { - if(first) { - first = false; - continue; - } - testPath += path + "/"; - } - testPath.pop_back(); - } - - // Adds the test to the list of test to run - CppUnit::TextUi::TestRunner runner; - runner.addTest( suite ); - - // Change the default outputter to a compiler error format outputter - runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); - // Run the tests. - runner.run( controller, testPath ); - - progressListener.printResults(); - - std::ofstream xmlFileResults("CppUnitTestResults.xml"); - CppUnit::XmlOutputter xmlOut(&result, xmlFileResults); - xmlOut.write(); - - return progressListener.getResult(); - } catch(const exception::CommonException& exception) { - std::cerr << exception.getCause() << std::endl; - return 1; - } catch(const TCLAP::ArgException& exception) { - std::cerr << exception.error() << std::endl; - return 2; - } catch (const std::exception& exception) { - std::cerr << "Exception caught: " << exception.what() << std::endl; - return 3; - } catch(...) { - std::cerr << "Unknown exception caught." << std::endl; - return 127; - } -} +#define CATCH_CONFIG_MAIN +#include <catch2/catch.hpp> diff --git a/alib2data/test-src/regexp/RegExpTest.cpp b/alib2data/test-src/regexp/RegExpTest.cpp index 8712ab60d1e96d9224f49918d09680f9b13ea623..5b4d473ce3c5625cbdbf233111c8717fc96f6c2c 100644 --- a/alib2data/test-src/regexp/RegExpTest.cpp +++ b/alib2data/test-src/regexp/RegExpTest.cpp @@ -1,5 +1,4 @@ -#include <alib/list> -#include "RegExpTest.h" +#include <catch2/extensions/HelperMacros.h> #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -13,631 +12,614 @@ #include "factory/XmlDataFactory.hpp" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RegExpTest, "regexp" ); -CPPUNIT_TEST_SUITE_REGISTRATION( RegExpTest ); +TEST_CASE ( "RegExp test", "[unit][data][regexp]" ) { + SECTION ( "Copy construction" ) { + { + regexp::UnboundedRegExpSymbol < int > l1 = regexp::UnboundedRegExpSymbol < int >( 1 ); + regexp::UnboundedRegExpSymbol < int > l2 = regexp::UnboundedRegExpSymbol < int >( 2 ); -void RegExpTest::setUp() { -} + regexp::UnboundedRegExpConcatenation < int > con = regexp::UnboundedRegExpConcatenation < int >(); + con.appendElement(l1); + con.appendElement(l2); -void RegExpTest::tearDown() { -} + regexp::UnboundedRegExpIteration < int > ite = regexp::UnboundedRegExpIteration < int >(l1); -void RegExpTest::testCopyConstruct() { - { - regexp::UnboundedRegExpSymbol < int > l1 = regexp::UnboundedRegExpSymbol < int >( 1 ); - regexp::UnboundedRegExpSymbol < int > l2 = regexp::UnboundedRegExpSymbol < int >( 2 ); + regexp::UnboundedRegExpAlternation < int > alt = regexp::UnboundedRegExpAlternation < int >(); + alt.appendElement(con); + alt.appendElement(ite); - regexp::UnboundedRegExpConcatenation < int > con = regexp::UnboundedRegExpConcatenation < int >(); - con.appendElement(l1); - con.appendElement(l2); + regexp::UnboundedRegExp < int > regexp({1, 2, 3}, regexp::UnboundedRegExpStructure < int > ( alt ) ); - regexp::UnboundedRegExpIteration < int > ite = regexp::UnboundedRegExpIteration < int >(l1); + regexp::UnboundedRegExp < int > regexp2(regexp); - regexp::UnboundedRegExpAlternation < int > alt = regexp::UnboundedRegExpAlternation < int >(); - alt.appendElement(con); - alt.appendElement(ite); + CHECK( regexp == regexp2 ); - regexp::UnboundedRegExp < int > regexp({1, 2, 3}, regexp::UnboundedRegExpStructure < int > ( alt ) ); + regexp::UnboundedRegExp < int > regexp3(std::move(regexp)); - regexp::UnboundedRegExp < int > regexp2(regexp); + CHECK( regexp2 == regexp3 ); + } + { + regexp::FormalRegExpSymbol < int > l1 = regexp::FormalRegExpSymbol < int >( 1 ); + regexp::FormalRegExpSymbol < int > l2 = regexp::FormalRegExpSymbol < int >( 2 ); - CPPUNIT_ASSERT( regexp == regexp2 ); + regexp::FormalRegExpConcatenation < int > con = regexp::FormalRegExpConcatenation < int >(l1, l2); - regexp::UnboundedRegExp < int > regexp3(std::move(regexp)); + regexp::FormalRegExpIteration < int > ite = regexp::FormalRegExpIteration < int >(l1); - CPPUNIT_ASSERT( regexp2 == regexp3 ); - } - { - regexp::FormalRegExpSymbol < int > l1 = regexp::FormalRegExpSymbol < int >( 1 ); - regexp::FormalRegExpSymbol < int > l2 = regexp::FormalRegExpSymbol < int >( 2 ); + regexp::FormalRegExpAlternation < int > alt = regexp::FormalRegExpAlternation < int >(con, ite); - regexp::FormalRegExpConcatenation < int > con = regexp::FormalRegExpConcatenation < int >(l1, l2); + regexp::FormalRegExp < int > regexp({1, 2, 3}, regexp::FormalRegExpStructure < int > ( alt ) ); - regexp::FormalRegExpIteration < int > ite = regexp::FormalRegExpIteration < int >(l1); + regexp::FormalRegExp < int > regexp2(regexp); - regexp::FormalRegExpAlternation < int > alt = regexp::FormalRegExpAlternation < int >(con, ite); + CHECK( regexp == regexp2 ); - regexp::FormalRegExp < int > regexp({1, 2, 3}, regexp::FormalRegExpStructure < int > ( alt ) ); + regexp::FormalRegExp < int > regexp3(std::move(regexp)); - regexp::FormalRegExp < int > regexp2(regexp); + CHECK( regexp2 == regexp3 ); + } + { + regexp::FormalRegExpSymbol < int > l1 = regexp::FormalRegExpSymbol < int >( 1 ); + regexp::FormalRegExpSymbol < int > l2 = regexp::FormalRegExpSymbol < int >( 2 ); - CPPUNIT_ASSERT( regexp == regexp2 ); + regexp::FormalRegExpConcatenation < int > con = regexp::FormalRegExpConcatenation < int >(l1, l2); - regexp::FormalRegExp < int > regexp3(std::move(regexp)); + regexp::FormalRegExpIteration < int > ite = regexp::FormalRegExpIteration < int >(l1); - CPPUNIT_ASSERT( regexp2 == regexp3 ); - } - { - regexp::FormalRegExpSymbol < int > l1 = regexp::FormalRegExpSymbol < int >( 1 ); - regexp::FormalRegExpSymbol < int > l2 = regexp::FormalRegExpSymbol < int >( 2 ); + regexp::FormalRegExpAlternation < int > alt = regexp::FormalRegExpAlternation < int >(con, ite); - regexp::FormalRegExpConcatenation < int > con = regexp::FormalRegExpConcatenation < int >(l1, l2); + regexp::FormalRegExp < int > regexp({1, 3}, regexp::FormalRegExpStructure < int > ( regexp::FormalRegExpEmpty < int > { } ) ); - regexp::FormalRegExpIteration < int > ite = regexp::FormalRegExpIteration < int >(l1); - - regexp::FormalRegExpAlternation < int > alt = regexp::FormalRegExpAlternation < int >(con, ite); - - regexp::FormalRegExp < int > regexp({1, 3}, regexp::FormalRegExpStructure < int > ( regexp::FormalRegExpEmpty < int > { } ) ); - - CPPUNIT_ASSERT_THROW( - regexp.setRegExp ( regexp::FormalRegExpStructure < int > ( alt ) ), - exception::CommonException - ); + CHECK_THROWS_AS ( regexp.setRegExp ( regexp::FormalRegExpStructure < int > ( alt ) ), exception::CommonException ); + } } -} -void RegExpTest::testXMLParser() { + SECTION ( "Xml parser" ) { + regexp::UnboundedRegExpSymbol < int > l1 = regexp::UnboundedRegExpSymbol < int >( 1 ); + regexp::UnboundedRegExpSymbol < int > l2 = regexp::UnboundedRegExpSymbol < int >( 2 ); - regexp::UnboundedRegExpSymbol < int > l1 = regexp::UnboundedRegExpSymbol < int >( 1 ); - regexp::UnboundedRegExpSymbol < int > l2 = regexp::UnboundedRegExpSymbol < int >( 2 ); + regexp::UnboundedRegExpConcatenation < int > con = regexp::UnboundedRegExpConcatenation < int >(); + con.appendElement(l1); + con.appendElement(l2); - regexp::UnboundedRegExpConcatenation < int > con = regexp::UnboundedRegExpConcatenation < int >(); - con.appendElement(l1); - con.appendElement(l2); + regexp::UnboundedRegExpIteration < int > ite = regexp::UnboundedRegExpIteration < int >(l1); - regexp::UnboundedRegExpIteration < int > ite = regexp::UnboundedRegExpIteration < int >(l1); + regexp::UnboundedRegExpAlternation < int > alt = regexp::UnboundedRegExpAlternation < int >(); + alt.appendElement(con); + alt.appendElement(ite); - regexp::UnboundedRegExpAlternation < int > alt = regexp::UnboundedRegExpAlternation < int >(); - alt.appendElement(con); - alt.appendElement(ite); + regexp::UnboundedRegExp < int > unboundedRegexp({1, 2, 3}, regexp::UnboundedRegExpStructure < int >(alt)); - regexp::UnboundedRegExp < int > unboundedRegexp({1, 2, 3}, regexp::UnboundedRegExpStructure < int >(alt)); + regexp::UnboundedRegExp < > regexp = core::normalize < regexp::UnboundedRegExp < int > >::eval ( std::move ( unboundedRegexp ) ); - regexp::UnboundedRegExp < > regexp = core::normalize < regexp::UnboundedRegExp < int > >::eval ( std::move ( unboundedRegexp ) ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(regexp); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(regexp); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + regexp::UnboundedRegExp < > regexp2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - regexp::UnboundedRegExp < > regexp2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + CHECK( regexp == regexp2 ); + } + { + std::string tmp = factory::XmlDataFactory::toString(regexp); + regexp::UnboundedRegExp < > regexp2 = factory::XmlDataFactory::fromString (tmp); - CPPUNIT_ASSERT( regexp == regexp2 ); + CHECK( regexp == regexp2 ); + } } - { - std::string tmp = factory::XmlDataFactory::toString(regexp); - regexp::UnboundedRegExp < > regexp2 = factory::XmlDataFactory::fromString (tmp); - CPPUNIT_ASSERT( regexp == regexp2 ); + SECTION ( "Order" ) { + { + regexp::UnboundedRegExpSymbol < int > s1( 1 ); + regexp::UnboundedRegExpEmpty < int > e1; + regexp::UnboundedRegExpEpsilon < int > e2; + regexp::UnboundedRegExpIteration < int > i1(s1); + regexp::UnboundedRegExpConcatenation < int > a1; + a1.appendElement(s1); + a1.appendElement(s1); + regexp::UnboundedRegExpAlternation < int > c1; + c1.appendElement(s1); + c1.appendElement(s1); + + regexp::UnboundedRegExp < int > alt1{regexp::UnboundedRegExpStructure < int >(a1)}; + regexp::UnboundedRegExp < int > con1{regexp::UnboundedRegExpStructure < int >(c1)}; + regexp::UnboundedRegExp < int > ite1{regexp::UnboundedRegExpStructure < int >(i1)}; + regexp::UnboundedRegExp < int > emp1{regexp::UnboundedRegExpStructure < int >(e1)}; + regexp::UnboundedRegExp < int > eps1{regexp::UnboundedRegExpStructure < int >(e2)}; + regexp::UnboundedRegExp < int > sym1{regexp::UnboundedRegExpStructure < int >(s1)}; + + CHECK_EXCLUSIVE_OR(alt1 < con1, con1 < alt1); + CHECK_EXCLUSIVE_OR(alt1 < ite1, ite1 < alt1); + CHECK_EXCLUSIVE_OR(alt1 < emp1, emp1 < alt1); + CHECK_EXCLUSIVE_OR(alt1 < eps1, eps1 < alt1); + CHECK_EXCLUSIVE_OR(alt1 < sym1, sym1 < alt1); + + CHECK_EXCLUSIVE_OR(con1 < ite1, ite1 < con1); + CHECK_EXCLUSIVE_OR(con1 < emp1, emp1 < con1); + CHECK_EXCLUSIVE_OR(con1 < eps1, eps1 < con1); + CHECK_EXCLUSIVE_OR(con1 < sym1, sym1 < con1); + + CHECK_EXCLUSIVE_OR(ite1 < emp1, emp1 < ite1); + CHECK_EXCLUSIVE_OR(ite1 < eps1, eps1 < ite1); + CHECK_EXCLUSIVE_OR(ite1 < sym1, sym1 < ite1); + + CHECK_EXCLUSIVE_OR(emp1 < eps1, eps1 < emp1); + CHECK_EXCLUSIVE_OR(emp1 < sym1, sym1 < emp1); + + CHECK_EXCLUSIVE_OR(eps1 < sym1, sym1 < eps1); + + CHECK_IMPLY( alt1 < con1 && con1 < ite1, alt1 < ite1 ); + CHECK_IMPLY( alt1 < con1 && con1 < emp1, alt1 < emp1 ); + CHECK_IMPLY( alt1 < con1 && con1 < eps1, alt1 < eps1 ); + CHECK_IMPLY( alt1 < con1 && con1 < sym1, alt1 < sym1 ); + + CHECK_IMPLY( alt1 < ite1 && ite1 < con1, alt1 < con1 ); + CHECK_IMPLY( alt1 < ite1 && ite1 < emp1, alt1 < emp1 ); + CHECK_IMPLY( alt1 < ite1 && ite1 < eps1, alt1 < eps1 ); + CHECK_IMPLY( alt1 < ite1 && ite1 < sym1, alt1 < sym1 ); + + CHECK_IMPLY( alt1 < emp1 && emp1 < con1, alt1 < con1 ); + CHECK_IMPLY( alt1 < emp1 && emp1 < ite1, alt1 < ite1 ); + CHECK_IMPLY( alt1 < emp1 && emp1 < eps1, alt1 < eps1 ); + CHECK_IMPLY( alt1 < emp1 && emp1 < sym1, alt1 < sym1 ); + + CHECK_IMPLY( alt1 < eps1 && eps1 < con1, alt1 < con1 ); + CHECK_IMPLY( alt1 < eps1 && eps1 < ite1, alt1 < ite1 ); + CHECK_IMPLY( alt1 < eps1 && eps1 < emp1, alt1 < emp1 ); + CHECK_IMPLY( alt1 < eps1 && eps1 < sym1, alt1 < sym1 ); + + CHECK_IMPLY( alt1 < sym1 && sym1 < con1, alt1 < con1 ); + CHECK_IMPLY( alt1 < sym1 && sym1 < ite1, alt1 < ite1 ); + CHECK_IMPLY( alt1 < sym1 && sym1 < emp1, alt1 < emp1 ); + CHECK_IMPLY( alt1 < sym1 && sym1 < eps1, alt1 < eps1 ); + + + + CHECK_IMPLY( con1 < alt1 && alt1 < ite1, con1 < ite1 ); + CHECK_IMPLY( con1 < alt1 && alt1 < emp1, con1 < emp1 ); + CHECK_IMPLY( con1 < alt1 && alt1 < eps1, con1 < eps1 ); + CHECK_IMPLY( con1 < alt1 && alt1 < sym1, con1 < sym1 ); + + CHECK_IMPLY( con1 < ite1 && ite1 < alt1, con1 < alt1 ); + CHECK_IMPLY( con1 < ite1 && ite1 < emp1, con1 < emp1 ); + CHECK_IMPLY( con1 < ite1 && ite1 < eps1, con1 < eps1 ); + CHECK_IMPLY( con1 < ite1 && ite1 < sym1, con1 < sym1 ); + + CHECK_IMPLY( con1 < emp1 && emp1 < alt1, con1 < alt1 ); + CHECK_IMPLY( con1 < emp1 && emp1 < ite1, con1 < ite1 ); + CHECK_IMPLY( con1 < emp1 && emp1 < eps1, con1 < eps1 ); + CHECK_IMPLY( con1 < emp1 && emp1 < sym1, con1 < sym1 ); + + CHECK_IMPLY( con1 < eps1 && eps1 < alt1, con1 < alt1 ); + CHECK_IMPLY( con1 < eps1 && eps1 < ite1, con1 < ite1 ); + CHECK_IMPLY( con1 < eps1 && eps1 < emp1, con1 < emp1 ); + CHECK_IMPLY( con1 < eps1 && eps1 < sym1, con1 < sym1 ); + + CHECK_IMPLY( con1 < sym1 && sym1 < alt1, con1 < alt1 ); + CHECK_IMPLY( con1 < sym1 && sym1 < ite1, con1 < ite1 ); + CHECK_IMPLY( con1 < sym1 && sym1 < emp1, con1 < emp1 ); + CHECK_IMPLY( con1 < sym1 && sym1 < eps1, con1 < eps1 ); + + + + CHECK_IMPLY( ite1 < alt1 && alt1 < con1, ite1 < con1 ); + CHECK_IMPLY( ite1 < alt1 && alt1 < emp1, ite1 < emp1 ); + CHECK_IMPLY( ite1 < alt1 && alt1 < eps1, ite1 < eps1 ); + CHECK_IMPLY( ite1 < alt1 && alt1 < sym1, ite1 < sym1 ); + + CHECK_IMPLY( ite1 < con1 && con1 < alt1, ite1 < alt1 ); + CHECK_IMPLY( ite1 < con1 && con1 < emp1, ite1 < emp1 ); + CHECK_IMPLY( ite1 < con1 && con1 < eps1, ite1 < eps1 ); + CHECK_IMPLY( ite1 < con1 && con1 < sym1, ite1 < sym1 ); + + CHECK_IMPLY( ite1 < emp1 && emp1 < alt1, ite1 < alt1 ); + CHECK_IMPLY( ite1 < emp1 && emp1 < con1, ite1 < con1 ); + CHECK_IMPLY( ite1 < emp1 && emp1 < eps1, ite1 < eps1 ); + CHECK_IMPLY( ite1 < emp1 && emp1 < sym1, ite1 < sym1 ); + + CHECK_IMPLY( ite1 < eps1 && eps1 < alt1, ite1 < alt1 ); + CHECK_IMPLY( ite1 < eps1 && eps1 < con1, ite1 < con1 ); + CHECK_IMPLY( ite1 < eps1 && eps1 < emp1, ite1 < emp1 ); + CHECK_IMPLY( ite1 < eps1 && eps1 < sym1, ite1 < sym1 ); + + CHECK_IMPLY( ite1 < sym1 && sym1 < alt1, ite1 < alt1 ); + CHECK_IMPLY( ite1 < sym1 && sym1 < con1, ite1 < con1 ); + CHECK_IMPLY( ite1 < sym1 && sym1 < emp1, ite1 < emp1 ); + CHECK_IMPLY( ite1 < sym1 && sym1 < eps1, ite1 < eps1 ); + + + + CHECK_IMPLY( emp1 < alt1 && alt1 < con1, emp1 < con1 ); + CHECK_IMPLY( emp1 < alt1 && alt1 < ite1, emp1 < ite1 ); + CHECK_IMPLY( emp1 < alt1 && alt1 < eps1, emp1 < eps1 ); + CHECK_IMPLY( emp1 < alt1 && alt1 < sym1, emp1 < sym1 ); + + CHECK_IMPLY( emp1 < con1 && con1 < alt1, emp1 < alt1 ); + CHECK_IMPLY( emp1 < con1 && con1 < ite1, emp1 < ite1 ); + CHECK_IMPLY( emp1 < con1 && con1 < eps1, emp1 < eps1 ); + CHECK_IMPLY( emp1 < con1 && con1 < sym1, emp1 < sym1 ); + + CHECK_IMPLY( emp1 < ite1 && ite1 < alt1, emp1 < alt1 ); + CHECK_IMPLY( emp1 < ite1 && ite1 < con1, emp1 < con1 ); + CHECK_IMPLY( emp1 < ite1 && ite1 < eps1, emp1 < eps1 ); + CHECK_IMPLY( emp1 < ite1 && ite1 < sym1, emp1 < sym1 ); + + CHECK_IMPLY( emp1 < eps1 && eps1 < alt1, emp1 < alt1 ); + CHECK_IMPLY( emp1 < eps1 && eps1 < con1, emp1 < con1 ); + CHECK_IMPLY( emp1 < eps1 && eps1 < ite1, emp1 < ite1 ); + CHECK_IMPLY( emp1 < eps1 && eps1 < sym1, emp1 < sym1 ); + + CHECK_IMPLY( emp1 < sym1 && sym1 < alt1, emp1 < alt1 ); + CHECK_IMPLY( emp1 < sym1 && sym1 < con1, emp1 < con1 ); + CHECK_IMPLY( emp1 < sym1 && sym1 < ite1, emp1 < ite1 ); + CHECK_IMPLY( emp1 < sym1 && sym1 < eps1, emp1 < eps1 ); + + + + CHECK_IMPLY( eps1 < alt1 && alt1 < con1, eps1 < con1 ); + CHECK_IMPLY( eps1 < alt1 && alt1 < ite1, eps1 < ite1 ); + CHECK_IMPLY( eps1 < alt1 && alt1 < emp1, eps1 < emp1 ); + CHECK_IMPLY( eps1 < alt1 && alt1 < sym1, eps1 < sym1 ); + + CHECK_IMPLY( eps1 < con1 && con1 < alt1, eps1 < alt1 ); + CHECK_IMPLY( eps1 < con1 && con1 < ite1, eps1 < ite1 ); + CHECK_IMPLY( eps1 < con1 && con1 < emp1, eps1 < emp1 ); + CHECK_IMPLY( eps1 < con1 && con1 < sym1, eps1 < sym1 ); + + CHECK_IMPLY( eps1 < ite1 && ite1 < alt1, eps1 < alt1 ); + CHECK_IMPLY( eps1 < ite1 && ite1 < con1, eps1 < con1 ); + CHECK_IMPLY( eps1 < ite1 && ite1 < emp1, eps1 < emp1 ); + CHECK_IMPLY( eps1 < ite1 && ite1 < sym1, eps1 < sym1 ); + + CHECK_IMPLY( eps1 < emp1 && emp1 < alt1, eps1 < alt1 ); + CHECK_IMPLY( eps1 < emp1 && emp1 < con1, eps1 < con1 ); + CHECK_IMPLY( eps1 < emp1 && emp1 < ite1, eps1 < ite1 ); + CHECK_IMPLY( eps1 < emp1 && emp1 < sym1, eps1 < sym1 ); + + CHECK_IMPLY( eps1 < sym1 && sym1 < alt1, eps1 < alt1 ); + CHECK_IMPLY( eps1 < sym1 && sym1 < con1, eps1 < con1 ); + CHECK_IMPLY( eps1 < sym1 && sym1 < ite1, eps1 < ite1 ); + CHECK_IMPLY( eps1 < sym1 && sym1 < emp1, eps1 < emp1 ); + + + + CHECK_IMPLY( sym1 < alt1 && alt1 < con1, sym1 < con1 ); + CHECK_IMPLY( sym1 < alt1 && alt1 < ite1, sym1 < ite1 ); + CHECK_IMPLY( sym1 < alt1 && alt1 < emp1, sym1 < emp1 ); + CHECK_IMPLY( sym1 < alt1 && alt1 < eps1, sym1 < eps1 ); + + CHECK_IMPLY( sym1 < con1 && con1 < alt1, sym1 < alt1 ); + CHECK_IMPLY( sym1 < con1 && con1 < ite1, sym1 < ite1 ); + CHECK_IMPLY( sym1 < con1 && con1 < emp1, sym1 < emp1 ); + CHECK_IMPLY( sym1 < con1 && con1 < eps1, sym1 < eps1 ); + + CHECK_IMPLY( sym1 < ite1 && ite1 < alt1, sym1 < alt1 ); + CHECK_IMPLY( sym1 < ite1 && ite1 < con1, sym1 < con1 ); + CHECK_IMPLY( sym1 < ite1 && ite1 < emp1, sym1 < emp1 ); + CHECK_IMPLY( sym1 < ite1 && ite1 < eps1, sym1 < eps1 ); + + CHECK_IMPLY( sym1 < emp1 && emp1 < alt1, sym1 < alt1 ); + CHECK_IMPLY( sym1 < emp1 && emp1 < con1, sym1 < con1 ); + CHECK_IMPLY( sym1 < emp1 && emp1 < ite1, sym1 < ite1 ); + CHECK_IMPLY( sym1 < emp1 && emp1 < eps1, sym1 < eps1 ); + + CHECK_IMPLY( sym1 < eps1 && eps1 < alt1, sym1 < alt1 ); + CHECK_IMPLY( sym1 < eps1 && eps1 < con1, sym1 < con1 ); + CHECK_IMPLY( sym1 < eps1 && eps1 < ite1, sym1 < ite1 ); + CHECK_IMPLY( sym1 < eps1 && eps1 < emp1, sym1 < emp1 ); + } + { + regexp::UnboundedRegExpSymbol < int > s1( 1 ); + regexp::UnboundedRegExpSymbol < int > s2( 2 ); + regexp::UnboundedRegExpSymbol < int > s3( 3 ); + + regexp::UnboundedRegExpEmpty < int > e1; + regexp::UnboundedRegExpEpsilon < int > e2; + + regexp::UnboundedRegExpIteration < int > i1(s1); + regexp::UnboundedRegExpIteration < int > i2(s2); + regexp::UnboundedRegExpIteration < int > i3(s3); + + regexp::UnboundedRegExpAlternation < int > a1; + a1.appendElement(s1); + a1.appendElement(s1); + regexp::UnboundedRegExpAlternation < int > a2; + a2.appendElement(s1); + a2.appendElement(s2); + regexp::UnboundedRegExpAlternation < int > a3; + a3.appendElement(s1); + a3.appendElement(s3); + regexp::UnboundedRegExpAlternation < int > a4; + a4.appendElement(s2); + a4.appendElement(s1); + regexp::UnboundedRegExpAlternation < int > a5; + a5.appendElement(s2); + a5.appendElement(s2); + regexp::UnboundedRegExpAlternation < int > a6; + a6.appendElement(s2); + a6.appendElement(s3); + regexp::UnboundedRegExpAlternation < int > a7; + a7.appendElement(s3); + a7.appendElement(s1); + regexp::UnboundedRegExpAlternation < int > a8; + a8.appendElement(s3); + a8.appendElement(s2); + regexp::UnboundedRegExpAlternation < int > a9; + a9.appendElement(s3); + a9.appendElement(s3); + + regexp::UnboundedRegExpConcatenation < int > c1; + c1.appendElement(s1); + c1.appendElement(s1); + regexp::UnboundedRegExpConcatenation < int > c2; + c2.appendElement(s1); + c2.appendElement(s2); + regexp::UnboundedRegExpConcatenation < int > c3; + c3.appendElement(s1); + c3.appendElement(s3); + regexp::UnboundedRegExpConcatenation < int > c4; + c4.appendElement(s2); + c4.appendElement(s1); + regexp::UnboundedRegExpConcatenation < int > c5; + c5.appendElement(s2); + c5.appendElement(s2); + regexp::UnboundedRegExpConcatenation < int > c6; + c6.appendElement(s2); + c6.appendElement(s3); + regexp::UnboundedRegExpConcatenation < int > c7; + c7.appendElement(s3); + c7.appendElement(s1); + regexp::UnboundedRegExpConcatenation < int > c8; + c8.appendElement(s3); + c8.appendElement(s2); + regexp::UnboundedRegExpConcatenation < int > c9; + c9.appendElement(s3); + c9.appendElement(s3); + + regexp::UnboundedRegExp < int > alt1{regexp::UnboundedRegExpStructure < int >(a1)}; + regexp::UnboundedRegExp < int > alt2{regexp::UnboundedRegExpStructure < int >(a2)}; + regexp::UnboundedRegExp < int > alt3{regexp::UnboundedRegExpStructure < int >(a3)}; + regexp::UnboundedRegExp < int > alt4{regexp::UnboundedRegExpStructure < int >(a4)}; + regexp::UnboundedRegExp < int > alt5{regexp::UnboundedRegExpStructure < int >(a5)}; + regexp::UnboundedRegExp < int > alt6{regexp::UnboundedRegExpStructure < int >(a6)}; + regexp::UnboundedRegExp < int > alt7{regexp::UnboundedRegExpStructure < int >(a7)}; + regexp::UnboundedRegExp < int > alt8{regexp::UnboundedRegExpStructure < int >(a8)}; + regexp::UnboundedRegExp < int > alt9{regexp::UnboundedRegExpStructure < int >(a9)}; + + regexp::UnboundedRegExp < int > con1{regexp::UnboundedRegExpStructure < int >(c1)}; + regexp::UnboundedRegExp < int > con2{regexp::UnboundedRegExpStructure < int >(c2)}; + regexp::UnboundedRegExp < int > con3{regexp::UnboundedRegExpStructure < int >(c3)}; + regexp::UnboundedRegExp < int > con4{regexp::UnboundedRegExpStructure < int >(c4)}; + regexp::UnboundedRegExp < int > con5{regexp::UnboundedRegExpStructure < int >(c5)}; + regexp::UnboundedRegExp < int > con6{regexp::UnboundedRegExpStructure < int >(c6)}; + regexp::UnboundedRegExp < int > con7{regexp::UnboundedRegExpStructure < int >(c7)}; + regexp::UnboundedRegExp < int > con8{regexp::UnboundedRegExpStructure < int >(c8)}; + regexp::UnboundedRegExp < int > con9{regexp::UnboundedRegExpStructure < int >(c9)}; + + regexp::UnboundedRegExp < int > ite1{regexp::UnboundedRegExpStructure < int >(i1)}; + regexp::UnboundedRegExp < int > ite2{regexp::UnboundedRegExpStructure < int >(i2)}; + regexp::UnboundedRegExp < int > ite3{regexp::UnboundedRegExpStructure < int >(i3)}; + + regexp::UnboundedRegExp < int > emp1{regexp::UnboundedRegExpStructure < int >(e1)}; + regexp::UnboundedRegExp < int > eps1{regexp::UnboundedRegExpStructure < int >(e2)}; + + regexp::UnboundedRegExp < int > sym1{regexp::UnboundedRegExpStructure < int >(s1)}; + regexp::UnboundedRegExp < int > sym2{regexp::UnboundedRegExpStructure < int >(s2)}; + regexp::UnboundedRegExp < int > sym3{regexp::UnboundedRegExpStructure < int >(s3)}; + + + + CHECK(alt1 == alt1); + CHECK(alt1 < alt2); + CHECK(alt1 < alt3); + CHECK(alt1 < alt4); + CHECK(alt1 < alt5); + CHECK(alt1 < alt6); + CHECK(alt1 < alt7); + CHECK(alt1 < alt8); + CHECK(alt1 < alt9); + + CHECK(alt2 > alt1); + CHECK(alt2 == alt2); + CHECK(alt2 < alt3); + CHECK(alt2 < alt4); + CHECK(alt2 < alt5); + CHECK(alt2 < alt6); + CHECK(alt2 < alt7); + CHECK(alt2 < alt8); + CHECK(alt2 < alt9); + + CHECK(alt3 > alt1); + CHECK(alt3 > alt2); + CHECK(alt3 == alt3); + CHECK(alt3 < alt4); + CHECK(alt3 < alt5); + CHECK(alt3 < alt6); + CHECK(alt3 < alt7); + CHECK(alt3 < alt8); + CHECK(alt3 < alt9); + + CHECK(alt4 > alt1); + CHECK(alt4 > alt2); + CHECK(alt4 > alt3); + CHECK(alt4 == alt4); + CHECK(alt4 < alt5); + CHECK(alt4 < alt6); + CHECK(alt4 < alt7); + CHECK(alt4 < alt8); + CHECK(alt4 < alt9); + + CHECK(alt5 > alt1); + CHECK(alt5 > alt2); + CHECK(alt5 > alt3); + CHECK(alt5 > alt4); + CHECK(alt5 == alt5); + CHECK(alt5 < alt6); + CHECK(alt5 < alt7); + CHECK(alt5 < alt8); + CHECK(alt5 < alt9); + + CHECK(alt6 > alt1); + CHECK(alt6 > alt2); + CHECK(alt6 > alt3); + CHECK(alt6 > alt4); + CHECK(alt6 > alt5); + CHECK(alt6 == alt6); + CHECK(alt6 < alt7); + CHECK(alt6 < alt8); + CHECK(alt6 < alt9); + + CHECK(alt7 > alt1); + CHECK(alt7 > alt2); + CHECK(alt7 > alt3); + CHECK(alt7 > alt4); + CHECK(alt7 > alt5); + CHECK(alt7 > alt6); + CHECK(alt7 == alt7); + CHECK(alt7 < alt8); + CHECK(alt7 < alt9); + + CHECK(alt8 > alt1); + CHECK(alt8 > alt2); + CHECK(alt8 > alt3); + CHECK(alt8 > alt4); + CHECK(alt8 > alt5); + CHECK(alt8 > alt6); + CHECK(alt8 > alt7); + CHECK(alt8 == alt8); + CHECK(alt8 < alt9); + + CHECK(alt9 > alt1); + CHECK(alt9 > alt2); + CHECK(alt9 > alt3); + CHECK(alt9 > alt4); + CHECK(alt9 > alt5); + CHECK(alt9 > alt6); + CHECK(alt9 > alt7); + CHECK(alt9 > alt8); + CHECK(alt9 == alt9); + + + + CHECK(con1 == con1); + CHECK(con1 < con2); + CHECK(con1 < con3); + CHECK(con1 < con4); + CHECK(con1 < con5); + CHECK(con1 < con6); + CHECK(con1 < con7); + CHECK(con1 < con8); + CHECK(con1 < con9); + + CHECK(con2 > con1); + CHECK(con2 == con2); + CHECK(con2 < con3); + CHECK(con2 < con4); + CHECK(con2 < con5); + CHECK(con2 < con6); + CHECK(con2 < con7); + CHECK(con2 < con8); + CHECK(con2 < con9); + + CHECK(con3 > con1); + CHECK(con3 > con2); + CHECK(con3 == con3); + CHECK(con3 < con4); + CHECK(con3 < con5); + CHECK(con3 < con6); + CHECK(con3 < con7); + CHECK(con3 < con8); + CHECK(con3 < con9); + + CHECK(con4 > con1); + CHECK(con4 > con2); + CHECK(con4 > con3); + CHECK(con4 == con4); + CHECK(con4 < con5); + CHECK(con4 < con6); + CHECK(con4 < con7); + CHECK(con4 < con8); + CHECK(con4 < con9); + + CHECK(con5 > con1); + CHECK(con5 > con2); + CHECK(con5 > con3); + CHECK(con5 > con4); + CHECK(con5 == con5); + CHECK(con5 < con6); + CHECK(con5 < con7); + CHECK(con5 < con8); + CHECK(con5 < con9); + + CHECK(con6 > con1); + CHECK(con6 > con2); + CHECK(con6 > con3); + CHECK(con6 > con4); + CHECK(con6 > con5); + CHECK(con6 == con6); + CHECK(con6 < con7); + CHECK(con6 < con8); + CHECK(con6 < con9); + + CHECK(con7 > con1); + CHECK(con7 > con2); + CHECK(con7 > con3); + CHECK(con7 > con4); + CHECK(con7 > con5); + CHECK(con7 > con6); + CHECK(con7 == con7); + CHECK(con7 < con8); + CHECK(con7 < con9); + + CHECK(con8 > con1); + CHECK(con8 > con2); + CHECK(con8 > con3); + CHECK(con8 > con4); + CHECK(con8 > con5); + CHECK(con8 > con6); + CHECK(con8 > con7); + CHECK(con8 == con8); + CHECK(con8 < con9); + + CHECK(con9 > con1); + CHECK(con9 > con2); + CHECK(con9 > con3); + CHECK(con9 > con4); + CHECK(con9 > con5); + CHECK(con9 > con6); + CHECK(con9 > con7); + CHECK(con9 > con8); + CHECK(con9 == con9); + + + CHECK(ite1 == ite1); + CHECK(ite1 < ite2); + CHECK(ite1 < ite3); + + CHECK(ite2 > ite1); + CHECK(ite2 == ite2); + CHECK(ite2 < ite3); + + CHECK(ite3 > ite1); + CHECK(ite3 > ite2); + CHECK(ite3 == ite3); + + CHECK(emp1 == emp1); + + CHECK(eps1 == eps1); + + CHECK(sym1 == sym1); + CHECK(sym1 < sym2); + CHECK(sym1 < sym3); + + CHECK(sym2 > sym1); + CHECK(sym2 == sym2); + CHECK(sym2 < sym3); + + CHECK(sym3 > sym1); + CHECK(sym3 > sym2); + CHECK(sym3 == sym3); + } } } - -void RegExpTest::testOrder() { - regexp::UnboundedRegExpSymbol < int > s1( 1 ); - regexp::UnboundedRegExpEmpty < int > e1; - regexp::UnboundedRegExpEpsilon < int > e2; - regexp::UnboundedRegExpIteration < int > i1(s1); - regexp::UnboundedRegExpConcatenation < int > a1; - a1.appendElement(s1); - a1.appendElement(s1); - regexp::UnboundedRegExpAlternation < int > c1; - c1.appendElement(s1); - c1.appendElement(s1); - - regexp::UnboundedRegExp < int > alt1{regexp::UnboundedRegExpStructure < int >(a1)}; - regexp::UnboundedRegExp < int > con1{regexp::UnboundedRegExpStructure < int >(c1)}; - regexp::UnboundedRegExp < int > ite1{regexp::UnboundedRegExpStructure < int >(i1)}; - regexp::UnboundedRegExp < int > emp1{regexp::UnboundedRegExpStructure < int >(e1)}; - regexp::UnboundedRegExp < int > eps1{regexp::UnboundedRegExpStructure < int >(e2)}; - regexp::UnboundedRegExp < int > sym1{regexp::UnboundedRegExpStructure < int >(s1)}; - - CPPUNIT_EXCLUSIVE_OR(alt1 < con1, con1 < alt1); - CPPUNIT_EXCLUSIVE_OR(alt1 < ite1, ite1 < alt1); - CPPUNIT_EXCLUSIVE_OR(alt1 < emp1, emp1 < alt1); - CPPUNIT_EXCLUSIVE_OR(alt1 < eps1, eps1 < alt1); - CPPUNIT_EXCLUSIVE_OR(alt1 < sym1, sym1 < alt1); - - CPPUNIT_EXCLUSIVE_OR(con1 < ite1, ite1 < con1); - CPPUNIT_EXCLUSIVE_OR(con1 < emp1, emp1 < con1); - CPPUNIT_EXCLUSIVE_OR(con1 < eps1, eps1 < con1); - CPPUNIT_EXCLUSIVE_OR(con1 < sym1, sym1 < con1); - - CPPUNIT_EXCLUSIVE_OR(ite1 < emp1, emp1 < ite1); - CPPUNIT_EXCLUSIVE_OR(ite1 < eps1, eps1 < ite1); - CPPUNIT_EXCLUSIVE_OR(ite1 < sym1, sym1 < ite1); - - CPPUNIT_EXCLUSIVE_OR(emp1 < eps1, eps1 < emp1); - CPPUNIT_EXCLUSIVE_OR(emp1 < sym1, sym1 < emp1); - - CPPUNIT_EXCLUSIVE_OR(eps1 < sym1, sym1 < eps1); - - CPPUNIT_IMPLY( alt1 < con1 && con1 < ite1, alt1 < ite1 ); - CPPUNIT_IMPLY( alt1 < con1 && con1 < emp1, alt1 < emp1 ); - CPPUNIT_IMPLY( alt1 < con1 && con1 < eps1, alt1 < eps1 ); - CPPUNIT_IMPLY( alt1 < con1 && con1 < sym1, alt1 < sym1 ); - - CPPUNIT_IMPLY( alt1 < ite1 && ite1 < con1, alt1 < con1 ); - CPPUNIT_IMPLY( alt1 < ite1 && ite1 < emp1, alt1 < emp1 ); - CPPUNIT_IMPLY( alt1 < ite1 && ite1 < eps1, alt1 < eps1 ); - CPPUNIT_IMPLY( alt1 < ite1 && ite1 < sym1, alt1 < sym1 ); - - CPPUNIT_IMPLY( alt1 < emp1 && emp1 < con1, alt1 < con1 ); - CPPUNIT_IMPLY( alt1 < emp1 && emp1 < ite1, alt1 < ite1 ); - CPPUNIT_IMPLY( alt1 < emp1 && emp1 < eps1, alt1 < eps1 ); - CPPUNIT_IMPLY( alt1 < emp1 && emp1 < sym1, alt1 < sym1 ); - - CPPUNIT_IMPLY( alt1 < eps1 && eps1 < con1, alt1 < con1 ); - CPPUNIT_IMPLY( alt1 < eps1 && eps1 < ite1, alt1 < ite1 ); - CPPUNIT_IMPLY( alt1 < eps1 && eps1 < emp1, alt1 < emp1 ); - CPPUNIT_IMPLY( alt1 < eps1 && eps1 < sym1, alt1 < sym1 ); - - CPPUNIT_IMPLY( alt1 < sym1 && sym1 < con1, alt1 < con1 ); - CPPUNIT_IMPLY( alt1 < sym1 && sym1 < ite1, alt1 < ite1 ); - CPPUNIT_IMPLY( alt1 < sym1 && sym1 < emp1, alt1 < emp1 ); - CPPUNIT_IMPLY( alt1 < sym1 && sym1 < eps1, alt1 < eps1 ); - - - - CPPUNIT_IMPLY( con1 < alt1 && alt1 < ite1, con1 < ite1 ); - CPPUNIT_IMPLY( con1 < alt1 && alt1 < emp1, con1 < emp1 ); - CPPUNIT_IMPLY( con1 < alt1 && alt1 < eps1, con1 < eps1 ); - CPPUNIT_IMPLY( con1 < alt1 && alt1 < sym1, con1 < sym1 ); - - CPPUNIT_IMPLY( con1 < ite1 && ite1 < alt1, con1 < alt1 ); - CPPUNIT_IMPLY( con1 < ite1 && ite1 < emp1, con1 < emp1 ); - CPPUNIT_IMPLY( con1 < ite1 && ite1 < eps1, con1 < eps1 ); - CPPUNIT_IMPLY( con1 < ite1 && ite1 < sym1, con1 < sym1 ); - - CPPUNIT_IMPLY( con1 < emp1 && emp1 < alt1, con1 < alt1 ); - CPPUNIT_IMPLY( con1 < emp1 && emp1 < ite1, con1 < ite1 ); - CPPUNIT_IMPLY( con1 < emp1 && emp1 < eps1, con1 < eps1 ); - CPPUNIT_IMPLY( con1 < emp1 && emp1 < sym1, con1 < sym1 ); - - CPPUNIT_IMPLY( con1 < eps1 && eps1 < alt1, con1 < alt1 ); - CPPUNIT_IMPLY( con1 < eps1 && eps1 < ite1, con1 < ite1 ); - CPPUNIT_IMPLY( con1 < eps1 && eps1 < emp1, con1 < emp1 ); - CPPUNIT_IMPLY( con1 < eps1 && eps1 < sym1, con1 < sym1 ); - - CPPUNIT_IMPLY( con1 < sym1 && sym1 < alt1, con1 < alt1 ); - CPPUNIT_IMPLY( con1 < sym1 && sym1 < ite1, con1 < ite1 ); - CPPUNIT_IMPLY( con1 < sym1 && sym1 < emp1, con1 < emp1 ); - CPPUNIT_IMPLY( con1 < sym1 && sym1 < eps1, con1 < eps1 ); - - - - CPPUNIT_IMPLY( ite1 < alt1 && alt1 < con1, ite1 < con1 ); - CPPUNIT_IMPLY( ite1 < alt1 && alt1 < emp1, ite1 < emp1 ); - CPPUNIT_IMPLY( ite1 < alt1 && alt1 < eps1, ite1 < eps1 ); - CPPUNIT_IMPLY( ite1 < alt1 && alt1 < sym1, ite1 < sym1 ); - - CPPUNIT_IMPLY( ite1 < con1 && con1 < alt1, ite1 < alt1 ); - CPPUNIT_IMPLY( ite1 < con1 && con1 < emp1, ite1 < emp1 ); - CPPUNIT_IMPLY( ite1 < con1 && con1 < eps1, ite1 < eps1 ); - CPPUNIT_IMPLY( ite1 < con1 && con1 < sym1, ite1 < sym1 ); - - CPPUNIT_IMPLY( ite1 < emp1 && emp1 < alt1, ite1 < alt1 ); - CPPUNIT_IMPLY( ite1 < emp1 && emp1 < con1, ite1 < con1 ); - CPPUNIT_IMPLY( ite1 < emp1 && emp1 < eps1, ite1 < eps1 ); - CPPUNIT_IMPLY( ite1 < emp1 && emp1 < sym1, ite1 < sym1 ); - - CPPUNIT_IMPLY( ite1 < eps1 && eps1 < alt1, ite1 < alt1 ); - CPPUNIT_IMPLY( ite1 < eps1 && eps1 < con1, ite1 < con1 ); - CPPUNIT_IMPLY( ite1 < eps1 && eps1 < emp1, ite1 < emp1 ); - CPPUNIT_IMPLY( ite1 < eps1 && eps1 < sym1, ite1 < sym1 ); - - CPPUNIT_IMPLY( ite1 < sym1 && sym1 < alt1, ite1 < alt1 ); - CPPUNIT_IMPLY( ite1 < sym1 && sym1 < con1, ite1 < con1 ); - CPPUNIT_IMPLY( ite1 < sym1 && sym1 < emp1, ite1 < emp1 ); - CPPUNIT_IMPLY( ite1 < sym1 && sym1 < eps1, ite1 < eps1 ); - - - - CPPUNIT_IMPLY( emp1 < alt1 && alt1 < con1, emp1 < con1 ); - CPPUNIT_IMPLY( emp1 < alt1 && alt1 < ite1, emp1 < ite1 ); - CPPUNIT_IMPLY( emp1 < alt1 && alt1 < eps1, emp1 < eps1 ); - CPPUNIT_IMPLY( emp1 < alt1 && alt1 < sym1, emp1 < sym1 ); - - CPPUNIT_IMPLY( emp1 < con1 && con1 < alt1, emp1 < alt1 ); - CPPUNIT_IMPLY( emp1 < con1 && con1 < ite1, emp1 < ite1 ); - CPPUNIT_IMPLY( emp1 < con1 && con1 < eps1, emp1 < eps1 ); - CPPUNIT_IMPLY( emp1 < con1 && con1 < sym1, emp1 < sym1 ); - - CPPUNIT_IMPLY( emp1 < ite1 && ite1 < alt1, emp1 < alt1 ); - CPPUNIT_IMPLY( emp1 < ite1 && ite1 < con1, emp1 < con1 ); - CPPUNIT_IMPLY( emp1 < ite1 && ite1 < eps1, emp1 < eps1 ); - CPPUNIT_IMPLY( emp1 < ite1 && ite1 < sym1, emp1 < sym1 ); - - CPPUNIT_IMPLY( emp1 < eps1 && eps1 < alt1, emp1 < alt1 ); - CPPUNIT_IMPLY( emp1 < eps1 && eps1 < con1, emp1 < con1 ); - CPPUNIT_IMPLY( emp1 < eps1 && eps1 < ite1, emp1 < ite1 ); - CPPUNIT_IMPLY( emp1 < eps1 && eps1 < sym1, emp1 < sym1 ); - - CPPUNIT_IMPLY( emp1 < sym1 && sym1 < alt1, emp1 < alt1 ); - CPPUNIT_IMPLY( emp1 < sym1 && sym1 < con1, emp1 < con1 ); - CPPUNIT_IMPLY( emp1 < sym1 && sym1 < ite1, emp1 < ite1 ); - CPPUNIT_IMPLY( emp1 < sym1 && sym1 < eps1, emp1 < eps1 ); - - - - CPPUNIT_IMPLY( eps1 < alt1 && alt1 < con1, eps1 < con1 ); - CPPUNIT_IMPLY( eps1 < alt1 && alt1 < ite1, eps1 < ite1 ); - CPPUNIT_IMPLY( eps1 < alt1 && alt1 < emp1, eps1 < emp1 ); - CPPUNIT_IMPLY( eps1 < alt1 && alt1 < sym1, eps1 < sym1 ); - - CPPUNIT_IMPLY( eps1 < con1 && con1 < alt1, eps1 < alt1 ); - CPPUNIT_IMPLY( eps1 < con1 && con1 < ite1, eps1 < ite1 ); - CPPUNIT_IMPLY( eps1 < con1 && con1 < emp1, eps1 < emp1 ); - CPPUNIT_IMPLY( eps1 < con1 && con1 < sym1, eps1 < sym1 ); - - CPPUNIT_IMPLY( eps1 < ite1 && ite1 < alt1, eps1 < alt1 ); - CPPUNIT_IMPLY( eps1 < ite1 && ite1 < con1, eps1 < con1 ); - CPPUNIT_IMPLY( eps1 < ite1 && ite1 < emp1, eps1 < emp1 ); - CPPUNIT_IMPLY( eps1 < ite1 && ite1 < sym1, eps1 < sym1 ); - - CPPUNIT_IMPLY( eps1 < emp1 && emp1 < alt1, eps1 < alt1 ); - CPPUNIT_IMPLY( eps1 < emp1 && emp1 < con1, eps1 < con1 ); - CPPUNIT_IMPLY( eps1 < emp1 && emp1 < ite1, eps1 < ite1 ); - CPPUNIT_IMPLY( eps1 < emp1 && emp1 < sym1, eps1 < sym1 ); - - CPPUNIT_IMPLY( eps1 < sym1 && sym1 < alt1, eps1 < alt1 ); - CPPUNIT_IMPLY( eps1 < sym1 && sym1 < con1, eps1 < con1 ); - CPPUNIT_IMPLY( eps1 < sym1 && sym1 < ite1, eps1 < ite1 ); - CPPUNIT_IMPLY( eps1 < sym1 && sym1 < emp1, eps1 < emp1 ); - - - - CPPUNIT_IMPLY( sym1 < alt1 && alt1 < con1, sym1 < con1 ); - CPPUNIT_IMPLY( sym1 < alt1 && alt1 < ite1, sym1 < ite1 ); - CPPUNIT_IMPLY( sym1 < alt1 && alt1 < emp1, sym1 < emp1 ); - CPPUNIT_IMPLY( sym1 < alt1 && alt1 < eps1, sym1 < eps1 ); - - CPPUNIT_IMPLY( sym1 < con1 && con1 < alt1, sym1 < alt1 ); - CPPUNIT_IMPLY( sym1 < con1 && con1 < ite1, sym1 < ite1 ); - CPPUNIT_IMPLY( sym1 < con1 && con1 < emp1, sym1 < emp1 ); - CPPUNIT_IMPLY( sym1 < con1 && con1 < eps1, sym1 < eps1 ); - - CPPUNIT_IMPLY( sym1 < ite1 && ite1 < alt1, sym1 < alt1 ); - CPPUNIT_IMPLY( sym1 < ite1 && ite1 < con1, sym1 < con1 ); - CPPUNIT_IMPLY( sym1 < ite1 && ite1 < emp1, sym1 < emp1 ); - CPPUNIT_IMPLY( sym1 < ite1 && ite1 < eps1, sym1 < eps1 ); - - CPPUNIT_IMPLY( sym1 < emp1 && emp1 < alt1, sym1 < alt1 ); - CPPUNIT_IMPLY( sym1 < emp1 && emp1 < con1, sym1 < con1 ); - CPPUNIT_IMPLY( sym1 < emp1 && emp1 < ite1, sym1 < ite1 ); - CPPUNIT_IMPLY( sym1 < emp1 && emp1 < eps1, sym1 < eps1 ); - - CPPUNIT_IMPLY( sym1 < eps1 && eps1 < alt1, sym1 < alt1 ); - CPPUNIT_IMPLY( sym1 < eps1 && eps1 < con1, sym1 < con1 ); - CPPUNIT_IMPLY( sym1 < eps1 && eps1 < ite1, sym1 < ite1 ); - CPPUNIT_IMPLY( sym1 < eps1 && eps1 < emp1, sym1 < emp1 ); -} - -void RegExpTest::testOrder2() { - regexp::UnboundedRegExpSymbol < int > s1( 1 ); - regexp::UnboundedRegExpSymbol < int > s2( 2 ); - regexp::UnboundedRegExpSymbol < int > s3( 3 ); - - regexp::UnboundedRegExpEmpty < int > e1; - regexp::UnboundedRegExpEpsilon < int > e2; - - regexp::UnboundedRegExpIteration < int > i1(s1); - regexp::UnboundedRegExpIteration < int > i2(s2); - regexp::UnboundedRegExpIteration < int > i3(s3); - - regexp::UnboundedRegExpAlternation < int > a1; - a1.appendElement(s1); - a1.appendElement(s1); - regexp::UnboundedRegExpAlternation < int > a2; - a2.appendElement(s1); - a2.appendElement(s2); - regexp::UnboundedRegExpAlternation < int > a3; - a3.appendElement(s1); - a3.appendElement(s3); - regexp::UnboundedRegExpAlternation < int > a4; - a4.appendElement(s2); - a4.appendElement(s1); - regexp::UnboundedRegExpAlternation < int > a5; - a5.appendElement(s2); - a5.appendElement(s2); - regexp::UnboundedRegExpAlternation < int > a6; - a6.appendElement(s2); - a6.appendElement(s3); - regexp::UnboundedRegExpAlternation < int > a7; - a7.appendElement(s3); - a7.appendElement(s1); - regexp::UnboundedRegExpAlternation < int > a8; - a8.appendElement(s3); - a8.appendElement(s2); - regexp::UnboundedRegExpAlternation < int > a9; - a9.appendElement(s3); - a9.appendElement(s3); - - regexp::UnboundedRegExpConcatenation < int > c1; - c1.appendElement(s1); - c1.appendElement(s1); - regexp::UnboundedRegExpConcatenation < int > c2; - c2.appendElement(s1); - c2.appendElement(s2); - regexp::UnboundedRegExpConcatenation < int > c3; - c3.appendElement(s1); - c3.appendElement(s3); - regexp::UnboundedRegExpConcatenation < int > c4; - c4.appendElement(s2); - c4.appendElement(s1); - regexp::UnboundedRegExpConcatenation < int > c5; - c5.appendElement(s2); - c5.appendElement(s2); - regexp::UnboundedRegExpConcatenation < int > c6; - c6.appendElement(s2); - c6.appendElement(s3); - regexp::UnboundedRegExpConcatenation < int > c7; - c7.appendElement(s3); - c7.appendElement(s1); - regexp::UnboundedRegExpConcatenation < int > c8; - c8.appendElement(s3); - c8.appendElement(s2); - regexp::UnboundedRegExpConcatenation < int > c9; - c9.appendElement(s3); - c9.appendElement(s3); - - regexp::UnboundedRegExp < int > alt1{regexp::UnboundedRegExpStructure < int >(a1)}; - regexp::UnboundedRegExp < int > alt2{regexp::UnboundedRegExpStructure < int >(a2)}; - regexp::UnboundedRegExp < int > alt3{regexp::UnboundedRegExpStructure < int >(a3)}; - regexp::UnboundedRegExp < int > alt4{regexp::UnboundedRegExpStructure < int >(a4)}; - regexp::UnboundedRegExp < int > alt5{regexp::UnboundedRegExpStructure < int >(a5)}; - regexp::UnboundedRegExp < int > alt6{regexp::UnboundedRegExpStructure < int >(a6)}; - regexp::UnboundedRegExp < int > alt7{regexp::UnboundedRegExpStructure < int >(a7)}; - regexp::UnboundedRegExp < int > alt8{regexp::UnboundedRegExpStructure < int >(a8)}; - regexp::UnboundedRegExp < int > alt9{regexp::UnboundedRegExpStructure < int >(a9)}; - - regexp::UnboundedRegExp < int > con1{regexp::UnboundedRegExpStructure < int >(c1)}; - regexp::UnboundedRegExp < int > con2{regexp::UnboundedRegExpStructure < int >(c2)}; - regexp::UnboundedRegExp < int > con3{regexp::UnboundedRegExpStructure < int >(c3)}; - regexp::UnboundedRegExp < int > con4{regexp::UnboundedRegExpStructure < int >(c4)}; - regexp::UnboundedRegExp < int > con5{regexp::UnboundedRegExpStructure < int >(c5)}; - regexp::UnboundedRegExp < int > con6{regexp::UnboundedRegExpStructure < int >(c6)}; - regexp::UnboundedRegExp < int > con7{regexp::UnboundedRegExpStructure < int >(c7)}; - regexp::UnboundedRegExp < int > con8{regexp::UnboundedRegExpStructure < int >(c8)}; - regexp::UnboundedRegExp < int > con9{regexp::UnboundedRegExpStructure < int >(c9)}; - - regexp::UnboundedRegExp < int > ite1{regexp::UnboundedRegExpStructure < int >(i1)}; - regexp::UnboundedRegExp < int > ite2{regexp::UnboundedRegExpStructure < int >(i2)}; - regexp::UnboundedRegExp < int > ite3{regexp::UnboundedRegExpStructure < int >(i3)}; - - regexp::UnboundedRegExp < int > emp1{regexp::UnboundedRegExpStructure < int >(e1)}; - regexp::UnboundedRegExp < int > eps1{regexp::UnboundedRegExpStructure < int >(e2)}; - - regexp::UnboundedRegExp < int > sym1{regexp::UnboundedRegExpStructure < int >(s1)}; - regexp::UnboundedRegExp < int > sym2{regexp::UnboundedRegExpStructure < int >(s2)}; - regexp::UnboundedRegExp < int > sym3{regexp::UnboundedRegExpStructure < int >(s3)}; - - - - CPPUNIT_ASSERT(alt1 == alt1); - CPPUNIT_ASSERT(alt1 < alt2); - CPPUNIT_ASSERT(alt1 < alt3); - CPPUNIT_ASSERT(alt1 < alt4); - CPPUNIT_ASSERT(alt1 < alt5); - CPPUNIT_ASSERT(alt1 < alt6); - CPPUNIT_ASSERT(alt1 < alt7); - CPPUNIT_ASSERT(alt1 < alt8); - CPPUNIT_ASSERT(alt1 < alt9); - - CPPUNIT_ASSERT(alt2 > alt1); - CPPUNIT_ASSERT(alt2 == alt2); - CPPUNIT_ASSERT(alt2 < alt3); - CPPUNIT_ASSERT(alt2 < alt4); - CPPUNIT_ASSERT(alt2 < alt5); - CPPUNIT_ASSERT(alt2 < alt6); - CPPUNIT_ASSERT(alt2 < alt7); - CPPUNIT_ASSERT(alt2 < alt8); - CPPUNIT_ASSERT(alt2 < alt9); - - CPPUNIT_ASSERT(alt3 > alt1); - CPPUNIT_ASSERT(alt3 > alt2); - CPPUNIT_ASSERT(alt3 == alt3); - CPPUNIT_ASSERT(alt3 < alt4); - CPPUNIT_ASSERT(alt3 < alt5); - CPPUNIT_ASSERT(alt3 < alt6); - CPPUNIT_ASSERT(alt3 < alt7); - CPPUNIT_ASSERT(alt3 < alt8); - CPPUNIT_ASSERT(alt3 < alt9); - - CPPUNIT_ASSERT(alt4 > alt1); - CPPUNIT_ASSERT(alt4 > alt2); - CPPUNIT_ASSERT(alt4 > alt3); - CPPUNIT_ASSERT(alt4 == alt4); - CPPUNIT_ASSERT(alt4 < alt5); - CPPUNIT_ASSERT(alt4 < alt6); - CPPUNIT_ASSERT(alt4 < alt7); - CPPUNIT_ASSERT(alt4 < alt8); - CPPUNIT_ASSERT(alt4 < alt9); - - CPPUNIT_ASSERT(alt5 > alt1); - CPPUNIT_ASSERT(alt5 > alt2); - CPPUNIT_ASSERT(alt5 > alt3); - CPPUNIT_ASSERT(alt5 > alt4); - CPPUNIT_ASSERT(alt5 == alt5); - CPPUNIT_ASSERT(alt5 < alt6); - CPPUNIT_ASSERT(alt5 < alt7); - CPPUNIT_ASSERT(alt5 < alt8); - CPPUNIT_ASSERT(alt5 < alt9); - - CPPUNIT_ASSERT(alt6 > alt1); - CPPUNIT_ASSERT(alt6 > alt2); - CPPUNIT_ASSERT(alt6 > alt3); - CPPUNIT_ASSERT(alt6 > alt4); - CPPUNIT_ASSERT(alt6 > alt5); - CPPUNIT_ASSERT(alt6 == alt6); - CPPUNIT_ASSERT(alt6 < alt7); - CPPUNIT_ASSERT(alt6 < alt8); - CPPUNIT_ASSERT(alt6 < alt9); - - CPPUNIT_ASSERT(alt7 > alt1); - CPPUNIT_ASSERT(alt7 > alt2); - CPPUNIT_ASSERT(alt7 > alt3); - CPPUNIT_ASSERT(alt7 > alt4); - CPPUNIT_ASSERT(alt7 > alt5); - CPPUNIT_ASSERT(alt7 > alt6); - CPPUNIT_ASSERT(alt7 == alt7); - CPPUNIT_ASSERT(alt7 < alt8); - CPPUNIT_ASSERT(alt7 < alt9); - - CPPUNIT_ASSERT(alt8 > alt1); - CPPUNIT_ASSERT(alt8 > alt2); - CPPUNIT_ASSERT(alt8 > alt3); - CPPUNIT_ASSERT(alt8 > alt4); - CPPUNIT_ASSERT(alt8 > alt5); - CPPUNIT_ASSERT(alt8 > alt6); - CPPUNIT_ASSERT(alt8 > alt7); - CPPUNIT_ASSERT(alt8 == alt8); - CPPUNIT_ASSERT(alt8 < alt9); - - CPPUNIT_ASSERT(alt9 > alt1); - CPPUNIT_ASSERT(alt9 > alt2); - CPPUNIT_ASSERT(alt9 > alt3); - CPPUNIT_ASSERT(alt9 > alt4); - CPPUNIT_ASSERT(alt9 > alt5); - CPPUNIT_ASSERT(alt9 > alt6); - CPPUNIT_ASSERT(alt9 > alt7); - CPPUNIT_ASSERT(alt9 > alt8); - CPPUNIT_ASSERT(alt9 == alt9); - - - - CPPUNIT_ASSERT(con1 == con1); - CPPUNIT_ASSERT(con1 < con2); - CPPUNIT_ASSERT(con1 < con3); - CPPUNIT_ASSERT(con1 < con4); - CPPUNIT_ASSERT(con1 < con5); - CPPUNIT_ASSERT(con1 < con6); - CPPUNIT_ASSERT(con1 < con7); - CPPUNIT_ASSERT(con1 < con8); - CPPUNIT_ASSERT(con1 < con9); - - CPPUNIT_ASSERT(con2 > con1); - CPPUNIT_ASSERT(con2 == con2); - CPPUNIT_ASSERT(con2 < con3); - CPPUNIT_ASSERT(con2 < con4); - CPPUNIT_ASSERT(con2 < con5); - CPPUNIT_ASSERT(con2 < con6); - CPPUNIT_ASSERT(con2 < con7); - CPPUNIT_ASSERT(con2 < con8); - CPPUNIT_ASSERT(con2 < con9); - - CPPUNIT_ASSERT(con3 > con1); - CPPUNIT_ASSERT(con3 > con2); - CPPUNIT_ASSERT(con3 == con3); - CPPUNIT_ASSERT(con3 < con4); - CPPUNIT_ASSERT(con3 < con5); - CPPUNIT_ASSERT(con3 < con6); - CPPUNIT_ASSERT(con3 < con7); - CPPUNIT_ASSERT(con3 < con8); - CPPUNIT_ASSERT(con3 < con9); - - CPPUNIT_ASSERT(con4 > con1); - CPPUNIT_ASSERT(con4 > con2); - CPPUNIT_ASSERT(con4 > con3); - CPPUNIT_ASSERT(con4 == con4); - CPPUNIT_ASSERT(con4 < con5); - CPPUNIT_ASSERT(con4 < con6); - CPPUNIT_ASSERT(con4 < con7); - CPPUNIT_ASSERT(con4 < con8); - CPPUNIT_ASSERT(con4 < con9); - - CPPUNIT_ASSERT(con5 > con1); - CPPUNIT_ASSERT(con5 > con2); - CPPUNIT_ASSERT(con5 > con3); - CPPUNIT_ASSERT(con5 > con4); - CPPUNIT_ASSERT(con5 == con5); - CPPUNIT_ASSERT(con5 < con6); - CPPUNIT_ASSERT(con5 < con7); - CPPUNIT_ASSERT(con5 < con8); - CPPUNIT_ASSERT(con5 < con9); - - CPPUNIT_ASSERT(con6 > con1); - CPPUNIT_ASSERT(con6 > con2); - CPPUNIT_ASSERT(con6 > con3); - CPPUNIT_ASSERT(con6 > con4); - CPPUNIT_ASSERT(con6 > con5); - CPPUNIT_ASSERT(con6 == con6); - CPPUNIT_ASSERT(con6 < con7); - CPPUNIT_ASSERT(con6 < con8); - CPPUNIT_ASSERT(con6 < con9); - - CPPUNIT_ASSERT(con7 > con1); - CPPUNIT_ASSERT(con7 > con2); - CPPUNIT_ASSERT(con7 > con3); - CPPUNIT_ASSERT(con7 > con4); - CPPUNIT_ASSERT(con7 > con5); - CPPUNIT_ASSERT(con7 > con6); - CPPUNIT_ASSERT(con7 == con7); - CPPUNIT_ASSERT(con7 < con8); - CPPUNIT_ASSERT(con7 < con9); - - CPPUNIT_ASSERT(con8 > con1); - CPPUNIT_ASSERT(con8 > con2); - CPPUNIT_ASSERT(con8 > con3); - CPPUNIT_ASSERT(con8 > con4); - CPPUNIT_ASSERT(con8 > con5); - CPPUNIT_ASSERT(con8 > con6); - CPPUNIT_ASSERT(con8 > con7); - CPPUNIT_ASSERT(con8 == con8); - CPPUNIT_ASSERT(con8 < con9); - - CPPUNIT_ASSERT(con9 > con1); - CPPUNIT_ASSERT(con9 > con2); - CPPUNIT_ASSERT(con9 > con3); - CPPUNIT_ASSERT(con9 > con4); - CPPUNIT_ASSERT(con9 > con5); - CPPUNIT_ASSERT(con9 > con6); - CPPUNIT_ASSERT(con9 > con7); - CPPUNIT_ASSERT(con9 > con8); - CPPUNIT_ASSERT(con9 == con9); - - - CPPUNIT_ASSERT(ite1 == ite1); - CPPUNIT_ASSERT(ite1 < ite2); - CPPUNIT_ASSERT(ite1 < ite3); - - CPPUNIT_ASSERT(ite2 > ite1); - CPPUNIT_ASSERT(ite2 == ite2); - CPPUNIT_ASSERT(ite2 < ite3); - - CPPUNIT_ASSERT(ite3 > ite1); - CPPUNIT_ASSERT(ite3 > ite2); - CPPUNIT_ASSERT(ite3 == ite3); - - - - CPPUNIT_ASSERT(emp1 == emp1); - - - - CPPUNIT_ASSERT(eps1 == eps1); - - - - CPPUNIT_ASSERT(sym1 == sym1); - CPPUNIT_ASSERT(sym1 < sym2); - CPPUNIT_ASSERT(sym1 < sym3); - - CPPUNIT_ASSERT(sym2 > sym1); - CPPUNIT_ASSERT(sym2 == sym2); - CPPUNIT_ASSERT(sym2 < sym3); - - CPPUNIT_ASSERT(sym3 > sym1); - CPPUNIT_ASSERT(sym3 > sym2); - CPPUNIT_ASSERT(sym3 == sym3); -} - diff --git a/alib2data/test-src/regexp/RegExpTest.h b/alib2data/test-src/regexp/RegExpTest.h deleted file mode 100644 index 03761f4dc3486c2fe9b0c57f34748f46da4ae0f8..0000000000000000000000000000000000000000 --- a/alib2data/test-src/regexp/RegExpTest.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef REG_EXP_TEST_H_ -#define REG_EXP_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class RegExpTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( RegExpTest ); - CPPUNIT_TEST( testCopyConstruct ); - CPPUNIT_TEST( testXMLParser ); - CPPUNIT_TEST( testOrder ); - CPPUNIT_TEST( testOrder2 ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testCopyConstruct(); - void testXMLParser(); - void testOrder(); - void testOrder2(); -}; - -#endif // REG_EXP_TEST_H_ diff --git a/alib2data/test-src/rte/RTETest.cpp b/alib2data/test-src/rte/RTETest.cpp index 3b6f39eb315943ec5a350a65a27a423d5c2ccf75..fb5ebdcb98958f0b8f45c6d5308313f6d9b35230 100644 --- a/alib2data/test-src/rte/RTETest.cpp +++ b/alib2data/test-src/rte/RTETest.cpp @@ -1,11 +1,8 @@ -#include "RTETest.h" -#include <alib/list> +#include <catch2/catch.hpp> #include "sax/SaxComposeInterface.h" #include "sax/SaxParseInterface.h" -// #include "rte/unbounded/UnboundedRTE.h" -// #include "rte/unbounded/UnboundedRTEElements.h" #include "rte/formal/FormalRTE.h" #include "rte/formal/FormalRTEElements.h" @@ -15,53 +12,82 @@ #include "factory/XmlDataFactory.hpp" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( RTETest, "rte" ); -CPPUNIT_TEST_SUITE_REGISTRATION ( RTETest ); +TEST_CASE ( "RTE", "[unit][data][rte]" ) { + SECTION ( "Copy constructor" ) { + { + /* + * rte::UnboundedRTE rte; + * rte.setAlphabet({DefaultSymbolType("1"), DefaultSymbolType("2"), DefaultSymbolType("3")}); + * rte::UnboundedRTESymbol l1 = rte::UnboundedRTESymbol("1"); + * rte::UnboundedRTESymbol l2 = rte::UnboundedRTESymbol("2"); + * + * rte::UnboundedRTEConcatenation con = rte::UnboundedRTEConcatenation(); + * con.appendElement(l1); + * con.appendElement(l2); + * + * rte::UnboundedRTEIteration ite = rte::UnboundedRTEIteration(l1); + * + * rte::UnboundedRTEAlternation alt = rte::UnboundedRTEAlternation(); + * alt.appendElement(con); + * alt.appendElement(ite); + * + * rte.setRTE(alt); + * + * rte::UnboundedRTE rte2(rte); + * + * CHECK( rte == rte2 ); + * + * rte::UnboundedRTE rte3(std::move(rte)); + * + * CHECK( rte2 == rte3 ); + */ + } + { + const common::ranked_symbol < > symb_a2 ( DefaultSymbolType ( 'a' ), DefaultRankType ( 2 ) ); + const common::ranked_symbol < > symb_b0 ( DefaultSymbolType ( 'b' ), DefaultRankType ( 0 ) ); + const common::ranked_symbol < > symb_c0 ( DefaultSymbolType ( 'c' ), DefaultRankType ( 0 ) ); + const common::ranked_symbol < > symb_y0 ( DefaultSymbolType ( 'y' ), DefaultRankType ( 0 ) ); + const common::ranked_symbol < > symb_z0 ( DefaultSymbolType ( 'z' ), DefaultRankType ( 0 ) ); -void RTETest::setUp ( ) { -} + rte::FormalRTE < > rte; + rte.setAlphabetSymbols ( { symb_a2, symb_b0, symb_c0 } ); + rte.setConstantSymbols ( { symb_y0, symb_z0 } ); -void RTETest::tearDown ( ) { -} + rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > b = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_b0, { } ); + rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > c = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_c0, { } ); + rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > y = rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_y0 ); + rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > z = rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_z0 ); + + rte::FormalRTEAlternation < DefaultSymbolType, unsigned > alt = rte::FormalRTEAlternation < DefaultSymbolType, unsigned > ( b, c ); + + ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, unsigned > > children; + children.push_back ( std::move ( y ) ); + children.push_back ( std::move ( z ) ); + rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > a = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_a2, std::move ( children ) ); + + rte::FormalRTEIteration < DefaultSymbolType, unsigned > iter = rte::FormalRTEIteration < DefaultSymbolType, unsigned > ( a, rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_y0 ) ); + rte::FormalRTESubstitution < DefaultSymbolType, unsigned > subst = rte::FormalRTESubstitution < DefaultSymbolType, unsigned > ( iter, alt, rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_z0 ) ); + rte.setRTE ( rte::FormalRTEStructure < DefaultSymbolType, unsigned > ( subst ) ); + + rte::FormalRTE < > frte2 ( rte ); + CHECK ( rte == frte2 ); -void RTETest::testCopyConstruct ( ) { - { - /* - * rte::UnboundedRTE rte; - * rte.setAlphabet({DefaultSymbolType("1"), DefaultSymbolType("2"), DefaultSymbolType("3")}); - * rte::UnboundedRTESymbol l1 = rte::UnboundedRTESymbol("1"); - * rte::UnboundedRTESymbol l2 = rte::UnboundedRTESymbol("2"); - * - * rte::UnboundedRTEConcatenation con = rte::UnboundedRTEConcatenation(); - * con.appendElement(l1); - * con.appendElement(l2); - * - * rte::UnboundedRTEIteration ite = rte::UnboundedRTEIteration(l1); - * - * rte::UnboundedRTEAlternation alt = rte::UnboundedRTEAlternation(); - * alt.appendElement(con); - * alt.appendElement(ite); - * - * rte.setRTE(alt); - * - * rte::UnboundedRTE rte2(rte); - * - * CPPUNIT_ASSERT( rte == rte2 ); - * - * rte::UnboundedRTE rte3(std::move(rte)); - * - * CPPUNIT_ASSERT( rte2 == rte3 ); - */ + rte::FormalRTE < > frte3 ( std::move ( rte ) ); + CHECK ( frte2 == frte3 ); + } } - { + + SECTION ( "Xml Parser" ) { const common::ranked_symbol < > symb_a2 ( DefaultSymbolType ( 'a' ), DefaultRankType ( 2 ) ); const common::ranked_symbol < > symb_b0 ( DefaultSymbolType ( 'b' ), DefaultRankType ( 0 ) ); const common::ranked_symbol < > symb_c0 ( DefaultSymbolType ( 'c' ), DefaultRankType ( 0 ) ); + const common::ranked_symbol < > symb_d1 ( DefaultSymbolType ( 'd' ), DefaultRankType ( 1 ) ); const common::ranked_symbol < > symb_y0 ( DefaultSymbolType ( 'y' ), DefaultRankType ( 0 ) ); const common::ranked_symbol < > symb_z0 ( DefaultSymbolType ( 'z' ), DefaultRankType ( 0 ) ); rte::FormalRTE < > rte; - rte.setAlphabetSymbols ( { symb_a2, symb_b0, symb_c0 } ); + + rte.setAlphabetSymbols ( { symb_a2, symb_b0, symb_c0, symb_d1 } ); rte.setConstantSymbols ( { symb_y0, symb_z0 } ); rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > b = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_b0, { } ); @@ -71,593 +97,558 @@ void RTETest::testCopyConstruct ( ) { rte::FormalRTEAlternation < DefaultSymbolType, unsigned > alt = rte::FormalRTEAlternation < DefaultSymbolType, unsigned > ( b, c ); - ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, unsigned > > children; - children.push_back ( std::move ( y ) ); - children.push_back ( std::move ( z ) ); - rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > a = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_a2, std::move ( children ) ); + ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, unsigned > > children_a; + children_a.push_back ( std::move ( y ) ); + children_a.push_back ( std::move ( z ) ); + rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > a = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_a2, std::move ( children_a ) ); + + ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, unsigned > > children_d; + children_d.push_back ( std::move ( a ) ); + rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > d = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_d1, children_d ); - rte::FormalRTEIteration < DefaultSymbolType, unsigned > iter = rte::FormalRTEIteration < DefaultSymbolType, unsigned > ( a, rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_y0 ) ); + rte::FormalRTEIteration < DefaultSymbolType, unsigned > iter = rte::FormalRTEIteration < DefaultSymbolType, unsigned > ( d, rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_y0 ) ); rte::FormalRTESubstitution < DefaultSymbolType, unsigned > subst = rte::FormalRTESubstitution < DefaultSymbolType, unsigned > ( iter, alt, rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_z0 ) ); rte.setRTE ( rte::FormalRTEStructure < DefaultSymbolType, unsigned > ( subst ) ); - rte::FormalRTE < > frte2 ( rte ); - CPPUNIT_ASSERT ( rte == frte2 ); - - rte::FormalRTE < > frte3 ( std::move ( rte ) ); - CPPUNIT_ASSERT ( frte2 == frte3 ); - } -} - -void RTETest::testXMLParser ( ) { - const common::ranked_symbol < > symb_a2 ( DefaultSymbolType ( 'a' ), DefaultRankType ( 2 ) ); - const common::ranked_symbol < > symb_b0 ( DefaultSymbolType ( 'b' ), DefaultRankType ( 0 ) ); - const common::ranked_symbol < > symb_c0 ( DefaultSymbolType ( 'c' ), DefaultRankType ( 0 ) ); - const common::ranked_symbol < > symb_d1 ( DefaultSymbolType ( 'd' ), DefaultRankType ( 1 ) ); - const common::ranked_symbol < > symb_y0 ( DefaultSymbolType ( 'y' ), DefaultRankType ( 0 ) ); - const common::ranked_symbol < > symb_z0 ( DefaultSymbolType ( 'z' ), DefaultRankType ( 0 ) ); - - rte::FormalRTE < > rte; - - rte.setAlphabetSymbols ( { symb_a2, symb_b0, symb_c0, symb_d1 } ); - rte.setConstantSymbols ( { symb_y0, symb_z0 } ); - - rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > b = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_b0, { } ); - rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > c = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_c0, { } ); - rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > y = rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_y0 ); - rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > z = rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_z0 ); - - rte::FormalRTEAlternation < DefaultSymbolType, unsigned > alt = rte::FormalRTEAlternation < DefaultSymbolType, unsigned > ( b, c ); - - ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, unsigned > > children_a; - children_a.push_back ( std::move ( y ) ); - children_a.push_back ( std::move ( z ) ); - rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > a = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_a2, std::move ( children_a ) ); + factory::XmlDataFactory::toStdout ( rte ); + { + ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( rte ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::ptr_vector < rte::FormalRTEElement < DefaultSymbolType, unsigned > > children_d; - children_d.push_back ( std::move ( a ) ); - rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > d = rte::FormalRTESymbolAlphabet < DefaultSymbolType, unsigned > ( symb_d1, children_d ); + ext::deque < sax::Token > tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + rte::FormalRTE < > rte2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); - rte::FormalRTEIteration < DefaultSymbolType, unsigned > iter = rte::FormalRTEIteration < DefaultSymbolType, unsigned > ( d, rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_y0 ) ); - rte::FormalRTESubstitution < DefaultSymbolType, unsigned > subst = rte::FormalRTESubstitution < DefaultSymbolType, unsigned > ( iter, alt, rte::FormalRTESymbolSubst < DefaultSymbolType, unsigned > ( symb_z0 ) ); - rte.setRTE ( rte::FormalRTEStructure < DefaultSymbolType, unsigned > ( subst ) ); + CHECK ( rte == rte2 ); + } + { + std::string tmp = factory::XmlDataFactory::toString ( rte ); + rte::FormalRTE < > rte2 = factory::XmlDataFactory::fromString ( tmp ); - factory::XmlDataFactory::toStdout ( rte ); - { - ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( rte ); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - - ext::deque < sax::Token > tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - rte::FormalRTE < > rte2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); - - CPPUNIT_ASSERT ( rte == rte2 ); + CHECK ( rte == rte2 ); + } } - { - std::string tmp = factory::XmlDataFactory::toString ( rte ); - rte::FormalRTE < > rte2 = factory::XmlDataFactory::fromString ( tmp ); - CPPUNIT_ASSERT ( rte == rte2 ); + SECTION ( "Order" ) { + { + /* + * rte::UnboundedRTESymbol s1("1"); + * rte::UnboundedRTEEmpty e1; + * rte::UnboundedRTEEpsilon e2; + * rte::UnboundedRTEIteration i1(s1); + * rte::UnboundedRTEConcatenation a1; + * a1.appendElement(s1); + * a1.appendElement(s1); + * rte::UnboundedRTEAlternation c1; + * c1.appendElement(s1); + * c1.appendElement(s1); + * + * rte::UnboundedRTE alt1(a1); + * rte::UnboundedRTE con1(c1); + * rte::UnboundedRTE ite1(i1); + * rte::UnboundedRTE emp1(e1); + * rte::UnboundedRTE eps1(e2); + * rte::UnboundedRTE sym1(s1); + * + * CPPUNIT_EXCLUSIVE_OR(alt1 < con1, con1 < alt1); + * CPPUNIT_EXCLUSIVE_OR(alt1 < ite1, ite1 < alt1); + * CPPUNIT_EXCLUSIVE_OR(alt1 < emp1, emp1 < alt1); + * CPPUNIT_EXCLUSIVE_OR(alt1 < eps1, eps1 < alt1); + * CPPUNIT_EXCLUSIVE_OR(alt1 < sym1, sym1 < alt1); + * + * CPPUNIT_EXCLUSIVE_OR(con1 < ite1, ite1 < con1); + * CPPUNIT_EXCLUSIVE_OR(con1 < emp1, emp1 < con1); + * CPPUNIT_EXCLUSIVE_OR(con1 < eps1, eps1 < con1); + * CPPUNIT_EXCLUSIVE_OR(con1 < sym1, sym1 < con1); + * + * CPPUNIT_EXCLUSIVE_OR(ite1 < emp1, emp1 < ite1); + * CPPUNIT_EXCLUSIVE_OR(ite1 < eps1, eps1 < ite1); + * CPPUNIT_EXCLUSIVE_OR(ite1 < sym1, sym1 < ite1); + * + * CPPUNIT_EXCLUSIVE_OR(emp1 < eps1, eps1 < emp1); + * CPPUNIT_EXCLUSIVE_OR(emp1 < sym1, sym1 < emp1); + * + * CPPUNIT_EXCLUSIVE_OR(eps1 < sym1, sym1 < eps1); + * + * CPPUNIT_IMPLY( alt1 < con1 && con1 < ite1, alt1 < ite1 ); + * CPPUNIT_IMPLY( alt1 < con1 && con1 < emp1, alt1 < emp1 ); + * CPPUNIT_IMPLY( alt1 < con1 && con1 < eps1, alt1 < eps1 ); + * CPPUNIT_IMPLY( alt1 < con1 && con1 < sym1, alt1 < sym1 ); + * + * CPPUNIT_IMPLY( alt1 < ite1 && ite1 < con1, alt1 < con1 ); + * CPPUNIT_IMPLY( alt1 < ite1 && ite1 < emp1, alt1 < emp1 ); + * CPPUNIT_IMPLY( alt1 < ite1 && ite1 < eps1, alt1 < eps1 ); + * CPPUNIT_IMPLY( alt1 < ite1 && ite1 < sym1, alt1 < sym1 ); + * + * CPPUNIT_IMPLY( alt1 < emp1 && emp1 < con1, alt1 < con1 ); + * CPPUNIT_IMPLY( alt1 < emp1 && emp1 < ite1, alt1 < ite1 ); + * CPPUNIT_IMPLY( alt1 < emp1 && emp1 < eps1, alt1 < eps1 ); + * CPPUNIT_IMPLY( alt1 < emp1 && emp1 < sym1, alt1 < sym1 ); + * + * CPPUNIT_IMPLY( alt1 < eps1 && eps1 < con1, alt1 < con1 ); + * CPPUNIT_IMPLY( alt1 < eps1 && eps1 < ite1, alt1 < ite1 ); + * CPPUNIT_IMPLY( alt1 < eps1 && eps1 < emp1, alt1 < emp1 ); + * CPPUNIT_IMPLY( alt1 < eps1 && eps1 < sym1, alt1 < sym1 ); + * + * CPPUNIT_IMPLY( alt1 < sym1 && sym1 < con1, alt1 < con1 ); + * CPPUNIT_IMPLY( alt1 < sym1 && sym1 < ite1, alt1 < ite1 ); + * CPPUNIT_IMPLY( alt1 < sym1 && sym1 < emp1, alt1 < emp1 ); + * CPPUNIT_IMPLY( alt1 < sym1 && sym1 < eps1, alt1 < eps1 ); + * + * + * + * CPPUNIT_IMPLY( con1 < alt1 && alt1 < ite1, con1 < ite1 ); + * CPPUNIT_IMPLY( con1 < alt1 && alt1 < emp1, con1 < emp1 ); + * CPPUNIT_IMPLY( con1 < alt1 && alt1 < eps1, con1 < eps1 ); + * CPPUNIT_IMPLY( con1 < alt1 && alt1 < sym1, con1 < sym1 ); + * + * CPPUNIT_IMPLY( con1 < ite1 && ite1 < alt1, con1 < alt1 ); + * CPPUNIT_IMPLY( con1 < ite1 && ite1 < emp1, con1 < emp1 ); + * CPPUNIT_IMPLY( con1 < ite1 && ite1 < eps1, con1 < eps1 ); + * CPPUNIT_IMPLY( con1 < ite1 && ite1 < sym1, con1 < sym1 ); + * + * CPPUNIT_IMPLY( con1 < emp1 && emp1 < alt1, con1 < alt1 ); + * CPPUNIT_IMPLY( con1 < emp1 && emp1 < ite1, con1 < ite1 ); + * CPPUNIT_IMPLY( con1 < emp1 && emp1 < eps1, con1 < eps1 ); + * CPPUNIT_IMPLY( con1 < emp1 && emp1 < sym1, con1 < sym1 ); + * + * CPPUNIT_IMPLY( con1 < eps1 && eps1 < alt1, con1 < alt1 ); + * CPPUNIT_IMPLY( con1 < eps1 && eps1 < ite1, con1 < ite1 ); + * CPPUNIT_IMPLY( con1 < eps1 && eps1 < emp1, con1 < emp1 ); + * CPPUNIT_IMPLY( con1 < eps1 && eps1 < sym1, con1 < sym1 ); + * + * CPPUNIT_IMPLY( con1 < sym1 && sym1 < alt1, con1 < alt1 ); + * CPPUNIT_IMPLY( con1 < sym1 && sym1 < ite1, con1 < ite1 ); + * CPPUNIT_IMPLY( con1 < sym1 && sym1 < emp1, con1 < emp1 ); + * CPPUNIT_IMPLY( con1 < sym1 && sym1 < eps1, con1 < eps1 ); + * + * + * + * CPPUNIT_IMPLY( ite1 < alt1 && alt1 < con1, ite1 < con1 ); + * CPPUNIT_IMPLY( ite1 < alt1 && alt1 < emp1, ite1 < emp1 ); + * CPPUNIT_IMPLY( ite1 < alt1 && alt1 < eps1, ite1 < eps1 ); + * CPPUNIT_IMPLY( ite1 < alt1 && alt1 < sym1, ite1 < sym1 ); + * + * CPPUNIT_IMPLY( ite1 < con1 && con1 < alt1, ite1 < alt1 ); + * CPPUNIT_IMPLY( ite1 < con1 && con1 < emp1, ite1 < emp1 ); + * CPPUNIT_IMPLY( ite1 < con1 && con1 < eps1, ite1 < eps1 ); + * CPPUNIT_IMPLY( ite1 < con1 && con1 < sym1, ite1 < sym1 ); + * + * CPPUNIT_IMPLY( ite1 < emp1 && emp1 < alt1, ite1 < alt1 ); + * CPPUNIT_IMPLY( ite1 < emp1 && emp1 < con1, ite1 < con1 ); + * CPPUNIT_IMPLY( ite1 < emp1 && emp1 < eps1, ite1 < eps1 ); + * CPPUNIT_IMPLY( ite1 < emp1 && emp1 < sym1, ite1 < sym1 ); + * + * CPPUNIT_IMPLY( ite1 < eps1 && eps1 < alt1, ite1 < alt1 ); + * CPPUNIT_IMPLY( ite1 < eps1 && eps1 < con1, ite1 < con1 ); + * CPPUNIT_IMPLY( ite1 < eps1 && eps1 < emp1, ite1 < emp1 ); + * CPPUNIT_IMPLY( ite1 < eps1 && eps1 < sym1, ite1 < sym1 ); + * + * CPPUNIT_IMPLY( ite1 < sym1 && sym1 < alt1, ite1 < alt1 ); + * CPPUNIT_IMPLY( ite1 < sym1 && sym1 < con1, ite1 < con1 ); + * CPPUNIT_IMPLY( ite1 < sym1 && sym1 < emp1, ite1 < emp1 ); + * CPPUNIT_IMPLY( ite1 < sym1 && sym1 < eps1, ite1 < eps1 ); + * + * + * + * CPPUNIT_IMPLY( emp1 < alt1 && alt1 < con1, emp1 < con1 ); + * CPPUNIT_IMPLY( emp1 < alt1 && alt1 < ite1, emp1 < ite1 ); + * CPPUNIT_IMPLY( emp1 < alt1 && alt1 < eps1, emp1 < eps1 ); + * CPPUNIT_IMPLY( emp1 < alt1 && alt1 < sym1, emp1 < sym1 ); + * + * CPPUNIT_IMPLY( emp1 < con1 && con1 < alt1, emp1 < alt1 ); + * CPPUNIT_IMPLY( emp1 < con1 && con1 < ite1, emp1 < ite1 ); + * CPPUNIT_IMPLY( emp1 < con1 && con1 < eps1, emp1 < eps1 ); + * CPPUNIT_IMPLY( emp1 < con1 && con1 < sym1, emp1 < sym1 ); + * + * CPPUNIT_IMPLY( emp1 < ite1 && ite1 < alt1, emp1 < alt1 ); + * CPPUNIT_IMPLY( emp1 < ite1 && ite1 < con1, emp1 < con1 ); + * CPPUNIT_IMPLY( emp1 < ite1 && ite1 < eps1, emp1 < eps1 ); + * CPPUNIT_IMPLY( emp1 < ite1 && ite1 < sym1, emp1 < sym1 ); + * + * CPPUNIT_IMPLY( emp1 < eps1 && eps1 < alt1, emp1 < alt1 ); + * CPPUNIT_IMPLY( emp1 < eps1 && eps1 < con1, emp1 < con1 ); + * CPPUNIT_IMPLY( emp1 < eps1 && eps1 < ite1, emp1 < ite1 ); + * CPPUNIT_IMPLY( emp1 < eps1 && eps1 < sym1, emp1 < sym1 ); + * + * CPPUNIT_IMPLY( emp1 < sym1 && sym1 < alt1, emp1 < alt1 ); + * CPPUNIT_IMPLY( emp1 < sym1 && sym1 < con1, emp1 < con1 ); + * CPPUNIT_IMPLY( emp1 < sym1 && sym1 < ite1, emp1 < ite1 ); + * CPPUNIT_IMPLY( emp1 < sym1 && sym1 < eps1, emp1 < eps1 ); + * + * + * + * CPPUNIT_IMPLY( eps1 < alt1 && alt1 < con1, eps1 < con1 ); + * CPPUNIT_IMPLY( eps1 < alt1 && alt1 < ite1, eps1 < ite1 ); + * CPPUNIT_IMPLY( eps1 < alt1 && alt1 < emp1, eps1 < emp1 ); + * CPPUNIT_IMPLY( eps1 < alt1 && alt1 < sym1, eps1 < sym1 ); + * + * CPPUNIT_IMPLY( eps1 < con1 && con1 < alt1, eps1 < alt1 ); + * CPPUNIT_IMPLY( eps1 < con1 && con1 < ite1, eps1 < ite1 ); + * CPPUNIT_IMPLY( eps1 < con1 && con1 < emp1, eps1 < emp1 ); + * CPPUNIT_IMPLY( eps1 < con1 && con1 < sym1, eps1 < sym1 ); + * + * CPPUNIT_IMPLY( eps1 < ite1 && ite1 < alt1, eps1 < alt1 ); + * CPPUNIT_IMPLY( eps1 < ite1 && ite1 < con1, eps1 < con1 ); + * CPPUNIT_IMPLY( eps1 < ite1 && ite1 < emp1, eps1 < emp1 ); + * CPPUNIT_IMPLY( eps1 < ite1 && ite1 < sym1, eps1 < sym1 ); + * + * CPPUNIT_IMPLY( eps1 < emp1 && emp1 < alt1, eps1 < alt1 ); + * CPPUNIT_IMPLY( eps1 < emp1 && emp1 < con1, eps1 < con1 ); + * CPPUNIT_IMPLY( eps1 < emp1 && emp1 < ite1, eps1 < ite1 ); + * CPPUNIT_IMPLY( eps1 < emp1 && emp1 < sym1, eps1 < sym1 ); + * + * CPPUNIT_IMPLY( eps1 < sym1 && sym1 < alt1, eps1 < alt1 ); + * CPPUNIT_IMPLY( eps1 < sym1 && sym1 < con1, eps1 < con1 ); + * CPPUNIT_IMPLY( eps1 < sym1 && sym1 < ite1, eps1 < ite1 ); + * CPPUNIT_IMPLY( eps1 < sym1 && sym1 < emp1, eps1 < emp1 ); + * + * + * + * CPPUNIT_IMPLY( sym1 < alt1 && alt1 < con1, sym1 < con1 ); + * CPPUNIT_IMPLY( sym1 < alt1 && alt1 < ite1, sym1 < ite1 ); + * CPPUNIT_IMPLY( sym1 < alt1 && alt1 < emp1, sym1 < emp1 ); + * CPPUNIT_IMPLY( sym1 < alt1 && alt1 < eps1, sym1 < eps1 ); + * + * CPPUNIT_IMPLY( sym1 < con1 && con1 < alt1, sym1 < alt1 ); + * CPPUNIT_IMPLY( sym1 < con1 && con1 < ite1, sym1 < ite1 ); + * CPPUNIT_IMPLY( sym1 < con1 && con1 < emp1, sym1 < emp1 ); + * CPPUNIT_IMPLY( sym1 < con1 && con1 < eps1, sym1 < eps1 ); + * + * CPPUNIT_IMPLY( sym1 < ite1 && ite1 < alt1, sym1 < alt1 ); + * CPPUNIT_IMPLY( sym1 < ite1 && ite1 < con1, sym1 < con1 ); + * CPPUNIT_IMPLY( sym1 < ite1 && ite1 < emp1, sym1 < emp1 ); + * CPPUNIT_IMPLY( sym1 < ite1 && ite1 < eps1, sym1 < eps1 ); + * + * CPPUNIT_IMPLY( sym1 < emp1 && emp1 < alt1, sym1 < alt1 ); + * CPPUNIT_IMPLY( sym1 < emp1 && emp1 < con1, sym1 < con1 ); + * CPPUNIT_IMPLY( sym1 < emp1 && emp1 < ite1, sym1 < ite1 ); + * CPPUNIT_IMPLY( sym1 < emp1 && emp1 < eps1, sym1 < eps1 ); + * + * CPPUNIT_IMPLY( sym1 < eps1 && eps1 < alt1, sym1 < alt1 ); + * CPPUNIT_IMPLY( sym1 < eps1 && eps1 < con1, sym1 < con1 ); + * CPPUNIT_IMPLY( sym1 < eps1 && eps1 < ite1, sym1 < ite1 ); + * CPPUNIT_IMPLY( sym1 < eps1 && eps1 < emp1, sym1 < emp1 ); + */ + } + { + /* + * rte::UnboundedRTESymbol s1("1"); + * rte::UnboundedRTESymbol s2("2"); + * rte::UnboundedRTESymbol s3("3"); + * + * rte::UnboundedRTEEmpty e1; + * rte::UnboundedRTEEpsilon e2; + * + * rte::UnboundedRTEIteration i1(s1); + * rte::UnboundedRTEIteration i2(s2); + * rte::UnboundedRTEIteration i3(s3); + * + * rte::UnboundedRTEAlternation a1; + * a1.appendElement(s1); + * a1.appendElement(s1); + * rte::UnboundedRTEAlternation a2; + * a2.appendElement(s1); + * a2.appendElement(s2); + * rte::UnboundedRTEAlternation a3; + * a3.appendElement(s1); + * a3.appendElement(s3); + * rte::UnboundedRTEAlternation a4; + * a4.appendElement(s2); + * a4.appendElement(s1); + * rte::UnboundedRTEAlternation a5; + * a5.appendElement(s2); + * a5.appendElement(s2); + * rte::UnboundedRTEAlternation a6; + * a6.appendElement(s2); + * a6.appendElement(s3); + * rte::UnboundedRTEAlternation a7; + * a7.appendElement(s3); + * a7.appendElement(s1); + * rte::UnboundedRTEAlternation a8; + * a8.appendElement(s3); + * a8.appendElement(s2); + * rte::UnboundedRTEAlternation a9; + * a9.appendElement(s3); + * a9.appendElement(s3); + * + * rte::UnboundedRTEConcatenation c1; + * c1.appendElement(s1); + * c1.appendElement(s1); + * rte::UnboundedRTEConcatenation c2; + * c2.appendElement(s1); + * c2.appendElement(s2); + * rte::UnboundedRTEConcatenation c3; + * c3.appendElement(s1); + * c3.appendElement(s3); + * rte::UnboundedRTEConcatenation c4; + * c4.appendElement(s2); + * c4.appendElement(s1); + * rte::UnboundedRTEConcatenation c5; + * c5.appendElement(s2); + * c5.appendElement(s2); + * rte::UnboundedRTEConcatenation c6; + * c6.appendElement(s2); + * c6.appendElement(s3); + * rte::UnboundedRTEConcatenation c7; + * c7.appendElement(s3); + * c7.appendElement(s1); + * rte::UnboundedRTEConcatenation c8; + * c8.appendElement(s3); + * c8.appendElement(s2); + * rte::UnboundedRTEConcatenation c9; + * c9.appendElement(s3); + * c9.appendElement(s3); + * + * rte::UnboundedRTE alt1(a1); + * rte::UnboundedRTE alt2(a2); + * rte::UnboundedRTE alt3(a3); + * rte::UnboundedRTE alt4(a4); + * rte::UnboundedRTE alt5(a5); + * rte::UnboundedRTE alt6(a6); + * rte::UnboundedRTE alt7(a7); + * rte::UnboundedRTE alt8(a8); + * rte::UnboundedRTE alt9(a9); + * + * rte::UnboundedRTE con1(c1); + * rte::UnboundedRTE con2(c2); + * rte::UnboundedRTE con3(c3); + * rte::UnboundedRTE con4(c4); + * rte::UnboundedRTE con5(c5); + * rte::UnboundedRTE con6(c6); + * rte::UnboundedRTE con7(c7); + * rte::UnboundedRTE con8(c8); + * rte::UnboundedRTE con9(c9); + * + * rte::UnboundedRTE ite1(i1); + * rte::UnboundedRTE ite2(i2); + * rte::UnboundedRTE ite3(i3); + * + * rte::UnboundedRTE emp1(e1); + * rte::UnboundedRTE eps1(e2); + * + * rte::UnboundedRTE sym1(s1); + * rte::UnboundedRTE sym2(s2); + * rte::UnboundedRTE sym3(s3); + * + * + * + * CHECK(alt1 == alt1); + * CHECK(alt1 < alt2); + * CHECK(alt1 < alt3); + * CHECK(alt1 < alt4); + * CHECK(alt1 < alt5); + * CHECK(alt1 < alt6); + * CHECK(alt1 < alt7); + * CHECK(alt1 < alt8); + * CHECK(alt1 < alt9); + * + * CHECK(alt2 > alt1); + * CHECK(alt2 == alt2); + * CHECK(alt2 < alt3); + * CHECK(alt2 < alt4); + * CHECK(alt2 < alt5); + * CHECK(alt2 < alt6); + * CHECK(alt2 < alt7); + * CHECK(alt2 < alt8); + * CHECK(alt2 < alt9); + * + * CHECK(alt3 > alt1); + * CHECK(alt3 > alt2); + * CHECK(alt3 == alt3); + * CHECK(alt3 < alt4); + * CHECK(alt3 < alt5); + * CHECK(alt3 < alt6); + * CHECK(alt3 < alt7); + * CHECK(alt3 < alt8); + * CHECK(alt3 < alt9); + * + * CHECK(alt4 > alt1); + * CHECK(alt4 > alt2); + * CHECK(alt4 > alt3); + * CHECK(alt4 == alt4); + * CHECK(alt4 < alt5); + * CHECK(alt4 < alt6); + * CHECK(alt4 < alt7); + * CHECK(alt4 < alt8); + * CHECK(alt4 < alt9); + * + * CHECK(alt5 > alt1); + * CHECK(alt5 > alt2); + * CHECK(alt5 > alt3); + * CHECK(alt5 > alt4); + * CHECK(alt5 == alt5); + * CHECK(alt5 < alt6); + * CHECK(alt5 < alt7); + * CHECK(alt5 < alt8); + * CHECK(alt5 < alt9); + * + * CHECK(alt6 > alt1); + * CHECK(alt6 > alt2); + * CHECK(alt6 > alt3); + * CHECK(alt6 > alt4); + * CHECK(alt6 > alt5); + * CHECK(alt6 == alt6); + * CHECK(alt6 < alt7); + * CHECK(alt6 < alt8); + * CHECK(alt6 < alt9); + * + * CHECK(alt7 > alt1); + * CHECK(alt7 > alt2); + * CHECK(alt7 > alt3); + * CHECK(alt7 > alt4); + * CHECK(alt7 > alt5); + * CHECK(alt7 > alt6); + * CHECK(alt7 == alt7); + * CHECK(alt7 < alt8); + * CHECK(alt7 < alt9); + * + * CHECK(alt8 > alt1); + * CHECK(alt8 > alt2); + * CHECK(alt8 > alt3); + * CHECK(alt8 > alt4); + * CHECK(alt8 > alt5); + * CHECK(alt8 > alt6); + * CHECK(alt8 > alt7); + * CHECK(alt8 == alt8); + * CHECK(alt8 < alt9); + * + * CHECK(alt9 > alt1); + * CHECK(alt9 > alt2); + * CHECK(alt9 > alt3); + * CHECK(alt9 > alt4); + * CHECK(alt9 > alt5); + * CHECK(alt9 > alt6); + * CHECK(alt9 > alt7); + * CHECK(alt9 > alt8); + * CHECK(alt9 == alt9); + * + * + * + * CHECK(con1 == con1); + * CHECK(con1 < con2); + * CHECK(con1 < con3); + * CHECK(con1 < con4); + * CHECK(con1 < con5); + * CHECK(con1 < con6); + * CHECK(con1 < con7); + * CHECK(con1 < con8); + * CHECK(con1 < con9); + * + * CHECK(con2 > con1); + * CHECK(con2 == con2); + * CHECK(con2 < con3); + * CHECK(con2 < con4); + * CHECK(con2 < con5); + * CHECK(con2 < con6); + * CHECK(con2 < con7); + * CHECK(con2 < con8); + * CHECK(con2 < con9); + * + * CHECK(con3 > con1); + * CHECK(con3 > con2); + * CHECK(con3 == con3); + * CHECK(con3 < con4); + * CHECK(con3 < con5); + * CHECK(con3 < con6); + * CHECK(con3 < con7); + * CHECK(con3 < con8); + * CHECK(con3 < con9); + * + * CHECK(con4 > con1); + * CHECK(con4 > con2); + * CHECK(con4 > con3); + * CHECK(con4 == con4); + * CHECK(con4 < con5); + * CHECK(con4 < con6); + * CHECK(con4 < con7); + * CHECK(con4 < con8); + * CHECK(con4 < con9); + * + * CHECK(con5 > con1); + * CHECK(con5 > con2); + * CHECK(con5 > con3); + * CHECK(con5 > con4); + * CHECK(con5 == con5); + * CHECK(con5 < con6); + * CHECK(con5 < con7); + * CHECK(con5 < con8); + * CHECK(con5 < con9); + * + * CHECK(con6 > con1); + * CHECK(con6 > con2); + * CHECK(con6 > con3); + * CHECK(con6 > con4); + * CHECK(con6 > con5); + * CHECK(con6 == con6); + * CHECK(con6 < con7); + * CHECK(con6 < con8); + * CHECK(con6 < con9); + * + * CHECK(con7 > con1); + * CHECK(con7 > con2); + * CHECK(con7 > con3); + * CHECK(con7 > con4); + * CHECK(con7 > con5); + * CHECK(con7 > con6); + * CHECK(con7 == con7); + * CHECK(con7 < con8); + * CHECK(con7 < con9); + * + * CHECK(con8 > con1); + * CHECK(con8 > con2); + * CHECK(con8 > con3); + * CHECK(con8 > con4); + * CHECK(con8 > con5); + * CHECK(con8 > con6); + * CHECK(con8 > con7); + * CHECK(con8 == con8); + * CHECK(con8 < con9); + * + * CHECK(con9 > con1); + * CHECK(con9 > con2); + * CHECK(con9 > con3); + * CHECK(con9 > con4); + * CHECK(con9 > con5); + * CHECK(con9 > con6); + * CHECK(con9 > con7); + * CHECK(con9 > con8); + * CHECK(con9 == con9); + * + * + * CHECK(ite1 == ite1); + * CHECK(ite1 < ite2); + * CHECK(ite1 < ite3); + * + * CHECK(ite2 > ite1); + * CHECK(ite2 == ite2); + * CHECK(ite2 < ite3); + * + * CHECK(ite3 > ite1); + * CHECK(ite3 > ite2); + * CHECK(ite3 == ite3); + * + * + * + * CHECK(emp1 == emp1); + * + * + * + * CHECK(eps1 == eps1); + * + * + * + * CHECK(sym1 == sym1); + * CHECK(sym1 < sym2); + * CHECK(sym1 < sym3); + * + * CHECK(sym2 > sym1); + * CHECK(sym2 == sym2); + * CHECK(sym2 < sym3); + * + * CHECK(sym3 > sym1); + * CHECK(sym3 > sym2); + * CHECK(sym3 == sym3); + */ + } } } - -void RTETest::testOrder ( ) { - /* - * rte::UnboundedRTESymbol s1("1"); - * rte::UnboundedRTEEmpty e1; - * rte::UnboundedRTEEpsilon e2; - * rte::UnboundedRTEIteration i1(s1); - * rte::UnboundedRTEConcatenation a1; - * a1.appendElement(s1); - * a1.appendElement(s1); - * rte::UnboundedRTEAlternation c1; - * c1.appendElement(s1); - * c1.appendElement(s1); - * - * rte::UnboundedRTE alt1(a1); - * rte::UnboundedRTE con1(c1); - * rte::UnboundedRTE ite1(i1); - * rte::UnboundedRTE emp1(e1); - * rte::UnboundedRTE eps1(e2); - * rte::UnboundedRTE sym1(s1); - * - * CPPUNIT_EXCLUSIVE_OR(alt1 < con1, con1 < alt1); - * CPPUNIT_EXCLUSIVE_OR(alt1 < ite1, ite1 < alt1); - * CPPUNIT_EXCLUSIVE_OR(alt1 < emp1, emp1 < alt1); - * CPPUNIT_EXCLUSIVE_OR(alt1 < eps1, eps1 < alt1); - * CPPUNIT_EXCLUSIVE_OR(alt1 < sym1, sym1 < alt1); - * - * CPPUNIT_EXCLUSIVE_OR(con1 < ite1, ite1 < con1); - * CPPUNIT_EXCLUSIVE_OR(con1 < emp1, emp1 < con1); - * CPPUNIT_EXCLUSIVE_OR(con1 < eps1, eps1 < con1); - * CPPUNIT_EXCLUSIVE_OR(con1 < sym1, sym1 < con1); - * - * CPPUNIT_EXCLUSIVE_OR(ite1 < emp1, emp1 < ite1); - * CPPUNIT_EXCLUSIVE_OR(ite1 < eps1, eps1 < ite1); - * CPPUNIT_EXCLUSIVE_OR(ite1 < sym1, sym1 < ite1); - * - * CPPUNIT_EXCLUSIVE_OR(emp1 < eps1, eps1 < emp1); - * CPPUNIT_EXCLUSIVE_OR(emp1 < sym1, sym1 < emp1); - * - * CPPUNIT_EXCLUSIVE_OR(eps1 < sym1, sym1 < eps1); - * - * CPPUNIT_IMPLY( alt1 < con1 && con1 < ite1, alt1 < ite1 ); - * CPPUNIT_IMPLY( alt1 < con1 && con1 < emp1, alt1 < emp1 ); - * CPPUNIT_IMPLY( alt1 < con1 && con1 < eps1, alt1 < eps1 ); - * CPPUNIT_IMPLY( alt1 < con1 && con1 < sym1, alt1 < sym1 ); - * - * CPPUNIT_IMPLY( alt1 < ite1 && ite1 < con1, alt1 < con1 ); - * CPPUNIT_IMPLY( alt1 < ite1 && ite1 < emp1, alt1 < emp1 ); - * CPPUNIT_IMPLY( alt1 < ite1 && ite1 < eps1, alt1 < eps1 ); - * CPPUNIT_IMPLY( alt1 < ite1 && ite1 < sym1, alt1 < sym1 ); - * - * CPPUNIT_IMPLY( alt1 < emp1 && emp1 < con1, alt1 < con1 ); - * CPPUNIT_IMPLY( alt1 < emp1 && emp1 < ite1, alt1 < ite1 ); - * CPPUNIT_IMPLY( alt1 < emp1 && emp1 < eps1, alt1 < eps1 ); - * CPPUNIT_IMPLY( alt1 < emp1 && emp1 < sym1, alt1 < sym1 ); - * - * CPPUNIT_IMPLY( alt1 < eps1 && eps1 < con1, alt1 < con1 ); - * CPPUNIT_IMPLY( alt1 < eps1 && eps1 < ite1, alt1 < ite1 ); - * CPPUNIT_IMPLY( alt1 < eps1 && eps1 < emp1, alt1 < emp1 ); - * CPPUNIT_IMPLY( alt1 < eps1 && eps1 < sym1, alt1 < sym1 ); - * - * CPPUNIT_IMPLY( alt1 < sym1 && sym1 < con1, alt1 < con1 ); - * CPPUNIT_IMPLY( alt1 < sym1 && sym1 < ite1, alt1 < ite1 ); - * CPPUNIT_IMPLY( alt1 < sym1 && sym1 < emp1, alt1 < emp1 ); - * CPPUNIT_IMPLY( alt1 < sym1 && sym1 < eps1, alt1 < eps1 ); - * - * - * - * CPPUNIT_IMPLY( con1 < alt1 && alt1 < ite1, con1 < ite1 ); - * CPPUNIT_IMPLY( con1 < alt1 && alt1 < emp1, con1 < emp1 ); - * CPPUNIT_IMPLY( con1 < alt1 && alt1 < eps1, con1 < eps1 ); - * CPPUNIT_IMPLY( con1 < alt1 && alt1 < sym1, con1 < sym1 ); - * - * CPPUNIT_IMPLY( con1 < ite1 && ite1 < alt1, con1 < alt1 ); - * CPPUNIT_IMPLY( con1 < ite1 && ite1 < emp1, con1 < emp1 ); - * CPPUNIT_IMPLY( con1 < ite1 && ite1 < eps1, con1 < eps1 ); - * CPPUNIT_IMPLY( con1 < ite1 && ite1 < sym1, con1 < sym1 ); - * - * CPPUNIT_IMPLY( con1 < emp1 && emp1 < alt1, con1 < alt1 ); - * CPPUNIT_IMPLY( con1 < emp1 && emp1 < ite1, con1 < ite1 ); - * CPPUNIT_IMPLY( con1 < emp1 && emp1 < eps1, con1 < eps1 ); - * CPPUNIT_IMPLY( con1 < emp1 && emp1 < sym1, con1 < sym1 ); - * - * CPPUNIT_IMPLY( con1 < eps1 && eps1 < alt1, con1 < alt1 ); - * CPPUNIT_IMPLY( con1 < eps1 && eps1 < ite1, con1 < ite1 ); - * CPPUNIT_IMPLY( con1 < eps1 && eps1 < emp1, con1 < emp1 ); - * CPPUNIT_IMPLY( con1 < eps1 && eps1 < sym1, con1 < sym1 ); - * - * CPPUNIT_IMPLY( con1 < sym1 && sym1 < alt1, con1 < alt1 ); - * CPPUNIT_IMPLY( con1 < sym1 && sym1 < ite1, con1 < ite1 ); - * CPPUNIT_IMPLY( con1 < sym1 && sym1 < emp1, con1 < emp1 ); - * CPPUNIT_IMPLY( con1 < sym1 && sym1 < eps1, con1 < eps1 ); - * - * - * - * CPPUNIT_IMPLY( ite1 < alt1 && alt1 < con1, ite1 < con1 ); - * CPPUNIT_IMPLY( ite1 < alt1 && alt1 < emp1, ite1 < emp1 ); - * CPPUNIT_IMPLY( ite1 < alt1 && alt1 < eps1, ite1 < eps1 ); - * CPPUNIT_IMPLY( ite1 < alt1 && alt1 < sym1, ite1 < sym1 ); - * - * CPPUNIT_IMPLY( ite1 < con1 && con1 < alt1, ite1 < alt1 ); - * CPPUNIT_IMPLY( ite1 < con1 && con1 < emp1, ite1 < emp1 ); - * CPPUNIT_IMPLY( ite1 < con1 && con1 < eps1, ite1 < eps1 ); - * CPPUNIT_IMPLY( ite1 < con1 && con1 < sym1, ite1 < sym1 ); - * - * CPPUNIT_IMPLY( ite1 < emp1 && emp1 < alt1, ite1 < alt1 ); - * CPPUNIT_IMPLY( ite1 < emp1 && emp1 < con1, ite1 < con1 ); - * CPPUNIT_IMPLY( ite1 < emp1 && emp1 < eps1, ite1 < eps1 ); - * CPPUNIT_IMPLY( ite1 < emp1 && emp1 < sym1, ite1 < sym1 ); - * - * CPPUNIT_IMPLY( ite1 < eps1 && eps1 < alt1, ite1 < alt1 ); - * CPPUNIT_IMPLY( ite1 < eps1 && eps1 < con1, ite1 < con1 ); - * CPPUNIT_IMPLY( ite1 < eps1 && eps1 < emp1, ite1 < emp1 ); - * CPPUNIT_IMPLY( ite1 < eps1 && eps1 < sym1, ite1 < sym1 ); - * - * CPPUNIT_IMPLY( ite1 < sym1 && sym1 < alt1, ite1 < alt1 ); - * CPPUNIT_IMPLY( ite1 < sym1 && sym1 < con1, ite1 < con1 ); - * CPPUNIT_IMPLY( ite1 < sym1 && sym1 < emp1, ite1 < emp1 ); - * CPPUNIT_IMPLY( ite1 < sym1 && sym1 < eps1, ite1 < eps1 ); - * - * - * - * CPPUNIT_IMPLY( emp1 < alt1 && alt1 < con1, emp1 < con1 ); - * CPPUNIT_IMPLY( emp1 < alt1 && alt1 < ite1, emp1 < ite1 ); - * CPPUNIT_IMPLY( emp1 < alt1 && alt1 < eps1, emp1 < eps1 ); - * CPPUNIT_IMPLY( emp1 < alt1 && alt1 < sym1, emp1 < sym1 ); - * - * CPPUNIT_IMPLY( emp1 < con1 && con1 < alt1, emp1 < alt1 ); - * CPPUNIT_IMPLY( emp1 < con1 && con1 < ite1, emp1 < ite1 ); - * CPPUNIT_IMPLY( emp1 < con1 && con1 < eps1, emp1 < eps1 ); - * CPPUNIT_IMPLY( emp1 < con1 && con1 < sym1, emp1 < sym1 ); - * - * CPPUNIT_IMPLY( emp1 < ite1 && ite1 < alt1, emp1 < alt1 ); - * CPPUNIT_IMPLY( emp1 < ite1 && ite1 < con1, emp1 < con1 ); - * CPPUNIT_IMPLY( emp1 < ite1 && ite1 < eps1, emp1 < eps1 ); - * CPPUNIT_IMPLY( emp1 < ite1 && ite1 < sym1, emp1 < sym1 ); - * - * CPPUNIT_IMPLY( emp1 < eps1 && eps1 < alt1, emp1 < alt1 ); - * CPPUNIT_IMPLY( emp1 < eps1 && eps1 < con1, emp1 < con1 ); - * CPPUNIT_IMPLY( emp1 < eps1 && eps1 < ite1, emp1 < ite1 ); - * CPPUNIT_IMPLY( emp1 < eps1 && eps1 < sym1, emp1 < sym1 ); - * - * CPPUNIT_IMPLY( emp1 < sym1 && sym1 < alt1, emp1 < alt1 ); - * CPPUNIT_IMPLY( emp1 < sym1 && sym1 < con1, emp1 < con1 ); - * CPPUNIT_IMPLY( emp1 < sym1 && sym1 < ite1, emp1 < ite1 ); - * CPPUNIT_IMPLY( emp1 < sym1 && sym1 < eps1, emp1 < eps1 ); - * - * - * - * CPPUNIT_IMPLY( eps1 < alt1 && alt1 < con1, eps1 < con1 ); - * CPPUNIT_IMPLY( eps1 < alt1 && alt1 < ite1, eps1 < ite1 ); - * CPPUNIT_IMPLY( eps1 < alt1 && alt1 < emp1, eps1 < emp1 ); - * CPPUNIT_IMPLY( eps1 < alt1 && alt1 < sym1, eps1 < sym1 ); - * - * CPPUNIT_IMPLY( eps1 < con1 && con1 < alt1, eps1 < alt1 ); - * CPPUNIT_IMPLY( eps1 < con1 && con1 < ite1, eps1 < ite1 ); - * CPPUNIT_IMPLY( eps1 < con1 && con1 < emp1, eps1 < emp1 ); - * CPPUNIT_IMPLY( eps1 < con1 && con1 < sym1, eps1 < sym1 ); - * - * CPPUNIT_IMPLY( eps1 < ite1 && ite1 < alt1, eps1 < alt1 ); - * CPPUNIT_IMPLY( eps1 < ite1 && ite1 < con1, eps1 < con1 ); - * CPPUNIT_IMPLY( eps1 < ite1 && ite1 < emp1, eps1 < emp1 ); - * CPPUNIT_IMPLY( eps1 < ite1 && ite1 < sym1, eps1 < sym1 ); - * - * CPPUNIT_IMPLY( eps1 < emp1 && emp1 < alt1, eps1 < alt1 ); - * CPPUNIT_IMPLY( eps1 < emp1 && emp1 < con1, eps1 < con1 ); - * CPPUNIT_IMPLY( eps1 < emp1 && emp1 < ite1, eps1 < ite1 ); - * CPPUNIT_IMPLY( eps1 < emp1 && emp1 < sym1, eps1 < sym1 ); - * - * CPPUNIT_IMPLY( eps1 < sym1 && sym1 < alt1, eps1 < alt1 ); - * CPPUNIT_IMPLY( eps1 < sym1 && sym1 < con1, eps1 < con1 ); - * CPPUNIT_IMPLY( eps1 < sym1 && sym1 < ite1, eps1 < ite1 ); - * CPPUNIT_IMPLY( eps1 < sym1 && sym1 < emp1, eps1 < emp1 ); - * - * - * - * CPPUNIT_IMPLY( sym1 < alt1 && alt1 < con1, sym1 < con1 ); - * CPPUNIT_IMPLY( sym1 < alt1 && alt1 < ite1, sym1 < ite1 ); - * CPPUNIT_IMPLY( sym1 < alt1 && alt1 < emp1, sym1 < emp1 ); - * CPPUNIT_IMPLY( sym1 < alt1 && alt1 < eps1, sym1 < eps1 ); - * - * CPPUNIT_IMPLY( sym1 < con1 && con1 < alt1, sym1 < alt1 ); - * CPPUNIT_IMPLY( sym1 < con1 && con1 < ite1, sym1 < ite1 ); - * CPPUNIT_IMPLY( sym1 < con1 && con1 < emp1, sym1 < emp1 ); - * CPPUNIT_IMPLY( sym1 < con1 && con1 < eps1, sym1 < eps1 ); - * - * CPPUNIT_IMPLY( sym1 < ite1 && ite1 < alt1, sym1 < alt1 ); - * CPPUNIT_IMPLY( sym1 < ite1 && ite1 < con1, sym1 < con1 ); - * CPPUNIT_IMPLY( sym1 < ite1 && ite1 < emp1, sym1 < emp1 ); - * CPPUNIT_IMPLY( sym1 < ite1 && ite1 < eps1, sym1 < eps1 ); - * - * CPPUNIT_IMPLY( sym1 < emp1 && emp1 < alt1, sym1 < alt1 ); - * CPPUNIT_IMPLY( sym1 < emp1 && emp1 < con1, sym1 < con1 ); - * CPPUNIT_IMPLY( sym1 < emp1 && emp1 < ite1, sym1 < ite1 ); - * CPPUNIT_IMPLY( sym1 < emp1 && emp1 < eps1, sym1 < eps1 ); - * - * CPPUNIT_IMPLY( sym1 < eps1 && eps1 < alt1, sym1 < alt1 ); - * CPPUNIT_IMPLY( sym1 < eps1 && eps1 < con1, sym1 < con1 ); - * CPPUNIT_IMPLY( sym1 < eps1 && eps1 < ite1, sym1 < ite1 ); - * CPPUNIT_IMPLY( sym1 < eps1 && eps1 < emp1, sym1 < emp1 ); - */ -} - -void RTETest::testOrder2 ( ) { - /* - * rte::UnboundedRTESymbol s1("1"); - * rte::UnboundedRTESymbol s2("2"); - * rte::UnboundedRTESymbol s3("3"); - * - * rte::UnboundedRTEEmpty e1; - * rte::UnboundedRTEEpsilon e2; - * - * rte::UnboundedRTEIteration i1(s1); - * rte::UnboundedRTEIteration i2(s2); - * rte::UnboundedRTEIteration i3(s3); - * - * rte::UnboundedRTEAlternation a1; - * a1.appendElement(s1); - * a1.appendElement(s1); - * rte::UnboundedRTEAlternation a2; - * a2.appendElement(s1); - * a2.appendElement(s2); - * rte::UnboundedRTEAlternation a3; - * a3.appendElement(s1); - * a3.appendElement(s3); - * rte::UnboundedRTEAlternation a4; - * a4.appendElement(s2); - * a4.appendElement(s1); - * rte::UnboundedRTEAlternation a5; - * a5.appendElement(s2); - * a5.appendElement(s2); - * rte::UnboundedRTEAlternation a6; - * a6.appendElement(s2); - * a6.appendElement(s3); - * rte::UnboundedRTEAlternation a7; - * a7.appendElement(s3); - * a7.appendElement(s1); - * rte::UnboundedRTEAlternation a8; - * a8.appendElement(s3); - * a8.appendElement(s2); - * rte::UnboundedRTEAlternation a9; - * a9.appendElement(s3); - * a9.appendElement(s3); - * - * rte::UnboundedRTEConcatenation c1; - * c1.appendElement(s1); - * c1.appendElement(s1); - * rte::UnboundedRTEConcatenation c2; - * c2.appendElement(s1); - * c2.appendElement(s2); - * rte::UnboundedRTEConcatenation c3; - * c3.appendElement(s1); - * c3.appendElement(s3); - * rte::UnboundedRTEConcatenation c4; - * c4.appendElement(s2); - * c4.appendElement(s1); - * rte::UnboundedRTEConcatenation c5; - * c5.appendElement(s2); - * c5.appendElement(s2); - * rte::UnboundedRTEConcatenation c6; - * c6.appendElement(s2); - * c6.appendElement(s3); - * rte::UnboundedRTEConcatenation c7; - * c7.appendElement(s3); - * c7.appendElement(s1); - * rte::UnboundedRTEConcatenation c8; - * c8.appendElement(s3); - * c8.appendElement(s2); - * rte::UnboundedRTEConcatenation c9; - * c9.appendElement(s3); - * c9.appendElement(s3); - * - * rte::UnboundedRTE alt1(a1); - * rte::UnboundedRTE alt2(a2); - * rte::UnboundedRTE alt3(a3); - * rte::UnboundedRTE alt4(a4); - * rte::UnboundedRTE alt5(a5); - * rte::UnboundedRTE alt6(a6); - * rte::UnboundedRTE alt7(a7); - * rte::UnboundedRTE alt8(a8); - * rte::UnboundedRTE alt9(a9); - * - * rte::UnboundedRTE con1(c1); - * rte::UnboundedRTE con2(c2); - * rte::UnboundedRTE con3(c3); - * rte::UnboundedRTE con4(c4); - * rte::UnboundedRTE con5(c5); - * rte::UnboundedRTE con6(c6); - * rte::UnboundedRTE con7(c7); - * rte::UnboundedRTE con8(c8); - * rte::UnboundedRTE con9(c9); - * - * rte::UnboundedRTE ite1(i1); - * rte::UnboundedRTE ite2(i2); - * rte::UnboundedRTE ite3(i3); - * - * rte::UnboundedRTE emp1(e1); - * rte::UnboundedRTE eps1(e2); - * - * rte::UnboundedRTE sym1(s1); - * rte::UnboundedRTE sym2(s2); - * rte::UnboundedRTE sym3(s3); - * - * - * - * CPPUNIT_ASSERT(alt1 == alt1); - * CPPUNIT_ASSERT(alt1 < alt2); - * CPPUNIT_ASSERT(alt1 < alt3); - * CPPUNIT_ASSERT(alt1 < alt4); - * CPPUNIT_ASSERT(alt1 < alt5); - * CPPUNIT_ASSERT(alt1 < alt6); - * CPPUNIT_ASSERT(alt1 < alt7); - * CPPUNIT_ASSERT(alt1 < alt8); - * CPPUNIT_ASSERT(alt1 < alt9); - * - * CPPUNIT_ASSERT(alt2 > alt1); - * CPPUNIT_ASSERT(alt2 == alt2); - * CPPUNIT_ASSERT(alt2 < alt3); - * CPPUNIT_ASSERT(alt2 < alt4); - * CPPUNIT_ASSERT(alt2 < alt5); - * CPPUNIT_ASSERT(alt2 < alt6); - * CPPUNIT_ASSERT(alt2 < alt7); - * CPPUNIT_ASSERT(alt2 < alt8); - * CPPUNIT_ASSERT(alt2 < alt9); - * - * CPPUNIT_ASSERT(alt3 > alt1); - * CPPUNIT_ASSERT(alt3 > alt2); - * CPPUNIT_ASSERT(alt3 == alt3); - * CPPUNIT_ASSERT(alt3 < alt4); - * CPPUNIT_ASSERT(alt3 < alt5); - * CPPUNIT_ASSERT(alt3 < alt6); - * CPPUNIT_ASSERT(alt3 < alt7); - * CPPUNIT_ASSERT(alt3 < alt8); - * CPPUNIT_ASSERT(alt3 < alt9); - * - * CPPUNIT_ASSERT(alt4 > alt1); - * CPPUNIT_ASSERT(alt4 > alt2); - * CPPUNIT_ASSERT(alt4 > alt3); - * CPPUNIT_ASSERT(alt4 == alt4); - * CPPUNIT_ASSERT(alt4 < alt5); - * CPPUNIT_ASSERT(alt4 < alt6); - * CPPUNIT_ASSERT(alt4 < alt7); - * CPPUNIT_ASSERT(alt4 < alt8); - * CPPUNIT_ASSERT(alt4 < alt9); - * - * CPPUNIT_ASSERT(alt5 > alt1); - * CPPUNIT_ASSERT(alt5 > alt2); - * CPPUNIT_ASSERT(alt5 > alt3); - * CPPUNIT_ASSERT(alt5 > alt4); - * CPPUNIT_ASSERT(alt5 == alt5); - * CPPUNIT_ASSERT(alt5 < alt6); - * CPPUNIT_ASSERT(alt5 < alt7); - * CPPUNIT_ASSERT(alt5 < alt8); - * CPPUNIT_ASSERT(alt5 < alt9); - * - * CPPUNIT_ASSERT(alt6 > alt1); - * CPPUNIT_ASSERT(alt6 > alt2); - * CPPUNIT_ASSERT(alt6 > alt3); - * CPPUNIT_ASSERT(alt6 > alt4); - * CPPUNIT_ASSERT(alt6 > alt5); - * CPPUNIT_ASSERT(alt6 == alt6); - * CPPUNIT_ASSERT(alt6 < alt7); - * CPPUNIT_ASSERT(alt6 < alt8); - * CPPUNIT_ASSERT(alt6 < alt9); - * - * CPPUNIT_ASSERT(alt7 > alt1); - * CPPUNIT_ASSERT(alt7 > alt2); - * CPPUNIT_ASSERT(alt7 > alt3); - * CPPUNIT_ASSERT(alt7 > alt4); - * CPPUNIT_ASSERT(alt7 > alt5); - * CPPUNIT_ASSERT(alt7 > alt6); - * CPPUNIT_ASSERT(alt7 == alt7); - * CPPUNIT_ASSERT(alt7 < alt8); - * CPPUNIT_ASSERT(alt7 < alt9); - * - * CPPUNIT_ASSERT(alt8 > alt1); - * CPPUNIT_ASSERT(alt8 > alt2); - * CPPUNIT_ASSERT(alt8 > alt3); - * CPPUNIT_ASSERT(alt8 > alt4); - * CPPUNIT_ASSERT(alt8 > alt5); - * CPPUNIT_ASSERT(alt8 > alt6); - * CPPUNIT_ASSERT(alt8 > alt7); - * CPPUNIT_ASSERT(alt8 == alt8); - * CPPUNIT_ASSERT(alt8 < alt9); - * - * CPPUNIT_ASSERT(alt9 > alt1); - * CPPUNIT_ASSERT(alt9 > alt2); - * CPPUNIT_ASSERT(alt9 > alt3); - * CPPUNIT_ASSERT(alt9 > alt4); - * CPPUNIT_ASSERT(alt9 > alt5); - * CPPUNIT_ASSERT(alt9 > alt6); - * CPPUNIT_ASSERT(alt9 > alt7); - * CPPUNIT_ASSERT(alt9 > alt8); - * CPPUNIT_ASSERT(alt9 == alt9); - * - * - * - * CPPUNIT_ASSERT(con1 == con1); - * CPPUNIT_ASSERT(con1 < con2); - * CPPUNIT_ASSERT(con1 < con3); - * CPPUNIT_ASSERT(con1 < con4); - * CPPUNIT_ASSERT(con1 < con5); - * CPPUNIT_ASSERT(con1 < con6); - * CPPUNIT_ASSERT(con1 < con7); - * CPPUNIT_ASSERT(con1 < con8); - * CPPUNIT_ASSERT(con1 < con9); - * - * CPPUNIT_ASSERT(con2 > con1); - * CPPUNIT_ASSERT(con2 == con2); - * CPPUNIT_ASSERT(con2 < con3); - * CPPUNIT_ASSERT(con2 < con4); - * CPPUNIT_ASSERT(con2 < con5); - * CPPUNIT_ASSERT(con2 < con6); - * CPPUNIT_ASSERT(con2 < con7); - * CPPUNIT_ASSERT(con2 < con8); - * CPPUNIT_ASSERT(con2 < con9); - * - * CPPUNIT_ASSERT(con3 > con1); - * CPPUNIT_ASSERT(con3 > con2); - * CPPUNIT_ASSERT(con3 == con3); - * CPPUNIT_ASSERT(con3 < con4); - * CPPUNIT_ASSERT(con3 < con5); - * CPPUNIT_ASSERT(con3 < con6); - * CPPUNIT_ASSERT(con3 < con7); - * CPPUNIT_ASSERT(con3 < con8); - * CPPUNIT_ASSERT(con3 < con9); - * - * CPPUNIT_ASSERT(con4 > con1); - * CPPUNIT_ASSERT(con4 > con2); - * CPPUNIT_ASSERT(con4 > con3); - * CPPUNIT_ASSERT(con4 == con4); - * CPPUNIT_ASSERT(con4 < con5); - * CPPUNIT_ASSERT(con4 < con6); - * CPPUNIT_ASSERT(con4 < con7); - * CPPUNIT_ASSERT(con4 < con8); - * CPPUNIT_ASSERT(con4 < con9); - * - * CPPUNIT_ASSERT(con5 > con1); - * CPPUNIT_ASSERT(con5 > con2); - * CPPUNIT_ASSERT(con5 > con3); - * CPPUNIT_ASSERT(con5 > con4); - * CPPUNIT_ASSERT(con5 == con5); - * CPPUNIT_ASSERT(con5 < con6); - * CPPUNIT_ASSERT(con5 < con7); - * CPPUNIT_ASSERT(con5 < con8); - * CPPUNIT_ASSERT(con5 < con9); - * - * CPPUNIT_ASSERT(con6 > con1); - * CPPUNIT_ASSERT(con6 > con2); - * CPPUNIT_ASSERT(con6 > con3); - * CPPUNIT_ASSERT(con6 > con4); - * CPPUNIT_ASSERT(con6 > con5); - * CPPUNIT_ASSERT(con6 == con6); - * CPPUNIT_ASSERT(con6 < con7); - * CPPUNIT_ASSERT(con6 < con8); - * CPPUNIT_ASSERT(con6 < con9); - * - * CPPUNIT_ASSERT(con7 > con1); - * CPPUNIT_ASSERT(con7 > con2); - * CPPUNIT_ASSERT(con7 > con3); - * CPPUNIT_ASSERT(con7 > con4); - * CPPUNIT_ASSERT(con7 > con5); - * CPPUNIT_ASSERT(con7 > con6); - * CPPUNIT_ASSERT(con7 == con7); - * CPPUNIT_ASSERT(con7 < con8); - * CPPUNIT_ASSERT(con7 < con9); - * - * CPPUNIT_ASSERT(con8 > con1); - * CPPUNIT_ASSERT(con8 > con2); - * CPPUNIT_ASSERT(con8 > con3); - * CPPUNIT_ASSERT(con8 > con4); - * CPPUNIT_ASSERT(con8 > con5); - * CPPUNIT_ASSERT(con8 > con6); - * CPPUNIT_ASSERT(con8 > con7); - * CPPUNIT_ASSERT(con8 == con8); - * CPPUNIT_ASSERT(con8 < con9); - * - * CPPUNIT_ASSERT(con9 > con1); - * CPPUNIT_ASSERT(con9 > con2); - * CPPUNIT_ASSERT(con9 > con3); - * CPPUNIT_ASSERT(con9 > con4); - * CPPUNIT_ASSERT(con9 > con5); - * CPPUNIT_ASSERT(con9 > con6); - * CPPUNIT_ASSERT(con9 > con7); - * CPPUNIT_ASSERT(con9 > con8); - * CPPUNIT_ASSERT(con9 == con9); - * - * - * CPPUNIT_ASSERT(ite1 == ite1); - * CPPUNIT_ASSERT(ite1 < ite2); - * CPPUNIT_ASSERT(ite1 < ite3); - * - * CPPUNIT_ASSERT(ite2 > ite1); - * CPPUNIT_ASSERT(ite2 == ite2); - * CPPUNIT_ASSERT(ite2 < ite3); - * - * CPPUNIT_ASSERT(ite3 > ite1); - * CPPUNIT_ASSERT(ite3 > ite2); - * CPPUNIT_ASSERT(ite3 == ite3); - * - * - * - * CPPUNIT_ASSERT(emp1 == emp1); - * - * - * - * CPPUNIT_ASSERT(eps1 == eps1); - * - * - * - * CPPUNIT_ASSERT(sym1 == sym1); - * CPPUNIT_ASSERT(sym1 < sym2); - * CPPUNIT_ASSERT(sym1 < sym3); - * - * CPPUNIT_ASSERT(sym2 > sym1); - * CPPUNIT_ASSERT(sym2 == sym2); - * CPPUNIT_ASSERT(sym2 < sym3); - * - * CPPUNIT_ASSERT(sym3 > sym1); - * CPPUNIT_ASSERT(sym3 > sym2); - * CPPUNIT_ASSERT(sym3 == sym3); - */ -} diff --git a/alib2data/test-src/rte/RTETest.h b/alib2data/test-src/rte/RTETest.h deleted file mode 100644 index a58704b6b7abb0f7c6c0bfdff2eabecc2467e931..0000000000000000000000000000000000000000 --- a/alib2data/test-src/rte/RTETest.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef RTE_TEST_H_ -#define RTE_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class RTETest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( RTETest ); - CPPUNIT_TEST( testCopyConstruct ); - CPPUNIT_TEST( testXMLParser ); - CPPUNIT_TEST( testOrder ); - CPPUNIT_TEST( testOrder2 ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testCopyConstruct(); - void testXMLParser(); - void testOrder(); - void testOrder2(); -}; - -#endif // REG_EXP_TEST_H_ diff --git a/alib2data/test-src/string/StringTest.cpp b/alib2data/test-src/string/StringTest.cpp index 058a0aceb6d0dffcb7820fe4473d451fbb4a0bec..a990a0988d536e04e826e7921c08936fa0f7677f 100644 --- a/alib2data/test-src/string/StringTest.cpp +++ b/alib2data/test-src/string/StringTest.cpp @@ -1,6 +1,6 @@ -#include <alib/list> +#include <catch2/catch.hpp> + #include <alib/variant> -#include "StringTest.h" #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -19,133 +19,126 @@ #include <primitive/xml/Character.h> #include <container/xml/ObjectsSet.h> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( StringTest, "string" ); -CPPUNIT_TEST_SUITE_REGISTRATION ( StringTest ); - -void StringTest::setUp ( ) { -} - -void StringTest::tearDown ( ) { -} - -void StringTest::testCopyConstruct ( ) { - string::LinearString < > string; +TEST_CASE ( "String", "[unit][data][string]" ) { + SECTION ( "Copy constructor" ) { + string::LinearString < > string; - string.accessComponent < string::GeneralAlphabet > ( ).set( { DefaultSymbolType ( "1" ), DefaultSymbolType ( "2" ), DefaultSymbolType ( "3" ) } ); - string.setContent ( { DefaultSymbolType ( "1" ), DefaultSymbolType ( "2" ), DefaultSymbolType ( "1" ) } ); - string::LinearString < > string2 ( string ); + string.accessComponent < string::GeneralAlphabet > ( ).set( { DefaultSymbolType ( "1" ), DefaultSymbolType ( "2" ), DefaultSymbolType ( "3" ) } ); + string.setContent ( { DefaultSymbolType ( "1" ), DefaultSymbolType ( "2" ), DefaultSymbolType ( "1" ) } ); + string::LinearString < > string2 ( string ); - CPPUNIT_ASSERT ( string == string2 ); + CHECK ( string == string2 ); - string::LinearString < > string3 ( std::move ( string ) ); + string::LinearString < > string3 ( std::move ( string ) ); - CPPUNIT_ASSERT ( string2 == string3 ); -} + CHECK ( string2 == string3 ); + } -void StringTest::testXMLParser ( ) { + SECTION ( "Xml Parser" ) { - string::LinearString < > string; + string::LinearString < > string; - string.accessComponent < string::GeneralAlphabet > ( ).set( { DefaultSymbolType ( "1" ), DefaultSymbolType ( "2" ), DefaultSymbolType ( "3" ) } ); - string.setContent ( { DefaultSymbolType ( "1" ), DefaultSymbolType ( "2" ), DefaultSymbolType ( "1" ) } ); + string.accessComponent < string::GeneralAlphabet > ( ).set( { DefaultSymbolType ( "1" ), DefaultSymbolType ( "2" ), DefaultSymbolType ( "3" ) } ); + string.setContent ( { DefaultSymbolType ( "1" ), DefaultSymbolType ( "2" ), DefaultSymbolType ( "1" ) } ); - { - ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( string ); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + { + ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( string ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - std::cout << tmp << std::endl; + std::cout << tmp << std::endl; - ext::deque < sax::Token > tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - string::LinearString < > string2 = factory::XmlDataFactory::fromTokens ( std::move( tokens2 ) ); + ext::deque < sax::Token > tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + string::LinearString < > string2 = factory::XmlDataFactory::fromTokens ( std::move( tokens2 ) ); - CPPUNIT_ASSERT ( string == string2 ); - } - { - std::string tmp = factory::XmlDataFactory::toString ( string ); - std::cout << tmp << std::endl; - string::LinearString < > string2 = factory::XmlDataFactory::fromString ( tmp ); + CHECK ( string == string2 ); + } + { + std::string tmp = factory::XmlDataFactory::toString ( string ); + std::cout << tmp << std::endl; + string::LinearString < > string2 = factory::XmlDataFactory::fromString ( tmp ); - CPPUNIT_ASSERT ( string == string2 ); + CHECK ( string == string2 ); + } } -} -void StringTest::testStringInMap ( ) { - ext::map < ext::variant < string::Epsilon < >, int >, int > testMap; - ext::variant < string::Epsilon < >, int > epsVar { - string::Epsilon < > { } - }; + SECTION ( "String in map" ) { + ext::map < ext::variant < string::Epsilon < >, int >, int > testMap; + ext::variant < string::Epsilon < >, int > epsVar { + string::Epsilon < > { } + }; - CPPUNIT_ASSERT ( string::Epsilon < >::EPSILON == epsVar.get < string::Epsilon < > > ( ) ); - CPPUNIT_ASSERT ( epsVar.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); + CHECK ( string::Epsilon < >::EPSILON == epsVar.get < string::Epsilon < > > ( ) ); + CHECK ( epsVar.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); - std::pair < ext::variant < string::Epsilon < >, int >, int > epsVarPair = std::make_pair ( epsVar, 10 ); - CPPUNIT_ASSERT ( string::Epsilon < >::EPSILON == epsVarPair.first.get < string::Epsilon < > > ( ) ); - CPPUNIT_ASSERT ( epsVarPair.first.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); + std::pair < ext::variant < string::Epsilon < >, int >, int > epsVarPair = std::make_pair ( epsVar, 10 ); + CHECK ( string::Epsilon < >::EPSILON == epsVarPair.first.get < string::Epsilon < > > ( ) ); + CHECK ( epsVarPair.first.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); - testMap.insert ( std::make_pair ( ext::variant < string::Epsilon < >, int > { string::Epsilon < > { } - }, 10 ) ); - CPPUNIT_ASSERT ( testMap.find ( ext::variant < string::Epsilon < >, int > { string::Epsilon < > { } - } ) != testMap.end ( ) ); + testMap.insert ( std::make_pair ( ext::variant < string::Epsilon < >, int > { string::Epsilon < > { } + }, 10 ) ); + CHECK ( testMap.find ( ext::variant < string::Epsilon < >, int > { string::Epsilon < > { } + } ) != testMap.end ( ) ); - for ( const auto & entry : testMap ) { - CPPUNIT_ASSERT ( entry.first.is < string::Epsilon < > > ( ) ); + for ( const auto & entry : testMap ) { + CHECK ( entry.first.is < string::Epsilon < > > ( ) ); - if ( entry.first.is < string::Epsilon < > > ( ) ) - CPPUNIT_ASSERT ( string::Epsilon < >::EPSILON == entry.first.get < string::Epsilon < > > ( ) ); + if ( entry.first.is < string::Epsilon < > > ( ) ) + CHECK ( string::Epsilon < >::EPSILON == entry.first.get < string::Epsilon < > > ( ) ); - CPPUNIT_ASSERT ( entry.first.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); + CHECK ( entry.first.get < string::Epsilon < > > ( ) == string::Epsilon < >::EPSILON ); + } } -} - -void StringTest::testNormalize ( ) { - string::LinearString < char > s1 ( ext::vector < char > { 'a', 'b' } ); - string::LinearString < > s2 = core::normalize < string::LinearString < char > >::eval ( string::LinearString < char > ( s1 ) ); - std::string tmp1 = factory::XmlDataFactory::toString ( s1 ); - std::cout << tmp1 << std::endl; - string::LinearString < > s1x = factory::XmlDataFactory::fromString ( tmp1 ); + SECTION ( "Normalize" ) { + { + string::LinearString < char > s1 ( ext::vector < char > { 'a', 'b' } ); + string::LinearString < > s2 = core::normalize < string::LinearString < char > >::eval ( string::LinearString < char > ( s1 ) ); - std::string tmp2 = factory::XmlDataFactory::toString ( s2 ); - std::cout << tmp2 << std::endl; - string::LinearString < > s2x = factory::XmlDataFactory::fromString ( tmp2 ); + std::string tmp1 = factory::XmlDataFactory::toString ( s1 ); + std::cout << tmp1 << std::endl; + string::LinearString < > s1x = factory::XmlDataFactory::fromString ( tmp1 ); - CPPUNIT_ASSERT ( s1x == s2x ); -} - -void StringTest::testNormalize2 ( ) { - string::LinearString < object::Object > s1 ( ext::vector < object::Object > { object::Object ( 'a' ), object::Object ( 'b' ) } ); - string::LinearString < > s2 = core::normalize < string::LinearString < object::Object > >::eval ( string::LinearString < object::Object > ( s1 ) ); + std::string tmp2 = factory::XmlDataFactory::toString ( s2 ); + std::cout << tmp2 << std::endl; + string::LinearString < > s2x = factory::XmlDataFactory::fromString ( tmp2 ); - std::string tmp1 = factory::XmlDataFactory::toString ( s1 ); - std::cout << tmp1 << std::endl; - string::LinearString < > s1x = factory::XmlDataFactory::fromString ( tmp1 ); + CHECK ( s1x == s2x ); + } + { + string::LinearString < object::Object > s1 ( ext::vector < object::Object > { object::Object ( 'a' ), object::Object ( 'b' ) } ); + string::LinearString < > s2 = core::normalize < string::LinearString < object::Object > >::eval ( string::LinearString < object::Object > ( s1 ) ); - std::string tmp2 = factory::XmlDataFactory::toString ( s2 ); - std::cout << tmp2 << std::endl; - string::LinearString < > s2x = factory::XmlDataFactory::fromString ( tmp2 ); + std::string tmp1 = factory::XmlDataFactory::toString ( s1 ); + std::cout << tmp1 << std::endl; + string::LinearString < > s1x = factory::XmlDataFactory::fromString ( tmp1 ); - CPPUNIT_ASSERT ( s1 == s1x ); - CPPUNIT_ASSERT ( s1 == s2x ); -} + std::string tmp2 = factory::XmlDataFactory::toString ( s2 ); + std::cout << tmp2 << std::endl; + string::LinearString < > s2x = factory::XmlDataFactory::fromString ( tmp2 ); -void StringTest::testNormalize3 ( ) { - string::LinearString < ext::set < char > > s1 ( ext::vector < ext::set < char > > { ext::set < char > { 'a' }, ext::set < char > { 'b' } } ); - string::LinearString < > s2 = core::normalize < string::LinearString < ext::set < char > > >::eval ( string::LinearString < ext::set < char > > ( s1 ) ); + CHECK ( s1 == s1x ); + CHECK ( s1 == s2x ); + } + { + string::LinearString < ext::set < char > > s1 ( ext::vector < ext::set < char > > { ext::set < char > { 'a' }, ext::set < char > { 'b' } } ); + string::LinearString < > s2 = core::normalize < string::LinearString < ext::set < char > > >::eval ( string::LinearString < ext::set < char > > ( s1 ) ); - std::string tmp1 = factory::XmlDataFactory::toString ( s1 ); - std::cout << tmp1 << std::endl; - string::LinearString < > s1x = factory::XmlDataFactory::fromString ( tmp1 ); + std::string tmp1 = factory::XmlDataFactory::toString ( s1 ); + std::cout << tmp1 << std::endl; + string::LinearString < > s1x = factory::XmlDataFactory::fromString ( tmp1 ); - std::string tmp2 = factory::XmlDataFactory::toString ( s2 ); - std::cout << tmp2 << std::endl; - string::LinearString < > s2x = factory::XmlDataFactory::fromString ( tmp2 ); + std::string tmp2 = factory::XmlDataFactory::toString ( s2 ); + std::cout << tmp2 << std::endl; + string::LinearString < > s2x = factory::XmlDataFactory::fromString ( tmp2 ); - CPPUNIT_ASSERT ( s1x == s2x ); + CHECK ( s1x == s2x ); - string::LinearString < object::Object > ref ( ext::vector < object::Object > { object::Object ( object::AnyObject < ext::set < object::Object > > ( ext::set < object::Object > { object::Object ( object::AnyObject < char > ( 'a' ) ) } ) ), object::Object ( object::AnyObject < ext::set < object::Object > > ( ext::set < object::Object > { object::Object ( object::AnyObject < char > ( 'b' ) ) } ) ) } ); + string::LinearString < object::Object > ref ( ext::vector < object::Object > { object::Object ( object::AnyObject < ext::set < object::Object > > ( ext::set < object::Object > { object::Object ( object::AnyObject < char > ( 'a' ) ) } ) ), object::Object ( object::AnyObject < ext::set < object::Object > > ( ext::set < object::Object > { object::Object ( object::AnyObject < char > ( 'b' ) ) } ) ) } ); - std::cout << s1x << std::endl; - std::cout << ref << std::endl; + std::cout << s1x << std::endl; + std::cout << ref << std::endl; - CPPUNIT_ASSERT ( s1x == ref ); + CHECK ( s1x == ref ); + } + } } diff --git a/alib2data/test-src/string/StringTest.h b/alib2data/test-src/string/StringTest.h deleted file mode 100644 index a3ba48f73e094b77ee3eb4be4f5f35b328691582..0000000000000000000000000000000000000000 --- a/alib2data/test-src/string/StringTest.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef STRING_TEST_H_ -#define STRING_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class StringTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( StringTest ); - CPPUNIT_TEST( testCopyConstruct ); - CPPUNIT_TEST( testXMLParser ); - CPPUNIT_TEST( testStringInMap ); - CPPUNIT_TEST( testNormalize ); - CPPUNIT_TEST( testNormalize2 ); - CPPUNIT_TEST( testNormalize3 ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testCopyConstruct(); - void testXMLParser(); - void testStringInMap(); - void testNormalize(); - void testNormalize2(); - void testNormalize3(); -}; - -#endif // STRING_TEST_H_ diff --git a/alib2data/test-src/tree/PatternTest.cpp b/alib2data/test-src/tree/PatternTest.cpp index f0cf0488e5251b19fefb621722197ccd2c3851a8..11d55fb6ffef6d743d0ace04f571eba0bb9787b8 100644 --- a/alib2data/test-src/tree/PatternTest.cpp +++ b/alib2data/test-src/tree/PatternTest.cpp @@ -1,4 +1,4 @@ -#include "PatternTest.h" +#include <catch2/catch.hpp> #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -21,168 +21,167 @@ #include "alphabet/BarSymbol.h" #include "alphabet/VariablesBarSymbol.h" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( PatternTest, "tree" ); -CPPUNIT_TEST_SUITE_REGISTRATION( PatternTest ); +TEST_CASE ( "Pattern test", "[unit][data][tree]" ) { + SECTION ( "Ranked Pattern Parser" ) { + const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); -void PatternTest::setUp() { -} - -void PatternTest::tearDown() { -} + const common::ranked_symbol < > S (DefaultSymbolType { alphabet::WildcardSymbol {} }, DefaultRankType(0)); + const ext::set<common::ranked_symbol < >> alphabet {a, b, c, S}; -void PatternTest::testRankedPatternParser() { - const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); + ext::tree < common::ranked_symbol < > > node3(c, {}); + ext::tree < common::ranked_symbol < > > node4(S, {}); + ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); + ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); - const common::ranked_symbol < > S (DefaultSymbolType { alphabet::WildcardSymbol {} }, DefaultRankType(0)); - const ext::set<common::ranked_symbol < >> alphabet {a, b, c, S}; + tree::RankedPattern < > tree(S, alphabet, std::move(node1)); - ext::tree < common::ranked_symbol < > > node3(c, {}); - ext::tree < common::ranked_symbol < > > node4(S, {}); - ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); - ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); + std::ostringstream oss; + tree.getContent().nicePrint(oss); + INFO ( "Tree: " << oss.str ( ) ); + CHECK( tree == tree ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - tree::RankedPattern < > tree(S, alphabet, std::move(node1)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + tree::RankedPattern < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( tree == tree ); - tree.getContent().nicePrint(std::cout); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - tree::RankedPattern < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - - CPPUNIT_ASSERT( tree == tree2 ); - std::cout << std::endl; - tree2.getContent().nicePrint(std::cout); - } + oss.str ( "" ); + oss.clear ( ); + tree2.getContent().nicePrint( oss ); + INFO ( "Tree2:" << oss.str ( ) ); + CHECK( tree == tree2 ); + } - const DefaultSymbolType ua = DefaultSymbolType('a'); - const DefaultSymbolType ub = DefaultSymbolType('b'); - const DefaultSymbolType uc = DefaultSymbolType('c'); + const DefaultSymbolType ua = DefaultSymbolType('a'); + const DefaultSymbolType ub = DefaultSymbolType('b'); + const DefaultSymbolType uc = DefaultSymbolType('c'); - const DefaultSymbolType uS { alphabet::WildcardSymbol {} }; - const ext::set<DefaultSymbolType> ualphabet {ua, ub, uc, uS}; + const DefaultSymbolType uS { alphabet::WildcardSymbol {} }; + const ext::set<DefaultSymbolType> ualphabet {ua, ub, uc, uS}; - ext::tree < DefaultSymbolType > unode3(uc, {}); - ext::tree < DefaultSymbolType > unode4(uS, {}); - ext::tree < DefaultSymbolType > unode2(ub, {std::move(unode3)}); - ext::tree < DefaultSymbolType > unode1(ua, {std::move(unode2), std::move(unode4)}); + ext::tree < DefaultSymbolType > unode3(uc, {}); + ext::tree < DefaultSymbolType > unode4(uS, {}); + ext::tree < DefaultSymbolType > unode2(ub, {std::move(unode3)}); + ext::tree < DefaultSymbolType > unode1(ua, {std::move(unode2), std::move(unode4)}); - tree::UnrankedPattern < > tree2(uS, ualphabet, std::move(unode1)); + tree::UnrankedPattern < > tree2(uS, ualphabet, std::move(unode1)); - tree::UnrankedPattern < > tree3 ( tree ); + tree::UnrankedPattern < > tree3 ( tree ); - CPPUNIT_ASSERT(tree3 == tree2); -} + CHECK(tree3 == tree2); + } -void PatternTest::testUnrankedPatternParser() { - const DefaultSymbolType a = DefaultSymbolType('a'); - const DefaultSymbolType b = DefaultSymbolType('b'); - const DefaultSymbolType c = DefaultSymbolType('c'); + SECTION ( "Unranked Pattern Parser" ) { + const DefaultSymbolType a = DefaultSymbolType('a'); + const DefaultSymbolType b = DefaultSymbolType('b'); + const DefaultSymbolType c = DefaultSymbolType('c'); - const DefaultSymbolType S { alphabet::WildcardSymbol {} }; - const ext::set<DefaultSymbolType> alphabet {a, b, c, S}; + const DefaultSymbolType S { alphabet::WildcardSymbol {} }; + const ext::set<DefaultSymbolType> alphabet {a, b, c, S}; - ext::tree < DefaultSymbolType > node3(c, {}); - ext::tree < DefaultSymbolType > node4(S, {}); - ext::tree < DefaultSymbolType > node2(b, {std::move(node3)}); - ext::tree < DefaultSymbolType > node1(a, {std::move(node2), std::move(node4)}); + ext::tree < DefaultSymbolType > node3(c, {}); + ext::tree < DefaultSymbolType > node4(S, {}); + ext::tree < DefaultSymbolType > node2(b, {std::move(node3)}); + ext::tree < DefaultSymbolType > node1(a, {std::move(node2), std::move(node4)}); - tree::UnrankedPattern < > tree(S, alphabet, std::move(node1)); + tree::UnrankedPattern < > tree(S, alphabet, std::move(node1)); - CPPUNIT_ASSERT( tree == tree ); - tree.getContent().nicePrint(std::cout); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + std::ostringstream oss; + tree.getContent().nicePrint(oss); + INFO ( "Tree1: " << oss.str ( ) ); + CHECK( tree == tree ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - tree::UnrankedPattern < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + tree::UnrankedPattern < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( tree == tree2 ); - std::cout << std::endl; - tree2.getContent().nicePrint(std::cout); - } + oss.str ( "" ); + oss.clear ( ); + tree2.getContent().nicePrint ( oss ); + INFO ( "Tree2: " << oss.str ( ) ); + CHECK( tree == tree2 ); + } - const common::ranked_symbol < > ra (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > rb (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > rc (DefaultSymbolType('c'), DefaultRankType(0)); + const common::ranked_symbol < > ra (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > rb (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > rc (DefaultSymbolType('c'), DefaultRankType(0)); - const common::ranked_symbol < > rS { DefaultSymbolType { alphabet::WildcardSymbol {} }, DefaultRankType(0)}; - const ext::set<common::ranked_symbol < >> ralphabet {ra, rb, rc, rS}; + const common::ranked_symbol < > rS { DefaultSymbolType { alphabet::WildcardSymbol {} }, DefaultRankType(0)}; + const ext::set<common::ranked_symbol < >> ralphabet {ra, rb, rc, rS}; - ext::tree < common::ranked_symbol < > > rnode3(rc, {}); - ext::tree < common::ranked_symbol < > > rnode4(rS, {}); - ext::tree < common::ranked_symbol < > > rnode2(rb, {std::move(rnode3)}); - ext::tree < common::ranked_symbol < > > rnode1(ra, {std::move(rnode2), std::move(rnode4)}); + ext::tree < common::ranked_symbol < > > rnode3(rc, {}); + ext::tree < common::ranked_symbol < > > rnode4(rS, {}); + ext::tree < common::ranked_symbol < > > rnode2(rb, {std::move(rnode3)}); + ext::tree < common::ranked_symbol < > > rnode1(ra, {std::move(rnode2), std::move(rnode4)}); - tree::RankedPattern < > tree2(rS, ralphabet, std::move(rnode1)); + tree::RankedPattern < > tree2(rS, ralphabet, std::move(rnode1)); - tree::RankedPattern < > tree3 (tree); + tree::RankedPattern < > tree3 (tree); - CPPUNIT_ASSERT(tree3 == tree2); -} + CHECK(tree3 == tree2); + } -void PatternTest::testPrefixRankedPatternParser() { - const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); + SECTION ( "Prefix Ranked Pattern Parser" ) { + const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); - const common::ranked_symbol < > S (DefaultSymbolType { alphabet::WildcardSymbol {} }, DefaultRankType(0)); - const ext::set<common::ranked_symbol < >> alphabet {a, b, c, S}; + const common::ranked_symbol < > S (DefaultSymbolType { alphabet::WildcardSymbol {} }, DefaultRankType(0)); + const ext::set<common::ranked_symbol < >> alphabet {a, b, c, S}; - ext::tree < common::ranked_symbol < > > node3(c, {}); - ext::tree < common::ranked_symbol < > > node4(S, {}); - ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); - ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); + ext::tree < common::ranked_symbol < > > node3(c, {}); + ext::tree < common::ranked_symbol < > > node4(S, {}); + ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); + ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); - tree::RankedPattern < > pattern(S, alphabet, std::move(node1)); - tree::PrefixRankedPattern < > pattern2(pattern); + tree::RankedPattern < > pattern(S, alphabet, std::move(node1)); + tree::PrefixRankedPattern < > pattern2(pattern); - CPPUNIT_ASSERT( pattern2 == pattern2 ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(pattern2); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( pattern2 == pattern2 ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(pattern2); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - tree::PrefixRankedPattern < > pattern3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + tree::PrefixRankedPattern < > pattern3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( pattern2 == pattern3 ); - std::cout << std::endl; + CHECK( pattern2 == pattern3 ); + } } -} -void PatternTest::testPrefixRankedBarPatternParser() { - const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); + SECTION ( "Prefix Ranked Bar Pattern Parser" ) { + const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); - const common::ranked_symbol < > S (DefaultSymbolType { alphabet::WildcardSymbol {} }, DefaultRankType(0)); - const ext::set<common::ranked_symbol < >> alphabet {a, b, c, S}; + const common::ranked_symbol < > S (DefaultSymbolType { alphabet::WildcardSymbol {} }, DefaultRankType(0)); + const ext::set<common::ranked_symbol < >> alphabet {a, b, c, S}; - ext::tree < common::ranked_symbol < > > node3(c, {}); - ext::tree < common::ranked_symbol < > > node4(S, {}); - ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); - ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); + ext::tree < common::ranked_symbol < > > node3(c, {}); + ext::tree < common::ranked_symbol < > > node4(S, {}); + ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); + ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); - tree::RankedPattern < > pattern(S, alphabet, std::move(node1)); - tree::PrefixRankedBarPattern < > pattern2(alphabet::BarSymbol::instance < DefaultSymbolType > ( ), alphabet::VariablesBarSymbol::instance < common::ranked_symbol < DefaultSymbolType, unsigned > > ( ), pattern); + tree::RankedPattern < > pattern(S, alphabet, std::move(node1)); + tree::PrefixRankedBarPattern < > pattern2(alphabet::BarSymbol::instance < DefaultSymbolType > ( ), alphabet::VariablesBarSymbol::instance < common::ranked_symbol < DefaultSymbolType, unsigned > > ( ), pattern); - CPPUNIT_ASSERT( pattern2 == pattern2 ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(pattern2); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( pattern2 == pattern2 ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(pattern2); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - std::cout << tmp << std::endl << std::endl; + CAPTURE ( tmp ); - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - tree::PrefixRankedBarPattern < > pattern3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + tree::PrefixRankedBarPattern < > pattern3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( pattern2 == pattern3 ); - std::cout << std::endl; + CHECK( pattern2 == pattern3 ); + } } } diff --git a/alib2data/test-src/tree/PatternTest.h b/alib2data/test-src/tree/PatternTest.h deleted file mode 100644 index ee9b57b9f57a17fbe96cbc88bebde3b24929af70..0000000000000000000000000000000000000000 --- a/alib2data/test-src/tree/PatternTest.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef PATTERN_TEST_H_ -#define PATTERN_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class PatternTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( PatternTest ); - CPPUNIT_TEST( testRankedPatternParser ); - CPPUNIT_TEST( testUnrankedPatternParser ); - CPPUNIT_TEST( testPrefixRankedPatternParser ); - CPPUNIT_TEST( testPrefixRankedBarPatternParser ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testRankedPatternParser(); - void testUnrankedPatternParser(); - - void testPrefixRankedPatternParser(); - void testPrefixRankedBarPatternParser(); -}; - -#endif // PATTERN_TEST_H_ diff --git a/alib2data/test-src/tree/TreeTest.cpp b/alib2data/test-src/tree/TreeTest.cpp index ab6d01abbec44bf6324c15bee1c0359a5d3f0ab4..220b9bdbced5192383dee26b901fe94bd122c3c8 100644 --- a/alib2data/test-src/tree/TreeTest.cpp +++ b/alib2data/test-src/tree/TreeTest.cpp @@ -1,4 +1,4 @@ -#include "TreeTest.h" +#include <catch2/catch.hpp> #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -22,16 +22,7 @@ #include "alphabet/WildcardSymbol.h" #include "alphabet/BarSymbol.h" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TreeTest, "tree" ); -CPPUNIT_TEST_SUITE_REGISTRATION( TreeTest ); - -void TreeTest::setUp() { -} - -void TreeTest::tearDown() { -} - -ext::tree < common::ranked_symbol < > > prefixToNode(const std::string & s, int & pos) { +static ext::tree < common::ranked_symbol < > > prefixToNode(const std::string & s, int & pos) { char c = s[pos]; int r = s[pos+1] - '0'; pos += 2; @@ -42,290 +33,292 @@ ext::tree < common::ranked_symbol < > > prefixToNode(const std::string & s, int return ext::tree < common::ranked_symbol < > >(common::ranked_symbol < >(DefaultSymbolType(c), DefaultRankType(r)), std::move(children)); } -void TreeTest::testRankedTreeParser() { -/* - L=(a(2), b(1), c(0)) - - \-1.a(2) - | - |-2.b(1) - | | - | \-3.c(0) - | - \-4.c(0) -*/ - const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); - - const ext::set<common::ranked_symbol < >> alphabet {a, b, c}; - - ext::tree < common::ranked_symbol < > > node3(c, {}); - ext::tree < common::ranked_symbol < > > node4(c, {}); - ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); - ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); - - tree::RankedTree < > tree(alphabet, std::move(node1)); - - CPPUNIT_ASSERT( tree == tree ); - tree.getContent().nicePrint(std::cout); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - tree::RankedTree < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - - CPPUNIT_ASSERT( tree == tree2 ); - std::cout << std::endl; - tree2.getContent().nicePrint(std::cout); +TEST_CASE ( "Trees test", "[unit][data][tree]" ) { + SECTION ( "Ranked Tree Parser" ) { + /* + L=(a(2), b(1), c(0)) + + \-1.a(2) + | + |-2.b(1) + | | + | \-3.c(0) + | + \-4.c(0) + */ + const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); + + const ext::set<common::ranked_symbol < >> alphabet {a, b, c}; + + ext::tree < common::ranked_symbol < > > node3(c, {}); + ext::tree < common::ranked_symbol < > > node4(c, {}); + ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); + ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); + + tree::RankedTree < > tree(alphabet, std::move(node1)); + + CHECK( tree == tree ); + tree.getContent().nicePrint(std::cout); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + tree::RankedTree < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + + CHECK( tree == tree2 ); + std::cout << std::endl; + tree2.getContent().nicePrint(std::cout); + } + + std::string s = "a2a2a2b1a2c0c0c0c0c0"; + int itmp = 0; + ext::tree < common::ranked_symbol < > > node = prefixToNode(s, itmp); + ext::set<common::ranked_symbol < >> al; + for (unsigned i = 0; i < s.length(); i += 2) al.insert(common::ranked_symbol < >(DefaultSymbolType(s[i]), DefaultRankType((int) (s[i+1] - '0')))); + tree::RankedTree < > t(al, std::move(node)); + INFO ( factory::XmlDataFactory::toString(t) ); + + //TODO test it somehow } - std::string s = "a2a2a2b1a2c0c0c0c0c0"; - int itmp = 0; - ext::tree < common::ranked_symbol < > > node = prefixToNode(s, itmp); - ext::set<common::ranked_symbol < >> al; - for (unsigned i = 0; i < s.length(); i += 2) al.insert(common::ranked_symbol < >(DefaultSymbolType(s[i]), DefaultRankType((int) (s[i+1] - '0')))); - tree::RankedTree < > t(al, std::move(node)); - factory::XmlDataFactory::toStdout(t); - - //TODO test it somehow -} - -void TreeTest::testRankedTreeCompare() { -/* - L=(a(2), b(1), c(0)) - - \-1.a(2) - | - |-2.b(1) - | | - | \-3.c(0) - | - \-4.c(0) - - \-5.a(2) - | - |-6.c(0) - | - \-7.b(1) - | - \-8.c(0) -*/ - const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); - - const ext::set<common::ranked_symbol < >> alphabet {a, b, c}; - - ext::tree < common::ranked_symbol < > > node3(c, {}); - ext::tree < common::ranked_symbol < > > node4(c, {}); - ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); - ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); - - ext::tree < common::ranked_symbol < > > node6(c, {}); - ext::tree < common::ranked_symbol < > > node8(c, {}); - ext::tree < common::ranked_symbol < > > node7(b, {std::move(node8)}); - ext::tree < common::ranked_symbol < > > node5(a, {std::move(node6), std::move(node7)}); - - tree::RankedTree < > tree1(alphabet, std::move(node1)); - tree::RankedTree < > tree2(alphabet, std::move(node5)); - - CPPUNIT_ASSERT( tree1 != tree2 ); - CPPUNIT_ASSERT( tree1 < tree2 ); - CPPUNIT_ASSERT( tree2 > tree1 ); - CPPUNIT_ASSERT( !(tree1 > tree2) ); -} + SECTION ( "Ranked Tree Compare" ) { + /* + L=(a(2), b(1), c(0)) + + \-1.a(2) + | + |-2.b(1) + | | + | \-3.c(0) + | + \-4.c(0) + + \-5.a(2) + | + |-6.c(0) + | + \-7.b(1) + | + \-8.c(0) + */ + const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); + + const ext::set<common::ranked_symbol < >> alphabet {a, b, c}; + + ext::tree < common::ranked_symbol < > > node3(c, {}); + ext::tree < common::ranked_symbol < > > node4(c, {}); + ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); + ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); + + ext::tree < common::ranked_symbol < > > node6(c, {}); + ext::tree < common::ranked_symbol < > > node8(c, {}); + ext::tree < common::ranked_symbol < > > node7(b, {std::move(node8)}); + ext::tree < common::ranked_symbol < > > node5(a, {std::move(node6), std::move(node7)}); + + tree::RankedTree < > tree1(alphabet, std::move(node1)); + tree::RankedTree < > tree2(alphabet, std::move(node5)); + + CHECK( tree1 != tree2 ); + CHECK( tree1 < tree2 ); + CHECK( tree2 > tree1 ); + CHECK( !(tree1 > tree2) ); + } -void TreeTest::testRankedTreeSymbolValidityCheck() { - const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); - const common::ranked_symbol < > d (DefaultSymbolType('d'), DefaultRankType(0)); - const common::ranked_symbol < > e (DefaultSymbolType('e'), DefaultRankType(0)); + SECTION ( "Ranked Tree Symbol Validity Check" ) { + const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); + const common::ranked_symbol < > d (DefaultSymbolType('d'), DefaultRankType(0)); + const common::ranked_symbol < > e (DefaultSymbolType('e'), DefaultRankType(0)); - const ext::set<common::ranked_symbol < >> alphabet {a, b, c, e}; + const ext::set<common::ranked_symbol < >> alphabet {a, b, c, e}; - ext::tree < common::ranked_symbol < > > node3(d, {}); - ext::tree < common::ranked_symbol < > > node4(c, {}); - ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); - ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); + ext::tree < common::ranked_symbol < > > node3(d, {}); + ext::tree < common::ranked_symbol < > > node4(c, {}); + ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); + ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); - CPPUNIT_ASSERT_THROW(tree::RankedTree < > (alphabet, std::move(node1)), exception::CommonException); + CHECK_THROWS_AS(tree::RankedTree < > (alphabet, std::move(node1)), exception::CommonException); - ext::tree < common::ranked_symbol < > > node6(e, {}); - ext::tree < common::ranked_symbol < > > node8(c, {}); - ext::tree < common::ranked_symbol < > > node7(b, {std::move(node8)}); - ext::tree < common::ranked_symbol < > > node5(a, {std::move(node6), std::move(node7)}); + ext::tree < common::ranked_symbol < > > node6(e, {}); + ext::tree < common::ranked_symbol < > > node8(c, {}); + ext::tree < common::ranked_symbol < > > node7(b, {std::move(node8)}); + ext::tree < common::ranked_symbol < > > node5(a, {std::move(node6), std::move(node7)}); - tree::RankedTree < > * tree = NULL; - CPPUNIT_ASSERT_NO_THROW(tree = new tree::RankedTree < > (alphabet, std::move(node5))); + tree::RankedTree < > * tree = NULL; + CHECK_NOTHROW(tree = new tree::RankedTree < > (alphabet, std::move(node5))); - delete tree; -} + delete tree; + } -void TreeTest::testUnrankedTreeParser() { -/* - L=(a, b, c) - - \-1.a - | - |-2.b - | | - | \-3.c - | - \-4.c -*/ - const DefaultSymbolType a = DefaultSymbolType('a'); - const DefaultSymbolType b = DefaultSymbolType('b'); - const DefaultSymbolType c = DefaultSymbolType('c'); - - const ext::set<DefaultSymbolType> alphabet {a, b, c}; - - ext::tree < DefaultSymbolType > node3(c, {}); - ext::tree < DefaultSymbolType > node4(c, {}); - ext::tree < DefaultSymbolType > node2(b, {std::move(node3)}); - ext::tree < DefaultSymbolType > node1(a, {std::move(node2), std::move(node4)}); - - tree::UnrankedTree < > tree(alphabet, std::move(node1)); - - CPPUNIT_ASSERT( tree == tree ); - tree.getContent().nicePrint(std::cout); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - std::cout << std::endl << tmp << std::endl << std::endl; - - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - tree::UnrankedTree < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - - CPPUNIT_ASSERT( tree == tree2 ); - std::cout << std::endl; - tree2.getContent().nicePrint(std::cout); + SECTION ( "Unranked Tree Parser" ) { + /* + L=(a, b, c) + + \-1.a + | + |-2.b + | | + | \-3.c + | + \-4.c + */ + const DefaultSymbolType a = DefaultSymbolType('a'); + const DefaultSymbolType b = DefaultSymbolType('b'); + const DefaultSymbolType c = DefaultSymbolType('c'); + + const ext::set<DefaultSymbolType> alphabet {a, b, c}; + + ext::tree < DefaultSymbolType > node3(c, {}); + ext::tree < DefaultSymbolType > node4(c, {}); + ext::tree < DefaultSymbolType > node2(b, {std::move(node3)}); + ext::tree < DefaultSymbolType > node1(a, {std::move(node2), std::move(node4)}); + + tree::UnrankedTree < > tree(alphabet, std::move(node1)); + + CHECK( tree == tree ); + tree.getContent().nicePrint(std::cout); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + std::cout << std::endl << tmp << std::endl << std::endl; + + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + tree::UnrankedTree < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + + CHECK( tree == tree2 ); + std::cout << std::endl; + tree2.getContent().nicePrint(std::cout); + } } -} -void TreeTest::testUnrankedTreeCompare() { -/* - L=(a, b, c) - - \-1.a - | - |-2.b - | | - | \-3.c - | - \-4.c - - \-5.a - | - |-6.c - | - \-7.b - | - \-8.c -*/ - const DefaultSymbolType a = DefaultSymbolType('a'); - const DefaultSymbolType b = DefaultSymbolType('b'); - const DefaultSymbolType c = DefaultSymbolType('c'); - - const ext::set<DefaultSymbolType> alphabet {a, b, c}; - - ext::tree < DefaultSymbolType > node3(c, {}); - ext::tree < DefaultSymbolType > node4(c, {}); - ext::tree < DefaultSymbolType > node2(b, {std::move(node3)}); - ext::tree < DefaultSymbolType > node1(a, {std::move(node2), std::move(node4)}); - - ext::tree < DefaultSymbolType > node6(c, {}); - ext::tree < DefaultSymbolType > node8(c, {}); - ext::tree < DefaultSymbolType > node7(b, {std::move(node8)}); - ext::tree < DefaultSymbolType > node5(a, {std::move(node6), std::move(node7)}); - - tree::UnrankedTree < > tree1(alphabet, std::move(node1)); - tree::UnrankedTree < > tree2(alphabet, std::move(node5)); - - CPPUNIT_ASSERT( tree1 != tree2 ); - CPPUNIT_ASSERT( tree1 < tree2 ); - CPPUNIT_ASSERT( tree2 > tree1 ); - CPPUNIT_ASSERT( !(tree1 > tree2) ); -} + SECTION ( "Unranked Tree Compare" ) { + /* + L=(a, b, c) + + \-1.a + | + |-2.b + | | + | \-3.c + | + \-4.c + + \-5.a + | + |-6.c + | + \-7.b + | + \-8.c + */ + const DefaultSymbolType a = DefaultSymbolType('a'); + const DefaultSymbolType b = DefaultSymbolType('b'); + const DefaultSymbolType c = DefaultSymbolType('c'); + + const ext::set<DefaultSymbolType> alphabet {a, b, c}; + + ext::tree < DefaultSymbolType > node3(c, {}); + ext::tree < DefaultSymbolType > node4(c, {}); + ext::tree < DefaultSymbolType > node2(b, {std::move(node3)}); + ext::tree < DefaultSymbolType > node1(a, {std::move(node2), std::move(node4)}); + + ext::tree < DefaultSymbolType > node6(c, {}); + ext::tree < DefaultSymbolType > node8(c, {}); + ext::tree < DefaultSymbolType > node7(b, {std::move(node8)}); + ext::tree < DefaultSymbolType > node5(a, {std::move(node6), std::move(node7)}); + + tree::UnrankedTree < > tree1(alphabet, std::move(node1)); + tree::UnrankedTree < > tree2(alphabet, std::move(node5)); + + CHECK( tree1 != tree2 ); + CHECK( tree1 < tree2 ); + CHECK( tree2 > tree1 ); + CHECK( !(tree1 > tree2) ); + } -void TreeTest::testUnrankedTreeSymbolValidityCheck() { - const DefaultSymbolType a = DefaultSymbolType('a'); - const DefaultSymbolType b = DefaultSymbolType('b'); - const DefaultSymbolType c = DefaultSymbolType('c'); - const DefaultSymbolType d = DefaultSymbolType('d'); - const DefaultSymbolType e = DefaultSymbolType('e'); + SECTION ( "Unranked Tree Symbol Validity Check" ) { + const DefaultSymbolType a = DefaultSymbolType('a'); + const DefaultSymbolType b = DefaultSymbolType('b'); + const DefaultSymbolType c = DefaultSymbolType('c'); + const DefaultSymbolType d = DefaultSymbolType('d'); + const DefaultSymbolType e = DefaultSymbolType('e'); - const ext::set<DefaultSymbolType> alphabet {a, b, c, e}; + const ext::set<DefaultSymbolType> alphabet {a, b, c, e}; - ext::tree < DefaultSymbolType > node3(d, {}); - ext::tree < DefaultSymbolType > node4(c, {}); - ext::tree < DefaultSymbolType > node2(b, {std::move(node3)}); - ext::tree < DefaultSymbolType > node1(a, {std::move(node2), std::move(node4)}); + ext::tree < DefaultSymbolType > node3(d, {}); + ext::tree < DefaultSymbolType > node4(c, {}); + ext::tree < DefaultSymbolType > node2(b, {std::move(node3)}); + ext::tree < DefaultSymbolType > node1(a, {std::move(node2), std::move(node4)}); - CPPUNIT_ASSERT_THROW(tree::UnrankedTree < > (alphabet, std::move(node1)), exception::CommonException); + CHECK_THROWS_AS(tree::UnrankedTree < > (alphabet, std::move(node1)), exception::CommonException); - ext::tree < DefaultSymbolType > node6(e, {}); - ext::tree < DefaultSymbolType > node8(c, {}); - ext::tree < DefaultSymbolType > node7(b, {std::move(node8)}); - ext::tree < DefaultSymbolType > node5(a, {std::move(node6), std::move(node7)}); + ext::tree < DefaultSymbolType > node6(e, {}); + ext::tree < DefaultSymbolType > node8(c, {}); + ext::tree < DefaultSymbolType > node7(b, {std::move(node8)}); + ext::tree < DefaultSymbolType > node5(a, {std::move(node6), std::move(node7)}); - tree::UnrankedTree < > * tree = NULL; - CPPUNIT_ASSERT_NO_THROW(tree = new tree::UnrankedTree < > (alphabet, std::move(node5))); + tree::UnrankedTree < > * tree = NULL; + CHECK_NOTHROW(tree = new tree::UnrankedTree < > (alphabet, std::move(node5))); - delete tree; -} + delete tree; + } -void TreeTest::testPrefixRankedBarParser() { - const DefaultSymbolType bar{alphabet::BarSymbol{}}; + SECTION ( "Prefix Ranked Bar Parser" ) { + const DefaultSymbolType bar{alphabet::BarSymbol{}}; - const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); + const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); - const ext::set<common::ranked_symbol < >> alphabet {a, b, c}; + const ext::set<common::ranked_symbol < >> alphabet {a, b, c}; - ext::tree < common::ranked_symbol < > > node3(c, {}); - ext::tree < common::ranked_symbol < > > node4(c, {}); - ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); - ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); + ext::tree < common::ranked_symbol < > > node3(c, {}); + ext::tree < common::ranked_symbol < > > node4(c, {}); + ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); + ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); - tree::RankedTree < > tree(alphabet, std::move(node1)); - tree::PrefixRankedBarTree < > tree2(bar, tree); + tree::RankedTree < > tree(alphabet, std::move(node1)); + tree::PrefixRankedBarTree < > tree2(bar, tree); - CPPUNIT_ASSERT( tree2 == tree2 ); - { - ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree2); - std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); + CHECK( tree2 == tree2 ); + { + ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree2); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - std::cout << tmp << std::endl << std::endl; + std::cout << tmp << std::endl << std::endl; - ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); - tree::PrefixRankedBarTree < > tree3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); + tree::PrefixRankedBarTree < > tree3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); - CPPUNIT_ASSERT( tree2 == tree3 ); - std::cout << std::endl; + CHECK( tree2 == tree3 ); + std::cout << std::endl; + } } -} -void TreeTest::testPostfixToPrefix ( ) { - const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); - const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); - const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); + SECTION ( "Postfix to Prefix" ) { + const common::ranked_symbol < > a (DefaultSymbolType('a'), DefaultRankType(2)); + const common::ranked_symbol < > b (DefaultSymbolType('b'), DefaultRankType(1)); + const common::ranked_symbol < > c (DefaultSymbolType('c'), DefaultRankType(0)); - const ext::set<common::ranked_symbol < >> alphabet {a, b, c}; + const ext::set<common::ranked_symbol < >> alphabet {a, b, c}; - ext::tree < common::ranked_symbol < > > node3(c, {}); - ext::tree < common::ranked_symbol < > > node4(c, {}); - ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); - ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); + ext::tree < common::ranked_symbol < > > node3(c, {}); + ext::tree < common::ranked_symbol < > > node4(c, {}); + ext::tree < common::ranked_symbol < > > node2(b, {std::move(node3)}); + ext::tree < common::ranked_symbol < > > node1(a, {std::move(node2), std::move(node4)}); - tree::RankedTree < > tree(alphabet, std::move(node1)); + tree::RankedTree < > tree(alphabet, std::move(node1)); - tree::PrefixRankedTree < > prefixRanked ( tree ); - tree::PostfixRankedTree < > postfixRanked ( tree ); - tree::PrefixRankedTree < > prefixRanked2 ( postfixRanked ); + tree::PrefixRankedTree < > prefixRanked ( tree ); + tree::PostfixRankedTree < > postfixRanked ( tree ); + tree::PrefixRankedTree < > prefixRanked2 ( postfixRanked ); - CPPUNIT_ASSERT ( prefixRanked == prefixRanked2 ); + CHECK ( prefixRanked == prefixRanked2 ); + } } diff --git a/alib2data/test-src/tree/TreeTest.h b/alib2data/test-src/tree/TreeTest.h deleted file mode 100644 index 79638305bc8a98de2bfad57352e5e82d5ed60ff6..0000000000000000000000000000000000000000 --- a/alib2data/test-src/tree/TreeTest.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef TREE_TEST_H_ -#define TREE_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class TreeTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( TreeTest ); - CPPUNIT_TEST( testRankedTreeParser ); - CPPUNIT_TEST( testRankedTreeCompare ); - CPPUNIT_TEST( testRankedTreeSymbolValidityCheck ); - CPPUNIT_TEST( testUnrankedTreeParser ); - CPPUNIT_TEST( testUnrankedTreeCompare ); - CPPUNIT_TEST( testUnrankedTreeSymbolValidityCheck ); - - CPPUNIT_TEST( testPrefixRankedBarParser ); - CPPUNIT_TEST( testPostfixToPrefix ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testRankedTreeParser(); - void testRankedTreeCompare(); - void testRankedTreeSymbolValidityCheck(); - - void testUnrankedTreeParser(); - void testUnrankedTreeCompare(); - void testUnrankedTreeSymbolValidityCheck(); - - void testPrefixRankedBarParser(); - void testPostfixToPrefix ( ); -}; - -#endif // TREE_TEST_H_