From b51357ec0d3c4eb79482bafe9db46cbfc9f752fe Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Mon, 5 Dec 2016 10:14:43 +0100 Subject: [PATCH] enable additional test --- .../regexp/simplify/RegExpOptimizeTest.cpp | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp b/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp index b3b23fcfa2..bc73260e63 100644 --- a/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp +++ b/alib2algo/test-src/regexp/simplify/RegExpOptimizeTest.cpp @@ -70,7 +70,7 @@ void RegExpOptimizeTest::testOptimize() { void RegExpOptimizeTest::testOptimizeTemplated() { regexp::UnboundedRegExpSymbol < char > a ( 'a' ); regexp::UnboundedRegExpSymbol < char > b ( 'b' ); -// regexp::UnboundedRegExpSymbol < char > z ( 'z' ); + regexp::UnboundedRegExpSymbol < char > z ( 'z' ); { regexp::UnboundedRegExpAlternation < char > alt; @@ -140,20 +140,38 @@ void RegExpOptimizeTest::testOptimizeTemplated() { CPPUNIT_ASSERT ( regexpRes == res ); } -/* { - std::string input = "a z + a b* b z"; - regexp::UnboundedRegExp < > regexp( static_cast<const regexp::UnboundedRegExp < > &>( alib::StringDataFactory::fromString<regexp::RegExp>(input).getData() ) ); + { + regexp::UnboundedRegExpConcatenation < char > con1; + con1.appendElement ( a ); + con1.appendElement ( z ); - regexp::UnboundedRegExp < > res = regexp::simplify::RegExpOptimize::optimize(regexp); + regexp::UnboundedRegExpIteration < char > iter { b }; + regexp::UnboundedRegExpConcatenation < char > con2; + con2.appendElement ( a ); + con2.appendElement ( iter ); + con2.appendElement ( b ); + con2.appendElement ( z ); - std::string inputRes = "a b* z"; - regexp::UnboundedRegExp < > regexpRes( static_cast<const regexp::UnboundedRegExp < > &>( alib::StringDataFactory::fromString<regexp::RegExp>(inputRes).getData() ) ); + regexp::UnboundedRegExpAlternation < char > alt1; + alt1.appendElement ( con1 ); + alt1.appendElement ( con2); + + regexp::UnboundedRegExp < char > regexp( regexp::UnboundedRegExpStructure < char > { alt1 } ); + + regexp::UnboundedRegExp < char > res = regexp::simplify::RegExpOptimize::optimize(regexp); + + regexp::UnboundedRegExpConcatenation < char > con3; + con3.appendElement ( a ); + con3.appendElement ( iter ); + con3.appendElement ( z ); + + regexp::UnboundedRegExp < char > regexpRes( regexp::UnboundedRegExpStructure < char > { con3 } ); std::cout << res << std::endl; std::cout << regexpRes << std::endl; CPPUNIT_ASSERT ( regexpRes == res ); - }*/ + } } -- GitLab