From 1a96c3ec72f77185969f8ebdeb05327e2f58487f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 2 Sep 2016 18:27:00 +0200 Subject: [PATCH] Added test covering removal of double negations. --- src/plasp/pddl/expressions/Not.cpp | 5 ++++- tests/TestPDDLNormalization.cpp | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/TestPDDLNormalization.cpp diff --git a/src/plasp/pddl/expressions/Not.cpp b/src/plasp/pddl/expressions/Not.cpp index 72efe5b..0190d0b 100644 --- a/src/plasp/pddl/expressions/Not.cpp +++ b/src/plasp/pddl/expressions/Not.cpp @@ -52,7 +52,10 @@ ExpressionPointer Not::normalize() { auto &argument = dynamic_cast(*m_argumentStorage); - return std::move(argument.m_argumentStorage); + auto normalized = std::move(argument.m_argumentStorage); + normalized->normalize(); + + return normalized; } auto normalizedArgument = m_argumentStorage->normalize(); diff --git a/tests/TestPDDLNormalization.cpp b/tests/TestPDDLNormalization.cpp new file mode 100644 index 0000000..3b679ea --- /dev/null +++ b/tests/TestPDDLNormalization.cpp @@ -0,0 +1,23 @@ +#include + +#include +#include + +using namespace plasp::pddl; + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +TEST(PDDLNormalizationTests, DoubleNegation) +{ + auto n1 = std::make_unique(); + auto n2 = std::make_unique(); + auto u = std::make_unique(); + const auto up = u.get(); + + n2->setArgument(std::move(u)); + n1->setArgument(std::move(n2)); + + auto normalized = n1->normalize(); + + ASSERT_EQ(normalized.get(), up); +}