diff --git a/alib2data/src/regexp/formal/FormalRegExpAlternation.cpp b/alib2data/src/regexp/formal/FormalRegExpAlternation.cpp index a7dbf0cfb728fb3e723d1188aee82d3c1bb87837..d01a6a95083d90e667205e15a9423759078c50f7 100644 --- a/alib2data/src/regexp/formal/FormalRegExpAlternation.cpp +++ b/alib2data/src/regexp/formal/FormalRegExpAlternation.cpp @@ -142,12 +142,12 @@ bool FormalRegExpAlternation::operator>(const FormalRegExpElement& other) const bool FormalRegExpAlternation::operator<(const FormalRegExpAlternation& other) const { - if(this->left == other.left) return this->right < other.right; - return this->left < other.left; + if(*left == *other.left) return *right < *other.right; + return *left < *other.left; } bool FormalRegExpAlternation::operator==(const FormalRegExpAlternation& other) const { - return this->left == other.left && this->right == other.right; + return *left == *other.left && *right == *other.right; } void FormalRegExpAlternation::operator>>(std::ostream& out) const { diff --git a/alib2data/src/regexp/formal/FormalRegExpConcatenation.cpp b/alib2data/src/regexp/formal/FormalRegExpConcatenation.cpp index 41154f6e3cc0c3e964277b0bebf660d4409d7d65..07c1b4327f237b5629f638640e1c73f03d029eb8 100644 --- a/alib2data/src/regexp/formal/FormalRegExpConcatenation.cpp +++ b/alib2data/src/regexp/formal/FormalRegExpConcatenation.cpp @@ -141,12 +141,12 @@ bool FormalRegExpConcatenation::operator>(const FormalRegExpElement& other) cons bool FormalRegExpConcatenation::operator<(const FormalRegExpConcatenation& other) const { - if(this->left == other.left) return this->right < other.right; - return this->left < other.left; + if(*left == *other.left) return *right < *other.right; + return *left < *other.left; } bool FormalRegExpConcatenation::operator==(const FormalRegExpConcatenation& other) const { - return this->left == other.left && this->right == other.right; + return *left == *other.left && *right == *other.right; } void FormalRegExpConcatenation::operator>>(std::ostream& out) const { diff --git a/alib2data/src/regexp/formal/FormalRegExpIteration.cpp b/alib2data/src/regexp/formal/FormalRegExpIteration.cpp index 6ee36586d2c4823c93e595813bf536f16d3b7fa9..ea044dc85cb0e4005a38e32dbfc7ede38486e2c9 100644 --- a/alib2data/src/regexp/formal/FormalRegExpIteration.cpp +++ b/alib2data/src/regexp/formal/FormalRegExpIteration.cpp @@ -106,11 +106,11 @@ bool FormalRegExpIteration::operator>(const FormalRegExpElement& other) const { } bool FormalRegExpIteration::operator<(const FormalRegExpIteration& other) const { - return *(this->element) < *(other.element); + return *element < *other.element; } bool FormalRegExpIteration::operator==(const FormalRegExpIteration& other) const { - return *(this->element) == *(other.element); + return *element == *other.element; } void FormalRegExpIteration::operator>>(std::ostream& out) const { diff --git a/alib2data/test-src/regexp/RegExpTest.cpp b/alib2data/test-src/regexp/RegExpTest.cpp index bcc8c4e2ea2decaaed338bc037e5d1c244fff761..3fafc00927d0fd4f050e690c9c59f35f74743806 100644 --- a/alib2data/test-src/regexp/RegExpTest.cpp +++ b/alib2data/test-src/regexp/RegExpTest.cpp @@ -24,30 +24,54 @@ void RegExpTest::tearDown() { } void RegExpTest::testCopyConstruct() { - regexp::UnboundedRegExp regexp; - regexp.setAlphabet({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}); - regexp::UnboundedRegExpSymbol l1 = regexp::UnboundedRegExpSymbol("1"); - regexp::UnboundedRegExpSymbol l2 = regexp::UnboundedRegExpSymbol("2"); + { + regexp::UnboundedRegExp regexp; + regexp.setAlphabet({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}); + regexp::UnboundedRegExpSymbol l1 = regexp::UnboundedRegExpSymbol("1"); + regexp::UnboundedRegExpSymbol l2 = regexp::UnboundedRegExpSymbol("2"); - regexp::UnboundedRegExpConcatenation con = regexp::UnboundedRegExpConcatenation(); - con.appendElement(l1); - con.appendElement(l2); + regexp::UnboundedRegExpConcatenation con = regexp::UnboundedRegExpConcatenation(); + con.appendElement(l1); + con.appendElement(l2); - regexp::UnboundedRegExpIteration ite = regexp::UnboundedRegExpIteration(l1); + regexp::UnboundedRegExpIteration ite = regexp::UnboundedRegExpIteration(l1); - regexp::UnboundedRegExpAlternation alt = regexp::UnboundedRegExpAlternation(); - alt.appendElement(con); - alt.appendElement(ite); + regexp::UnboundedRegExpAlternation alt = regexp::UnboundedRegExpAlternation(); + alt.appendElement(con); + alt.appendElement(ite); - regexp.setRegExp(alt); + regexp.setRegExp(alt); - regexp::UnboundedRegExp regexp2(regexp); + regexp::UnboundedRegExp regexp2(regexp); - CPPUNIT_ASSERT( regexp == regexp2 ); + CPPUNIT_ASSERT( regexp == regexp2 ); - regexp::UnboundedRegExp regexp3(std::move(regexp)); + regexp::UnboundedRegExp regexp3(std::move(regexp)); - CPPUNIT_ASSERT( regexp2 == regexp3 ); + CPPUNIT_ASSERT( regexp2 == regexp3 ); + } + { + regexp::FormalRegExp regexp; + regexp.setAlphabet({alphabet::symbolFrom("1"), alphabet::symbolFrom("2"), alphabet::symbolFrom("3")}); + regexp::FormalRegExpSymbol l1 = regexp::FormalRegExpSymbol("1"); + regexp::FormalRegExpSymbol l2 = regexp::FormalRegExpSymbol("2"); + + regexp::FormalRegExpConcatenation con = regexp::FormalRegExpConcatenation(l1, l2); + + regexp::FormalRegExpIteration ite = regexp::FormalRegExpIteration(l1); + + regexp::FormalRegExpAlternation alt = regexp::FormalRegExpAlternation(con, ite); + + regexp.setRegExp(alt); + + regexp::FormalRegExp regexp2(regexp); + + CPPUNIT_ASSERT( regexp == regexp2 ); + + regexp::FormalRegExp regexp3(std::move(regexp)); + + CPPUNIT_ASSERT( regexp2 == regexp3 ); + } } void RegExpTest::testEqual() {