From 59fde8436072bd9bdad846a267af3eef9520ce49 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Mon, 19 Dec 2016 15:22:59 +0100 Subject: [PATCH] use default data types in regexp tests --- .../test-src/regexp/simplify/RegExpOptimizeTest.cpp | 2 +- .../regexp/transform/RegExpConcatenateTest.cpp | 4 ++-- .../regexp/transform/RegExpDerivationTest.cpp | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp b/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp index bc73260e63..4343bc21bf 100644 --- a/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp +++ b/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp @@ -29,7 +29,7 @@ void RegExpOptimizeTest::testOptimize() { regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize(regexp); std::string inputRes = "a"; - regexp::UnboundedRegExp < > regexpRes( static_cast<const regexp::UnboundedRegExp < > &>( alib::StringDataFactory::fromString<regexp::RegExp>(inputRes).getData() ) ); + regexp::UnboundedRegExp < > regexpRes( static_cast<const regexp::UnboundedRegExp < DefaultSymbolType > &>( alib::StringDataFactory::fromString<regexp::RegExp>(inputRes).getData() ) ); std::cout << res << std::endl; std::cout << regexpRes << std::endl; diff --git a/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp b/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp index 6c5cf4ab83..0dbfd78d00 100644 --- a/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp +++ b/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp @@ -35,7 +35,7 @@ void RegExpConcatenateTest::testRegExpConcatenate() { std::string input1 = "(#E a b)"; regexp::RegExp re1 = alib::StringDataFactory::fromString<regexp::RegExp>(input1); - regexp::RegExp re2(regexp::FormalRegExp < > (regexp::FormalRegExpStructure < alphabet::Symbol > (regexp::FormalRegExpConcatenation < alphabet::Symbol > (regexp::FormalRegExpEmpty < alphabet::Symbol > {}, regexp::FormalRegExpEpsilon < alphabet::Symbol > {})))); + regexp::RegExp re2(regexp::FormalRegExp < > (regexp::FormalRegExpStructure < DefaultSymbolType > (regexp::FormalRegExpConcatenation < DefaultSymbolType > (regexp::FormalRegExpEmpty < DefaultSymbolType > {}, regexp::FormalRegExpEpsilon < DefaultSymbolType > {})))); regexp::RegExp re = regexp::RegExpConcatenate::concatenate(re1, re2); @@ -45,7 +45,7 @@ void RegExpConcatenateTest::testRegExpConcatenate() { CPPUNIT_ASSERT(re == rer); } { - regexp::RegExp re1(regexp::FormalRegExp < > (regexp::FormalRegExpStructure < alphabet::Symbol > (regexp::FormalRegExpConcatenation < alphabet::Symbol > (regexp::FormalRegExpEmpty < alphabet::Symbol > {}, regexp::FormalRegExpEpsilon < alphabet::Symbol > {})))); + regexp::RegExp re1(regexp::FormalRegExp < > (regexp::FormalRegExpStructure < DefaultSymbolType > (regexp::FormalRegExpConcatenation < DefaultSymbolType > (regexp::FormalRegExpEmpty < DefaultSymbolType > {}, regexp::FormalRegExpEpsilon < DefaultSymbolType > {})))); std::string input2 = "(#E a b)"; regexp::RegExp re2 = alib::StringDataFactory::fromString<regexp::RegExp>(input2); diff --git a/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp b/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp index 84beecdfe0..e45ed7a803 100644 --- a/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp +++ b/alib2algo/test-src/regexp/transform/RegExpDerivationTest.cpp @@ -4,6 +4,7 @@ #include <string/String.h> #include <factory/StringDataFactory.hpp> +#include "factory/XmlDataFactory.hpp" #define CPPUNIT_IMPLY(x, y) CPPUNIT_ASSERT(!(x) || (y)) @@ -32,9 +33,15 @@ void RegExpDerivationTest::testRegExpDerivation() { } void RegExpDerivationTest::ExecSingleTest(std::string regexp_str, std::string string_str, std::string result) { - regexp::RegExp regexp = alib::StringDataFactory::fromString<regexp::RegExp>(regexp_str); + regexp::RegExp regexp0 = alib::StringDataFactory::fromString<regexp::RegExp>(regexp_str); + std::deque<sax::Token> tokens = alib::XmlDataFactory::toTokens(regexp0); + regexp::RegExp regexp = alib::XmlDataFactory::fromTokens<regexp::RegExp>(std::move(tokens)); - string::LinearString < > string = static_cast<const string::LinearString < >&>(alib::StringDataFactory::fromString<string::String>("\"" + string_str + "\"").getData()); + string::String string0 = alib::StringDataFactory::fromString<string::String>("\"" + string_str + "\""); + std::deque<sax::Token> tokens2 = alib::XmlDataFactory::toTokens(string0); + string::String string1 = alib::XmlDataFactory::fromTokens<string::String>(std::move(tokens2)); + + string::LinearString < > string = static_cast<const string::LinearString < >&>(string1.getData()); std::cout << alib::StringDataFactory::toString<regexp::RegExp>(regexp::RegExpDerivation::derivation(regexp, string)) << " == " << std::endl << result << std::endl << std::endl; -- GitLab