diff --git a/alib2str/test-src/automaton/AutomatonTest.cpp b/alib2str/test-src/automaton/AutomatonTest.cpp index 696b84ea4bc1e81b1a15881c611980071c64a1bd..848161b14343d572cc8665ac7d95895c01b3cefe 100644 --- a/alib2str/test-src/automaton/AutomatonTest.cpp +++ b/alib2str/test-src/automaton/AutomatonTest.cpp @@ -1,4 +1,4 @@ -#include "AutomatonTest.h" +#include <catch2/catch.hpp> #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -15,16 +15,7 @@ #include "alphabet/BottomOfTheStackSymbol.h" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( AutomatonTest, "automaton" ); -CPPUNIT_TEST_SUITE_REGISTRATION( AutomatonTest ); - -void AutomatonTest::setUp() { -} - -void AutomatonTest::tearDown() { -} - -void AutomatonTest::FSMStringParserTest() { +TEST_CASE ( "Automaton String Parser", "[unit][str][automaton]" ) { { std::string input = "\r\n" "ENFA a b c d #E\n\r" @@ -51,11 +42,11 @@ void AutomatonTest::FSMStringParserTest() { std::string output = factory::StringDataFactory::toString(automaton); - CPPUNIT_ASSERT( input2 == output ); + CHECK( input2 == output ); automaton::EpsilonNFA < > automaton2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( automaton == automaton2 ); + CHECK( automaton == automaton2 ); } { std::string input = "MISNFA a b c d\n" @@ -69,11 +60,11 @@ void AutomatonTest::FSMStringParserTest() { std::string output = factory::StringDataFactory::toString(automaton); - CPPUNIT_ASSERT( input == output ); + CHECK( input == output ); automaton::MultiInitialStateNFA < > automaton2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( automaton == automaton2 ); + CHECK( automaton == automaton2 ); } { std::string input = "NFA a b c d\n" @@ -87,11 +78,11 @@ void AutomatonTest::FSMStringParserTest() { std::string output = factory::StringDataFactory::toString(automaton); - CPPUNIT_ASSERT( input == output ); + CHECK( input == output ); automaton::NFA < > automaton2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( automaton == automaton2 ); + CHECK( automaton == automaton2 ); } { std::string input = "DFA a b c d\n" @@ -105,13 +96,13 @@ void AutomatonTest::FSMStringParserTest() { std::string output = factory::StringDataFactory::toString(automaton); - std::cout << output << std::endl; + CAPTURE ( output ); - CPPUNIT_ASSERT( input == output ); + CHECK( input == output ); automaton::DFA < > automaton2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( automaton == automaton2 ); + CHECK( automaton == automaton2 ); } } diff --git a/alib2str/test-src/automaton/AutomatonTest.h b/alib2str/test-src/automaton/AutomatonTest.h deleted file mode 100644 index 96c918b9d2a1156a80d34e5e2aa31a8e3643763a..0000000000000000000000000000000000000000 --- a/alib2str/test-src/automaton/AutomatonTest.h +++ /dev/null @@ -1,19 +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( FSMStringParserTest ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void FSMStringParserTest(); -}; - -#endif // AUTOMATON_TEST_H_ diff --git a/alib2str/test-src/container/ContainerTest.cpp b/alib2str/test-src/container/ContainerTest.cpp index 9bc68697c1af533847ca681a91302dd8e8eb07f4..51f3206f2d0e955277bca35f9e559f20e5dc8c35 100644 --- a/alib2str/test-src/container/ContainerTest.cpp +++ b/alib2str/test-src/container/ContainerTest.cpp @@ -1,4 +1,4 @@ -#include "ContainerTest.h" +#include <catch2/catch.hpp> #include "factory/StringDataFactory.hpp" @@ -6,32 +6,24 @@ #include <primitive/string/Integer.h> #include <primitive/string/String.h> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ContainerTest, "automaton" ); -CPPUNIT_TEST_SUITE_REGISTRATION( ContainerTest ); +TEST_CASE ( "Container Test", "[unit][str][container]" ) { + SECTION ( "Variant" ) { + std::string input1 = "1"; + ext::variant < int, std::string > variant1 = factory::StringDataFactory::fromString ( input1 ); -void ContainerTest::setUp() { -} - -void ContainerTest::tearDown() { -} + std::string output1 = factory::StringDataFactory::toString ( variant1 ); -void ContainerTest::VariantTest() { - std::string input1 = "1"; - ext::variant < int, std::string > variant1 = factory::StringDataFactory::fromString ( input1 ); + CAPTURE ( input1, output1 ); + CHECK ( input1 == output1 ); - std::string output1 = factory::StringDataFactory::toString ( variant1 ); + ext::variant < int, std::string > variant2 = factory::StringDataFactory::fromString ( output1 ); - std::cout << "\"" << input1 << "\"" << std::endl << std::endl << "\"" << output1 << "\"" << std::endl; - CPPUNIT_ASSERT( input1 == output1 ); + CHECK ( variant1 == variant2 ); + CHECK ( variant2.template get < int > ( ) == 1 ); - ext::variant < int, std::string > variant2 = factory::StringDataFactory::fromString ( output1 ); + std::string input2 = "aa"; + ext::variant < int, std::string > variant3 = factory::StringDataFactory::fromString ( input2 ); - CPPUNIT_ASSERT( variant1 == variant2 ); - CPPUNIT_ASSERT ( variant2.template get < int > ( ) == 1 ); - - std::string input2 = "aa"; - ext::variant < int, std::string > variant3 = factory::StringDataFactory::fromString ( input2 ); - - CPPUNIT_ASSERT ( variant3.template get < std::string > ( ) == "aa" ); + CHECK ( variant3.template get < std::string > ( ) == "aa" ); + } } - diff --git a/alib2str/test-src/container/ContainerTest.h b/alib2str/test-src/container/ContainerTest.h deleted file mode 100644 index 29e32e1ba52242444d2ef37abb32714c40cb5104..0000000000000000000000000000000000000000 --- a/alib2str/test-src/container/ContainerTest.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CONTAINER_TEST_H_ -#define CONTAINER_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class ContainerTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( ContainerTest ); - CPPUNIT_TEST( VariantTest ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void VariantTest(); -}; - -#endif // CONTAINER_TEST_H_ diff --git a/alib2str/test-src/grammar/GrammarTest.cpp b/alib2str/test-src/grammar/GrammarTest.cpp index da8535ba3dc87b2d2ad2fb6a31747cc2ee1ba10b..84ef7e65d7a78282fa2f05c9ec55f9a69ae54593 100644 --- a/alib2str/test-src/grammar/GrammarTest.cpp +++ b/alib2str/test-src/grammar/GrammarTest.cpp @@ -1,5 +1,6 @@ +#include <catch2/catch.hpp> + #include <alib/list> -#include "GrammarTest.h" #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -24,16 +25,7 @@ #include "primitive/string/Character.h" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GrammarTest, "grammar" ); -CPPUNIT_TEST_SUITE_REGISTRATION( GrammarTest ); - -void GrammarTest::setUp() { -} - -void GrammarTest::tearDown() { -} - -void GrammarTest::stringParserTest() { +TEST_CASE ( "Grammar String Parser", "[unit][str][grammar]" ) { { std::string input1 = "CNF (\n" "{A, B, R, S},\n" @@ -56,13 +48,13 @@ void GrammarTest::stringParserTest() { std::string output1 = factory::StringDataFactory::toString(grammar1); - std::cout << "\"" << input1 << "\"" << std::endl << std::endl << "\"" << output1 << "\"" << std::endl; - CPPUNIT_ASSERT( input1 == output1 ); + CAPTURE ( input1, output1 ); + CHECK( input1 == output1 ); grammar::CNF < > grammar3 = factory::StringDataFactory::fromString (output1); - CPPUNIT_ASSERT( grammar1 == grammar3 ); - CPPUNIT_ASSERT( grammar1 == grammar2 ); + CHECK( grammar1 == grammar3 ); + CHECK( grammar1 == grammar2 ); } { std::string input = "RIGHT_RG (\n" @@ -76,12 +68,12 @@ void GrammarTest::stringParserTest() { std::string output = factory::StringDataFactory::toString(grammar); - std::cout << "\"" << input << "\"" << std::endl << std::endl << "\"" << output << "\"" << std::endl; - CPPUNIT_ASSERT( input == output ); + CAPTURE ( input, output ); + CHECK( input == output ); grammar::RightRG < > grammar2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); } { std::string input = "NON_CONTRACTING_GRAMMAR (\n" @@ -95,12 +87,12 @@ void GrammarTest::stringParserTest() { std::string output = factory::StringDataFactory::toString(grammar); - std::cout << "\"" << input << "\"" << std::endl << std::endl << "\"" << output << "\"" << std::endl; - CPPUNIT_ASSERT( input == output ); + CAPTURE ( input, output ); grammar::NonContractingGrammar < > grammar2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( grammar == grammar2 ); + CAPTURE ( input, output ); + CHECK( grammar == grammar2 ); } { std::string input = "CSG (\n" @@ -114,12 +106,12 @@ void GrammarTest::stringParserTest() { std::string output = factory::StringDataFactory::toString(grammar); - std::cout << "\"" << input << "\"" << std::endl << std::endl << "\"" << output << "\"" << std::endl; - CPPUNIT_ASSERT( input == output ); + CAPTURE ( input, output ); + CHECK( input == output ); grammar::CSG < > grammar2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( grammar == grammar2 ); + CHECK( grammar == grammar2 ); } { grammar::RightRG < char, char > grammar ( 'S' ); @@ -129,7 +121,7 @@ void GrammarTest::stringParserTest() { grammar.addRule ( 'S', 'b' ); std::string output = factory::StringDataFactory::toString(grammar); - std::cout << output << std::endl; + CAPTURE ( output ); std::string ref = "RIGHT_RG (\n" "{S, T},\n" @@ -138,7 +130,7 @@ void GrammarTest::stringParserTest() { " T -> | a S | b},\n" "T)\n"; - CPPUNIT_ASSERT ( output == ref ); + CHECK ( output == ref ); } } diff --git a/alib2str/test-src/grammar/GrammarTest.h b/alib2str/test-src/grammar/GrammarTest.h deleted file mode 100644 index 4ed649f29e6804ff0e38069c508569359a05347c..0000000000000000000000000000000000000000 --- a/alib2str/test-src/grammar/GrammarTest.h +++ /dev/null @@ -1,19 +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( stringParserTest ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void stringParserTest(); -}; - -#endif // GRAMMAR_TEST_H_ diff --git a/alib2str/test-src/main.cpp b/alib2str/test-src/main.cpp index adb58324a109835bfda91d246781668910521414..4ed06df1f7bea8cc18ee161389b9c3e2741b08a0 100644 --- a/alib2str/test-src/main.cpp +++ b/alib2str/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/alib2str/test-src/object/LabelTest.cpp b/alib2str/test-src/object/LabelTest.cpp index aa0550500ac0bc0361674f85cb7b630a3687a78e..783a23a84479b74374ba301144f7ea72e2dcd3cb 100644 --- a/alib2str/test-src/object/LabelTest.cpp +++ b/alib2str/test-src/object/LabelTest.cpp @@ -1,66 +1,58 @@ -#include "LabelTest.h" +#include <catch2/catch.hpp> #include "object/Object.h" #include "factory/StringDataFactory.hpp" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( LabelTest, "label" ); -CPPUNIT_TEST_SUITE_REGISTRATION( LabelTest ); +TEST_CASE ( "Label Test", "[unit][object][label]" ) { + SECTION ( "Equal" ) { + { + std::string input = "1"; + object::Object label = factory::StringDataFactory::fromString (input); -void LabelTest::setUp() { -} - -void LabelTest::tearDown() { -} - -void LabelTest::testEqual() { - { - std::string input = "1"; - object::Object label = factory::StringDataFactory::fromString (input); - - std::string output = factory::StringDataFactory::toString(label); + std::string output = factory::StringDataFactory::toString(label); - CPPUNIT_ASSERT( input == output ); + CHECK( input == output ); - /* object::Object label2 = factory::StringDataFactory::fromString (output); + /* object::Object label2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( label == label2 );*/ - } -/* { - std::string input = "aaaa"; - object::Object label = factory::StringDataFactory::fromString (input); + CHECK( label == label2 );*/ + } + /* { + std::string input = "aaaa"; + object::Object label = factory::StringDataFactory::fromString (input); - std::string output = factory::StringDataFactory::toString(label); + std::string output = factory::StringDataFactory::toString(label); - CPPUNIT_ASSERT( input == output ); + CHECK( input == output ); - object::Object label2 = factory::StringDataFactory::fromString (output); + object::Object label2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( label == label2 ); - } - { - std::string input = "[1, 2, 3]"; - object::Object label = factory::StringDataFactory::fromString (input); + CHECK( label == label2 ); + } + { + std::string input = "[1, 2, 3]"; + object::Object label = factory::StringDataFactory::fromString (input); - std::string output = factory::StringDataFactory::toString(label); + std::string output = factory::StringDataFactory::toString(label); - CPPUNIT_ASSERT( input == output ); + CHECK( input == output ); - object::Object label2 = factory::StringDataFactory::fromString (output); + object::Object label2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( label == label2 ); - } - { - std::string input = "<1, 2>"; - object::Object label = factory::StringDataFactory::fromString (input); + CHECK( label == label2 ); + } + { + std::string input = "<1, 2>"; + object::Object label = factory::StringDataFactory::fromString (input); - std::string output = factory::StringDataFactory::toString(label); + std::string output = factory::StringDataFactory::toString(label); - CPPUNIT_ASSERT( input == output ); + CHECK( input == output ); - object::Object label2 = factory::StringDataFactory::fromString (output); + object::Object label2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( label == label2 ); - }*/ + CHECK( label == label2 ); + }*/ + } } - diff --git a/alib2str/test-src/object/LabelTest.h b/alib2str/test-src/object/LabelTest.h deleted file mode 100644 index 81662bfce82a3135532168e3b2e9ecdfdcad9a0a..0000000000000000000000000000000000000000 --- a/alib2str/test-src/object/LabelTest.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LABEL_TEST_H_ -#define LABEL_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class LabelTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( LabelTest ); - CPPUNIT_TEST( testEqual ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testEqual(); -}; - -#endif // LABEL_TEST_H_ diff --git a/alib2str/test-src/object/ObjectTest.cpp b/alib2str/test-src/object/ObjectTest.cpp index 6fab410c5003dce49093146ef2c8dcc3fd80105e..b8e69d2f4b18b6d0bf6f74b0b905d6e0fa7f08d3 100644 --- a/alib2str/test-src/object/ObjectTest.cpp +++ b/alib2str/test-src/object/ObjectTest.cpp @@ -1,34 +1,26 @@ -#include "ObjectTest.h" +#include <catch2/catch.hpp> #include <object/Object.h> #include <factory/StringDataFactory.hpp> #include <sstream> -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ObjectTest, "label" ); -CPPUNIT_TEST_SUITE_REGISTRATION( ObjectTest ); +TEST_CASE ( "Object Test", "[unit][object][label]" ) { + SECTION ( "Composing" ) { + std::string input = "(1, 2)'"; + object::Object label = factory::StringDataFactory::fromString (input); -void ObjectTest::setUp() { -} - -void ObjectTest::tearDown() { -} + std::string output = factory::StringDataFactory::toString(label); + CHECK( input == output ); -void ObjectTest::testComposing() { - std::string input = "(1, 2)'"; - object::Object label = factory::StringDataFactory::fromString (input); + std::stringstream out; + factory::StringDataFactory::toStream ( label, out ); + std::string output2 = out.str(); + CHECK( input == output2 ); - std::string output = factory::StringDataFactory::toString(label); - CPPUNIT_ASSERT( input == output ); - - std::stringstream out; - factory::StringDataFactory::toStream ( label, out ); - std::string output2 = out.str(); - CPPUNIT_ASSERT( input == output2 ); - - std::stringstream out2; - factory::StringDataFactory::toStream ( label, out2 ); - std::string output3 = out2.str(); - CPPUNIT_ASSERT( input == output3 ); + std::stringstream out2; + factory::StringDataFactory::toStream ( label, out2 ); + std::string output3 = out2.str(); + CHECK( input == output3 ); + } } - diff --git a/alib2str/test-src/object/ObjectTest.h b/alib2str/test-src/object/ObjectTest.h deleted file mode 100644 index 04e4287eaf0e74b4ec7e7c25a3ed7a5f40e389c2..0000000000000000000000000000000000000000 --- a/alib2str/test-src/object/ObjectTest.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LABEL_TEST_H_ -#define LABEL_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -class ObjectTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( ObjectTest ); - CPPUNIT_TEST( testComposing ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testComposing(); -}; - -#endif // LABEL_TEST_H_ diff --git a/alib2str/test-src/object/SymbolTest.cpp b/alib2str/test-src/object/SymbolTest.cpp index 89a41d98d460d61111202ed89b02a08218845f05..f989392d614b058e8e077db76a35019a6596c587 100644 --- a/alib2str/test-src/object/SymbolTest.cpp +++ b/alib2str/test-src/object/SymbolTest.cpp @@ -1,42 +1,30 @@ -#include "SymbolTest.h" +#include <catch2/catch.hpp> #include "object/Object.h" #include "factory/StringDataFactory.hpp" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SymbolTest, "alphabet" ); -CPPUNIT_TEST_SUITE_REGISTRATION( SymbolTest ); +TEST_CASE ( "Symbol Test", "[unit][object][alphabet]" ) { + SECTION ( "Equal" ) { + { + std::string input = "a"; + object::Object symbol = factory::StringDataFactory::fromString (input); -void SymbolTest::setUp() { -} - -void SymbolTest::tearDown() { -} + std::string output = factory::StringDataFactory::toString(symbol); + CHECK( input == output ); -void SymbolTest::testEqual() { - { - std::string input = "a"; - object::Object symbol = factory::StringDataFactory::fromString (input); + object::Object symbol2 = factory::StringDataFactory::fromString (output); + CHECK( symbol == symbol2 ); + } + { + std::string input = "aaaa"; + object::Object symbol = factory::StringDataFactory::fromString (input); - std::string output = factory::StringDataFactory::toString(symbol); + std::string output = factory::StringDataFactory::toString(symbol); + CHECK( input == output ); - CPPUNIT_ASSERT( input == output ); - - object::Object symbol2 = factory::StringDataFactory::fromString (output); - - CPPUNIT_ASSERT( symbol == symbol2 ); - } - { - std::string input = "aaaa"; - object::Object symbol = factory::StringDataFactory::fromString (input); - - std::string output = factory::StringDataFactory::toString(symbol); - - CPPUNIT_ASSERT( input == output ); - - object::Object symbol2 = factory::StringDataFactory::fromString (output); - - CPPUNIT_ASSERT( symbol == symbol2 ); + object::Object symbol2 = factory::StringDataFactory::fromString (output); + CHECK( symbol == symbol2 ); + } } } - diff --git a/alib2str/test-src/object/SymbolTest.h b/alib2str/test-src/object/SymbolTest.h deleted file mode 100644 index 06d084a200d73e81f03f4ac063287b922192c923..0000000000000000000000000000000000000000 --- a/alib2str/test-src/object/SymbolTest.h +++ /dev/null @@ -1,19 +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( testEqual ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testEqual(); -}; - -#endif // SYMBOL_TEST_H_ diff --git a/alib2str/test-src/regexp/RegExpTest.cpp b/alib2str/test-src/regexp/RegExpTest.cpp index d978a3cb3024e4b79327cf66229686eb61c05cd6..310412846e75ac9c7db5514ae7848851408cfd3c 100644 --- a/alib2str/test-src/regexp/RegExpTest.cpp +++ b/alib2str/test-src/regexp/RegExpTest.cpp @@ -1,5 +1,6 @@ +#include <catch2/catch.hpp> + #include <alib/list> -#include "RegExpTest.h" #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -9,52 +10,43 @@ #include "factory/StringDataFactory.hpp" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( RegExpTest, "regexp" ); -CPPUNIT_TEST_SUITE_REGISTRATION( RegExpTest ); +TEST_CASE ( "RegExp Test", "[unit][str][regexp]" ) { + SECTION ( "Equal" ) { + { + std::string input = "#E* #0*"; + regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString (input); -void RegExpTest::setUp() { -} + std::string output = factory::StringDataFactory::toString(regexp); -void RegExpTest::tearDown() { -} + CHECK( input == output ); -void RegExpTest::testEqual() { - { - std::string input = "#E* #0*"; - regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString (input); + regexp::UnboundedRegExp < > regexp2 = factory::StringDataFactory::fromString (output); - std::string output = factory::StringDataFactory::toString(regexp); + CHECK( regexp == regexp2 ); + } + { + std::string input = "a+a"; + regexp::FormalRegExp < > regexp = factory::StringDataFactory::fromString (input); - CPPUNIT_ASSERT( input == output ); + std::string output = factory::StringDataFactory::toString(regexp); - regexp::UnboundedRegExp < > regexp2 = factory::StringDataFactory::fromString (output); + CHECK( input == output ); - CPPUNIT_ASSERT( regexp == regexp2 ); - } - { - std::string input = "a+a"; - regexp::FormalRegExp < > regexp = factory::StringDataFactory::fromString (input); + regexp::FormalRegExp < > regexp2 = factory::StringDataFactory::fromString (output); - std::string output = factory::StringDataFactory::toString(regexp); + CHECK( regexp == regexp2 ); + } + { + std::string input = "a+a (b+a)*"; + regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString (input); - CPPUNIT_ASSERT( input == output ); + std::string output = factory::StringDataFactory::toString(regexp); - regexp::FormalRegExp < > regexp2 = factory::StringDataFactory::fromString (output); + CHECK( input == output ); - CPPUNIT_ASSERT( regexp == regexp2 ); - } - { - std::string input = "a+a (b+a)*"; - regexp::UnboundedRegExp < > regexp = factory::StringDataFactory::fromString (input); + regexp::UnboundedRegExp < > regexp2 = factory::StringDataFactory::fromString (output); - std::string output = factory::StringDataFactory::toString(regexp); - - CPPUNIT_ASSERT( input == output ); - std::cout << output << std::endl; - - regexp::UnboundedRegExp < > regexp2 = factory::StringDataFactory::fromString (output); - - CPPUNIT_ASSERT( regexp == regexp2 ); + CHECK( regexp == regexp2 ); + } } } - diff --git a/alib2str/test-src/regexp/RegExpTest.h b/alib2str/test-src/regexp/RegExpTest.h deleted file mode 100644 index 7e0d2109cf8a2b4b057ddede507f208417388a69..0000000000000000000000000000000000000000 --- a/alib2str/test-src/regexp/RegExpTest.h +++ /dev/null @@ -1,19 +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( testEqual ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testEqual(); -}; - -#endif // REG_EXP_TEST_H_ diff --git a/alib2str/test-src/string/StringTest.cpp b/alib2str/test-src/string/StringTest.cpp index eaa05bfe246005f206f2f589793be93f48629b9e..4502ff64d99695764d941632d226d38e9a2f6b6c 100644 --- a/alib2str/test-src/string/StringTest.cpp +++ b/alib2str/test-src/string/StringTest.cpp @@ -1,5 +1,6 @@ +#include <catch2/catch.hpp> + #include <alib/list> -#include "StringTest.h" #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -9,53 +10,46 @@ #include "factory/StringDataFactory.hpp" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( StringTest, "string" ); -CPPUNIT_TEST_SUITE_REGISTRATION( StringTest ); - -void StringTest::setUp() { -} - -void StringTest::tearDown() { -} - -void StringTest::testEqual() { - { - std::string input = "\"aa\""; - string::LinearString < > string = factory::StringDataFactory::fromString (input); +TEST_CASE ( "String Test", "[unit][str][string]" ) { + SECTION ( "Equal" ) { + { + std::string input = "\"aa\""; + string::LinearString < > string = factory::StringDataFactory::fromString (input); - std::string output = factory::StringDataFactory::toString(string); + std::string output = factory::StringDataFactory::toString(string); - CPPUNIT_ASSERT( input == output ); + CAPTURE ( input, output ); + CHECK( input == output ); - string::LinearString < > string2 = factory::StringDataFactory::fromString (output); + string::LinearString < > string2 = factory::StringDataFactory::fromString (output); - CPPUNIT_ASSERT( string == string2 ); - } - { - std::string input = "\"aaaa aaa\""; - string::LinearString < > string = factory::StringDataFactory::fromString (input); + CHECK( string == string2 ); + } + { + std::string input = "\"aaaa aaa\""; + string::LinearString < > string = factory::StringDataFactory::fromString (input); - std::string output = factory::StringDataFactory::toString(string); + std::string output = factory::StringDataFactory::toString(string); - std::cout << output << std::endl; + CAPTURE ( input, output ); + CHECK( input == output ); - CPPUNIT_ASSERT( input == output ); + string::LinearString < > string2 = factory::StringDataFactory::fromString (output); - string::LinearString < > string2 = factory::StringDataFactory::fromString (output); + CHECK( string == string2 ); + } + { + std::string input = "#E"; + string::Epsilon < > string = factory::StringDataFactory::fromString (input); - CPPUNIT_ASSERT( string == string2 ); - } - { - std::string input = "#E"; - string::Epsilon < > string = factory::StringDataFactory::fromString (input); + std::string output = factory::StringDataFactory::toString(string); - std::string output = factory::StringDataFactory::toString(string); + CAPTURE ( input, output ); + CHECK( input == output ); - CPPUNIT_ASSERT( input == output ); + string::Epsilon < > string2 = factory::StringDataFactory::fromString (output); - string::Epsilon < > string2 = factory::StringDataFactory::fromString (output); - - CPPUNIT_ASSERT( string == string2 ); + CHECK ( string == string2 ); + } } } - diff --git a/alib2str/test-src/string/StringTest.h b/alib2str/test-src/string/StringTest.h deleted file mode 100644 index 4687ee9ce5379711eb5e2bb5ee9f2fa15b6c9c12..0000000000000000000000000000000000000000 --- a/alib2str/test-src/string/StringTest.h +++ /dev/null @@ -1,19 +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( testEqual ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testEqual(); -}; - -#endif // STRING_TEST_H_ diff --git a/alib2str/test-src/tree/TreeTest.cpp b/alib2str/test-src/tree/TreeTest.cpp index e6b32974e440466f5f52424bbc2109f0724bb772..e2c2f8246fda350c6c4e2d8366ef41a5d1232580 100644 --- a/alib2str/test-src/tree/TreeTest.cpp +++ b/alib2str/test-src/tree/TreeTest.cpp @@ -1,5 +1,6 @@ +#include <catch2/catch.hpp> + #include <alib/list> -#include "TreeTest.h" #include "sax/SaxParseInterface.h" #include "sax/SaxComposeInterface.h" @@ -12,90 +13,85 @@ #include "factory/StringDataFactory.hpp" -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION ( TreeTest, "tree" ); -CPPUNIT_TEST_SUITE_REGISTRATION ( TreeTest ); +TEST_CASE ( "Tree Test", "[unit][str][tree]" ) { + SECTION ( "Equal" ) { + { + std::string input = "RANKED_TREE a 0"; + tree::RankedTree < > tree = factory::StringDataFactory::fromString ( input ); -void TreeTest::setUp ( ) { -} + std::string output = factory::StringDataFactory::toString ( tree ); -void TreeTest::tearDown ( ) { -} + CAPTURE ( input, output ); + CHECK ( input == output ); -void TreeTest::testEqual ( ) { - { - std::string input = "RANKED_TREE a 0"; - tree::RankedTree < > tree = factory::StringDataFactory::fromString ( input ); + tree::RankedTree < > tree2 = factory::StringDataFactory::fromString ( output ); - std::string output = factory::StringDataFactory::toString ( tree ); + CHECK ( tree == tree2 ); + } + { + std::string input = "UNRANKED_TREE a |"; + tree::UnrankedTree < > tree = factory::StringDataFactory::fromString ( input ); - std::cout << input << std::endl; - std::cout << output << std::endl; - CPPUNIT_ASSERT ( input == output ); + std::string output = factory::StringDataFactory::toString ( tree ); - tree::RankedTree < > tree2 = factory::StringDataFactory::fromString ( output ); + CAPTURE ( input, output ); + CHECK ( input == output ); - CPPUNIT_ASSERT ( tree == tree2 ); - } - { - std::string input = "UNRANKED_TREE a |"; - tree::UnrankedTree < > tree = factory::StringDataFactory::fromString ( input ); + tree::UnrankedTree < > tree2 = factory::StringDataFactory::fromString ( output ); - std::string output = factory::StringDataFactory::toString ( tree ); + CHECK ( tree == tree2 ); + } + { + std::string input = "RANKED_TREE a 2 a 0 a 1 a 0"; + tree::RankedTree < > tree = factory::StringDataFactory::fromString ( input ); - CPPUNIT_ASSERT ( input == output ); + std::string output = factory::StringDataFactory::toString ( tree ); - tree::UnrankedTree < > tree2 = factory::StringDataFactory::fromString ( output ); + CAPTURE ( input, output ); + CHECK ( input == output ); - CPPUNIT_ASSERT ( tree == tree2 ); - } - { - std::string input = "RANKED_TREE a 2 a 0 a 1 a 0"; - tree::RankedTree < > tree = factory::StringDataFactory::fromString ( input ); + tree::RankedTree < > tree2 = factory::StringDataFactory::fromString ( output ); - std::string output = factory::StringDataFactory::toString ( tree ); + CHECK ( tree == tree2 ); + } + { + std::string input = "UNRANKED_TREE a a | a a | | |"; + tree::UnrankedTree < > tree = factory::StringDataFactory::fromString ( input ); - CPPUNIT_ASSERT ( input == output ); + std::string output = factory::StringDataFactory::toString ( tree ); - tree::RankedTree < > tree2 = factory::StringDataFactory::fromString ( output ); + CAPTURE ( input, output ); + CHECK ( input == output ); - CPPUNIT_ASSERT ( tree == tree2 ); - } - { - std::string input = "UNRANKED_TREE a a | a a | | |"; - tree::UnrankedTree < > tree = factory::StringDataFactory::fromString ( input ); + tree::UnrankedTree < > tree2 = factory::StringDataFactory::fromString ( output ); - std::string output = factory::StringDataFactory::toString ( tree ); + CHECK ( tree == tree2 ); + } + { + std::string input = "RANKED_PATTERN a 2 #S a 1 a 0"; + tree::RankedPattern < > tree = factory::StringDataFactory::fromString ( input ); - CPPUNIT_ASSERT ( input == output ); + std::string output = factory::StringDataFactory::toString ( tree ); - tree::UnrankedTree < > tree2 = factory::StringDataFactory::fromString ( output ); + CAPTURE ( input, output ); + CHECK ( input == output ); - CPPUNIT_ASSERT ( tree == tree2 ); - } - { - std::string input = "RANKED_PATTERN a 2 #S a 1 a 0"; - tree::RankedPattern < > tree = factory::StringDataFactory::fromString ( input ); - - std::string output = factory::StringDataFactory::toString ( tree ); - - std::cout << output << std::endl; - CPPUNIT_ASSERT ( input == output ); + tree::RankedPattern < > tree2 = factory::StringDataFactory::fromString ( output ); - tree::RankedPattern < > tree2 = factory::StringDataFactory::fromString ( output ); - - CPPUNIT_ASSERT ( tree == tree2 ); - } - { - std::string input = "UNRANKED_PATTERN a #S | a a | | |"; - tree::UnrankedPattern < > tree = factory::StringDataFactory::fromString ( input ); + CHECK ( tree == tree2 ); + } + { + std::string input = "UNRANKED_PATTERN a #S | a a | | |"; + tree::UnrankedPattern < > tree = factory::StringDataFactory::fromString ( input ); - std::string output = factory::StringDataFactory::toString ( tree ); + std::string output = factory::StringDataFactory::toString ( tree ); - std::cout << output << std::endl; - CPPUNIT_ASSERT ( input == output ); + CAPTURE ( input, output ); + CHECK ( input == output ); - tree::UnrankedPattern < > tree2 = factory::StringDataFactory::fromString ( output ); + tree::UnrankedPattern < > tree2 = factory::StringDataFactory::fromString ( output ); - CPPUNIT_ASSERT ( tree == tree2 ); + CHECK ( tree == tree2 ); + } } } diff --git a/alib2str/test-src/tree/TreeTest.h b/alib2str/test-src/tree/TreeTest.h deleted file mode 100644 index 96e21197ccba14bb349d6501665b9cedf1af5326..0000000000000000000000000000000000000000 --- a/alib2str/test-src/tree/TreeTest.h +++ /dev/null @@ -1,18 +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 ( testEqual ); - CPPUNIT_TEST_SUITE_END ( ); - -public: - void setUp ( ); - void tearDown ( ); - - void testEqual ( ); -}; - -#endif // TREE_TEST_H_