Switched from Google Test to Catch.

This commit is contained in:
Patrick Lühne 2016-10-08 16:03:14 +02:00
parent a163278fb5
commit d4faaf428c
10 changed files with 433 additions and 438 deletions

7
.gitmodules vendored
View File

@ -1,4 +1,3 @@
[submodule "tests/googletest"]
path = tests/googletest
url = https://github.com/google/googletest.git
ignore = dirty
[submodule "tests/catch"]
path = tests/catch
url = https://github.com/philsquared/Catch.git

View File

@ -2,18 +2,13 @@ set(target tests)
file(GLOB core_sources "*.cpp")
add_subdirectory(googletest)
include_directories(
${gtest_SOURCE_DIR}/include
${gtest_SOURCE_DIR}
${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include
catch/single_include
)
set(libraries
gtest_main
gtest
${Boost_LIBRARIES}
plasp
)
@ -22,7 +17,6 @@ file(COPY data DESTINATION ${CMAKE_BINARY_DIR})
add_executable(${target} ${core_sources})
target_link_libraries(${target} ${libraries})
add_test(tests ${core_sources})
add_custom_target(run-tests
COMMAND ${CMAKE_BINARY_DIR}/bin/tests

View File

@ -1,4 +1,4 @@
#include <gtest/gtest.h>
#include <catch.hpp>
#include <plasp/pddl/expressions/And.h>
#include <plasp/pddl/expressions/Dummy.h>
@ -10,7 +10,7 @@ using namespace plasp::pddl;
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLNormalizationTests, Reduce)
TEST_CASE("[PDDL normalization] PDDL expressions are correctly reduced", "[PDDL normalization]")
{
auto n1 = expressions::NotPointer(new expressions::Not);
auto n2 = expressions::NotPointer(new expressions::Not);
@ -33,12 +33,12 @@ TEST(PDDLNormalizationTests, Reduce)
std::stringstream output;
n1->reduced()->print(output);
ASSERT_EQ(output.str(), "(not (not (and (or (or (not (a)) (b)) (c)) (d))))");
REQUIRE(output.str() == "(not (not (and (or (or (not (a)) (b)) (c)) (d))))");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLNormalizationTests, Simplify)
TEST_CASE("[PDDL normalization] PDDL expressions are correctly simplified", "[PDDL normalization]")
{
auto a1 = expressions::AndPointer(new expressions::And);
auto a2 = expressions::AndPointer(new expressions::And);
@ -63,12 +63,12 @@ TEST(PDDLNormalizationTests, Simplify)
std::stringstream output;
a1->simplified()->print(output);
ASSERT_EQ(output.str(), "(and (a) (b) (c) (d) (or (e) (f) (g) (h)))");
REQUIRE(output.str() == "(and (a) (b) (c) (d) (or (e) (f) (g) (h)))");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLNormalizationTests, Implication)
TEST_CASE("[PDDL normalization] Implications are correctly replaced", "[PDDL normalization]")
{
auto i = expressions::ImplyPointer(new expressions::Imply);
@ -78,12 +78,12 @@ TEST(PDDLNormalizationTests, Implication)
std::stringstream output;
i->normalized()->print(output);
ASSERT_EQ(output.str(), "(or (not (a)) (b))");
REQUIRE(output.str() == "(or (not (a)) (b))");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLNormalizationTests, DoubleNegation)
TEST_CASE("[PDDL normalization] Double negations are correctly replaced", "[PDDL normalization]")
{
auto n1 = expressions::NotPointer(new expressions::Not);
auto n2 = expressions::NotPointer(new expressions::Not);
@ -94,12 +94,12 @@ TEST(PDDLNormalizationTests, DoubleNegation)
std::stringstream output;
n1->normalized()->print(output);
ASSERT_EQ(output.str(), "(a)");
REQUIRE(output.str() == "(a)");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLNormalizationTests, DeMorganNegativeConjunction)
TEST_CASE("[PDDL normalization] De Morgans rule is correctly applied to negative conjunctions", "[PDDL normalization]")
{
auto a = expressions::AndPointer(new expressions::And);
a->addArgument(new expressions::Dummy("a"));
@ -112,12 +112,12 @@ TEST(PDDLNormalizationTests, DeMorganNegativeConjunction)
std::stringstream output;
n->normalized()->print(output);
ASSERT_EQ(output.str(), "(or (not (a)) (not (b)) (not (c)))");
REQUIRE(output.str() == "(or (not (a)) (not (b)) (not (c)))");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLNormalizationTests, DeMorganNegativeDisjunction)
TEST_CASE("[PDDL normalization] De Morgans rule is correctly applied to negative disjunctions", "[PDDL normalization]")
{
auto a = expressions::OrPointer(new expressions::Or);
a->addArgument(new expressions::Dummy("a"));
@ -130,12 +130,12 @@ TEST(PDDLNormalizationTests, DeMorganNegativeDisjunction)
std::stringstream output;
n->normalized()->print(output);
ASSERT_EQ(output.str(), "(and (not (a)) (not (b)) (not (c)))");
REQUIRE(output.str() == "(and (not (a)) (not (b)) (not (c)))");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLNormalizationTests, DoubleNegationInner)
TEST_CASE("[PDDL normalization] Expressions inside double negations are also normalized", "[PDDL normalization]")
{
auto n1 = expressions::NotPointer(new expressions::Not);
auto n2 = expressions::NotPointer(new expressions::Not);
@ -153,5 +153,5 @@ TEST(PDDLNormalizationTests, DoubleNegationInner)
std::stringstream output;
n1->normalized()->print(output);
ASSERT_EQ(output.str(), "(or (not (a)) (not (b)) (not (c)))");
REQUIRE(output.str() == "(or (not (a)) (not (b)) (not (c)))");
}

View File

@ -1,4 +1,4 @@
#include <gtest/gtest.h>
#include <catch.hpp>
#include <fstream>
#include <iostream>
@ -16,164 +16,164 @@ using namespace plasp::pddl;
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseBlocksWorldDomain)
TEST_CASE("[PDDL parser] The Blocks World domain is parsed correctly", "[PDDL parser]")
{
const auto description = Description::fromFile("data/blocksworld-domain.pddl");
ASSERT_NO_THROW(description.domain());
REQUIRE_NOTHROW(description.domain());
const auto &domain = description.domain();
// Name
ASSERT_EQ(domain.name(), "blocks");
REQUIRE(domain.name() == "blocks");
// Requirements
ASSERT_EQ(domain.requirements().size(), 2u);
ASSERT_EQ(domain.requirements()[0].type(), Requirement::Type::STRIPS);
ASSERT_EQ(domain.requirements()[1].type(), Requirement::Type::Typing);
REQUIRE(domain.requirements().size() == 2u);
REQUIRE(domain.requirements()[0].type() == Requirement::Type::STRIPS);
REQUIRE(domain.requirements()[1].type() == Requirement::Type::Typing);
// Types
ASSERT_EQ(domain.types().size(), 1u);
REQUIRE(domain.types().size() == 1u);
const auto &block = *domain.types()[0];
ASSERT_EQ(block.name(), "block");
ASSERT_EQ(block.parentTypes().size(), 0u);
REQUIRE(block.name() == "block");
REQUIRE(block.parentTypes().size() == 0u);
// Predicates
ASSERT_EQ(domain.predicates().size(), 5u);
REQUIRE(domain.predicates().size() == 5u);
const auto &on = *domain.predicates()[0];
ASSERT_EQ(on.name(), "on");
ASSERT_EQ(on.arguments().size(), 2u);
ASSERT_EQ(on.arguments()[0]->name(), "x");
REQUIRE(on.name() == "on");
REQUIRE(on.arguments().size() == 2u);
REQUIRE(on.arguments()[0]->name() == "x");
const auto &onArgument0Type = dynamic_cast<const expressions::PrimitiveType &>(*on.arguments()[0]->type());
ASSERT_EQ(&onArgument0Type, &block);
ASSERT_EQ(on.arguments()[1]->name(), "y");
REQUIRE(&onArgument0Type == &block);
REQUIRE(on.arguments()[1]->name() == "y");
const auto &onArgument1Type = dynamic_cast<const expressions::PrimitiveType &>(*on.arguments()[1]->type());
ASSERT_EQ(&onArgument1Type, &block);
REQUIRE(&onArgument1Type == &block);
const auto &handempty = *domain.predicates()[3];
ASSERT_EQ(handempty.name(), "handempty");
ASSERT_TRUE(handempty.arguments().empty());
REQUIRE(handempty.name() == "handempty");
REQUIRE(handempty.arguments().empty());
// Actions
ASSERT_EQ(domain.actions().size(), 4u);
REQUIRE(domain.actions().size() == 4u);
const auto &pickUp = *domain.actions()[0];
ASSERT_EQ(pickUp.name(), "pick-up");
ASSERT_EQ(pickUp.parameters().size(), 1u);
ASSERT_EQ(pickUp.parameters()[0]->name(), "x");
ASSERT_EQ(pickUp.parameters()[0]->type(), &block);
REQUIRE(pickUp.name() == "pick-up");
REQUIRE(pickUp.parameters().size() == 1u);
REQUIRE(pickUp.parameters()[0]->name() == "x");
REQUIRE(pickUp.parameters()[0]->type() == &block);
const auto &pickUpPre = dynamic_cast<const expressions::And &>(*pickUp.precondition());
ASSERT_EQ(pickUpPre.arguments().size(), 3u);
REQUIRE(pickUpPre.arguments().size() == 3u);
const auto &pickUpPre0 = dynamic_cast<const expressions::Predicate &>(*pickUpPre.arguments()[0]);
ASSERT_EQ(pickUpPre0.name(), "clear");
ASSERT_EQ(pickUpPre0.arguments().size(), 1u);
REQUIRE(pickUpPre0.name() == "clear");
REQUIRE(pickUpPre0.arguments().size() == 1u);
const auto &pickUpPre00 = dynamic_cast<const expressions::Variable &>(*pickUpPre0.arguments()[0]);
ASSERT_EQ(pickUpPre00.name(), "x");
ASSERT_EQ(pickUpPre00.type(), &block);
ASSERT_EQ(&pickUpPre00, pickUp.parameters()[0].get());
REQUIRE(pickUpPre00.name() == "x");
REQUIRE(pickUpPre00.type() == &block);
REQUIRE(&pickUpPre00 == pickUp.parameters()[0].get());
const auto &pickUpPre2 = dynamic_cast<const expressions::Predicate &>(*pickUpPre.arguments()[2]);
ASSERT_EQ(pickUpPre2.name(), "handempty");
ASSERT_EQ(pickUpPre2.arguments().size(), 0u);
REQUIRE(pickUpPre2.name() == "handempty");
REQUIRE(pickUpPre2.arguments().size() == 0u);
const auto &pickUpEff = dynamic_cast<const expressions::And &>(*pickUp.effect());
ASSERT_EQ(pickUpEff.arguments().size(), 4u);
REQUIRE(pickUpEff.arguments().size() == 4u);
const auto &pickUpEff0 = dynamic_cast<const expressions::Not &>(*pickUpEff.arguments()[0]);
const auto &pickUpEff00 = dynamic_cast<const expressions::Predicate &>(*pickUpEff0.argument());
ASSERT_EQ(pickUpEff00.name(), "ontable");
ASSERT_EQ(pickUpEff00.arguments().size(), 1u);
REQUIRE(pickUpEff00.name() == "ontable");
REQUIRE(pickUpEff00.arguments().size() == 1u);
const auto &pickUpEff000 = dynamic_cast<const expressions::Variable &>(*pickUpEff00.arguments()[0]);
ASSERT_EQ(pickUpEff000.name(), "x");
ASSERT_EQ(pickUpEff000.type(), &block);
REQUIRE(pickUpEff000.name() == "x");
REQUIRE(pickUpEff000.type() == &block);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseBlocksWorldProblem)
TEST_CASE("[PDDL parser] A Blocks World problem is parsed correctly", "[PDDL parser]")
{
const auto description = Description::fromFiles({"data/blocksworld-domain.pddl", "data/blocksworld-problem.pddl"});
ASSERT_NO_THROW(description.problem());
REQUIRE_NOTHROW(description.problem());
const auto &problem = description.problem();
// Name
ASSERT_EQ(problem.name(), "blocks-4-0");
ASSERT_EQ(problem.domain().name(), "blocks");
REQUIRE(problem.name() == "blocks-4-0");
REQUIRE(problem.domain().name() == "blocks");
// Requirements
// TODO: compute domain vs. problem requirements correctly and check them
// Objects
ASSERT_EQ(problem.objects().size(), 4u);
REQUIRE(problem.objects().size() == 4u);
ASSERT_EQ(problem.objects()[0]->name(), "d");
ASSERT_NE(problem.objects()[0]->type(), nullptr);
ASSERT_EQ(problem.objects()[0]->type()->name(), "block");
ASSERT_EQ(problem.objects()[3]->name(), "c");
ASSERT_NE(problem.objects()[3]->type(), nullptr);
ASSERT_EQ(problem.objects()[3]->type()->name(), "block");
REQUIRE(problem.objects()[0]->name() == "d");
REQUIRE(problem.objects()[0]->type() != nullptr);
REQUIRE(problem.objects()[0]->type()->name() == "block");
REQUIRE(problem.objects()[3]->name() == "c");
REQUIRE(problem.objects()[3]->type() != nullptr);
REQUIRE(problem.objects()[3]->type()->name() == "block");
// Initial State
const auto &facts = problem.initialState().facts();
ASSERT_EQ(facts.size(), 9u);
REQUIRE(facts.size() == 9u);
const auto &fact0 = dynamic_cast<const expressions::Predicate &>(*facts[0].get());
ASSERT_EQ(fact0.name(), "clear");
ASSERT_EQ(fact0.arguments().size(), 1u);
REQUIRE(fact0.name() == "clear");
REQUIRE(fact0.arguments().size() == 1u);
const auto &fact00 = dynamic_cast<const expressions::Constant &>(*fact0.arguments()[0]);
ASSERT_EQ(fact00.name(), "c");
ASSERT_NE(fact00.type(), nullptr);
ASSERT_EQ(fact00.type()->name(), "block");
REQUIRE(fact00.name() == "c");
REQUIRE(fact00.type() != nullptr);
REQUIRE(fact00.type()->name() == "block");
const auto &fact8 = dynamic_cast<const expressions::Predicate &>(*facts[8].get());
ASSERT_EQ(fact8.name(), "handempty");
ASSERT_EQ(fact8.arguments().size(), 0u);
REQUIRE(fact8.name() == "handempty");
REQUIRE(fact8.arguments().size() == 0u);
// Goal
const auto &goal = dynamic_cast<const expressions::And &>(problem.goal());
ASSERT_EQ(goal.arguments().size(), 3u);
REQUIRE(goal.arguments().size() == 3u);
const auto &goal0 = dynamic_cast<const expressions::Predicate &>(*goal.arguments()[0]);
ASSERT_EQ(goal0.name(), "on");
ASSERT_EQ(goal0.arguments().size(), 2u);
REQUIRE(goal0.name() == "on");
REQUIRE(goal0.arguments().size() == 2u);
const auto &goal00 = dynamic_cast<const expressions::Constant &>(*goal0.arguments()[0]);
ASSERT_EQ(goal00.name(), "d");
REQUIRE(goal00.name() == "d");
const auto &goal01 = dynamic_cast<const expressions::Constant &>(*goal0.arguments()[1]);
ASSERT_EQ(goal01.name(), "c");
REQUIRE(goal01.name() == "c");
const auto &goal2 = dynamic_cast<const expressions::Predicate &>(*goal.arguments()[2]);
ASSERT_EQ(goal2.name(), "on");
ASSERT_EQ(goal2.arguments().size(), 2u);
REQUIRE(goal2.name() == "on");
REQUIRE(goal2.arguments().size() == 2u);
const auto &goal20 = dynamic_cast<const expressions::Constant &>(*goal2.arguments()[0]);
ASSERT_EQ(goal20.name(), "b");
REQUIRE(goal20.name() == "b");
const auto &goal21 = dynamic_cast<const expressions::Constant &>(*goal2.arguments()[1]);
ASSERT_EQ(goal21.name(), "a");
REQUIRE(goal21.name() == "a");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseStorageDomain)
TEST_CASE("[PDDL parser] The Storage domain is parsed correctly", "[PDDL parser]")
{
const auto description = plasp::pddl::Description::fromFile("data/storage-domain.pddl");
ASSERT_NO_THROW(description.domain());
REQUIRE_NOTHROW(description.domain());
const auto &domain = description.domain();
// Name
ASSERT_EQ(domain.name(), "storage-propositional");
REQUIRE(domain.name() == "storage-propositional");
// Requirements
ASSERT_EQ(domain.requirements().size(), 1u);
ASSERT_EQ(domain.requirements()[0].type(), Requirement::Type::Typing);
REQUIRE(domain.requirements().size() == 1u);
REQUIRE(domain.requirements()[0].type() == Requirement::Type::Typing);
// Types
ASSERT_EQ(domain.types().size(), 10u);
REQUIRE(domain.types().size() == 10u);
const auto &hoist = *domain.types()[0];
const auto &surface = *domain.types()[1];
@ -183,140 +183,140 @@ TEST(PDDLParserTests, ParseStorageDomain)
const auto &crate = *domain.types()[9];
const auto &hoistParents = hoist.parentTypes();
ASSERT_EQ(hoistParents.size(), 1u);
ASSERT_TRUE(std::find(hoistParents.cbegin(), hoistParents.cend(), &object) != hoistParents.cend());
REQUIRE(hoistParents.size() == 1u);
REQUIRE(std::find(hoistParents.cbegin(), hoistParents.cend(), &object) != hoistParents.cend());
const auto &areaParents = area.parentTypes();
ASSERT_EQ(areaParents.size(), 2u);
ASSERT_TRUE(std::find(areaParents.cbegin(), areaParents.cend(), &object) != areaParents.cend());
ASSERT_TRUE(std::find(areaParents.cbegin(), areaParents.cend(), &surface) != areaParents.cend());
REQUIRE(areaParents.size() == 2u);
REQUIRE(std::find(areaParents.cbegin(), areaParents.cend(), &object) != areaParents.cend());
REQUIRE(std::find(areaParents.cbegin(), areaParents.cend(), &surface) != areaParents.cend());
// Predicates
ASSERT_EQ(domain.predicates().size(), 8u);
REQUIRE(domain.predicates().size() == 8u);
const auto &on = *domain.predicates()[5];
ASSERT_EQ(on.name(), "on");
ASSERT_EQ(on.arguments().size(), 2u);
ASSERT_EQ(on.arguments()[0]->name(), "c");
REQUIRE(on.name() == "on");
REQUIRE(on.arguments().size() == 2u);
REQUIRE(on.arguments()[0]->name() == "c");
const auto &onArgument0Type = dynamic_cast<const expressions::PrimitiveType &>(*on.arguments()[0]->type());
ASSERT_EQ(&onArgument0Type, &crate);
ASSERT_EQ(on.arguments()[1]->name(), "s");
REQUIRE(&onArgument0Type == &crate);
REQUIRE(on.arguments()[1]->name() == "s");
const auto &onArgument1Type = dynamic_cast<const expressions::PrimitiveType &>(*on.arguments()[1]->type());
ASSERT_EQ(&onArgument1Type, &storearea);
REQUIRE(&onArgument1Type == &storearea);
const auto &in = *domain.predicates()[1];
ASSERT_EQ(in.name(), "in");
ASSERT_EQ(in.arguments().size(), 2u);
ASSERT_EQ(in.arguments()[0]->name(), "x");
REQUIRE(in.name() == "in");
REQUIRE(in.arguments().size() == 2u);
REQUIRE(in.arguments()[0]->name() == "x");
const auto &inArgument0Type = dynamic_cast<const expressions::Either &>(*in.arguments()[0]->type());
ASSERT_EQ(inArgument0Type.arguments().size(), 2u);
REQUIRE(inArgument0Type.arguments().size() == 2u);
const auto &inArgument0Type0 = dynamic_cast<const expressions::PrimitiveType &>(*inArgument0Type.arguments()[0]);
ASSERT_EQ(&inArgument0Type0, &storearea);
REQUIRE(&inArgument0Type0 == &storearea);
const auto &inArgument0Type1 = dynamic_cast<const expressions::PrimitiveType &>(*inArgument0Type.arguments()[1]);
ASSERT_EQ(&inArgument0Type1, &crate);
REQUIRE(&inArgument0Type1 == &crate);
// Actions
ASSERT_EQ(domain.actions().size(), 5u);
REQUIRE(domain.actions().size() == 5u);
const auto &drop = *domain.actions()[1];
ASSERT_EQ(drop.name(), "drop");
ASSERT_EQ(drop.parameters().size(), 5u);
ASSERT_EQ(drop.parameters()[3]->name(), "a2");
ASSERT_EQ(drop.parameters()[3]->type(), &area);
REQUIRE(drop.name() == "drop");
REQUIRE(drop.parameters().size() == 5u);
REQUIRE(drop.parameters()[3]->name() == "a2");
REQUIRE(drop.parameters()[3]->type() == &area);
const auto &dropPre = dynamic_cast<const expressions::And &>(*drop.precondition());
ASSERT_EQ(dropPre.arguments().size(), 5u);
REQUIRE(dropPre.arguments().size() == 5u);
const auto &dropPre2 = dynamic_cast<const expressions::Predicate &>(*dropPre.arguments()[2]);
ASSERT_EQ(dropPre2.name(), "lifting");
ASSERT_EQ(dropPre2.arguments().size(), 2u);
REQUIRE(dropPre2.name() == "lifting");
REQUIRE(dropPre2.arguments().size() == 2u);
const auto &dropPre21 = dynamic_cast<const expressions::Variable &>(*dropPre2.arguments()[1]);
ASSERT_EQ(dropPre21.name(), "c");
ASSERT_EQ(dropPre21.type(), &crate);
REQUIRE(dropPre21.name() == "c");
REQUIRE(dropPre21.type() == &crate);
const auto &dropEff = dynamic_cast<const expressions::And &>(*drop.effect());
ASSERT_EQ(dropEff.arguments().size(), 5u);
REQUIRE(dropEff.arguments().size() == 5u);
const auto &dropEff2 = dynamic_cast<const expressions::Not &>(*dropEff.arguments()[2]);
const auto &dropEff20 = dynamic_cast<const expressions::Predicate &>(*dropEff2.argument());
ASSERT_EQ(dropEff20.name(), "clear");
ASSERT_EQ(dropEff20.arguments().size(), 1u);
REQUIRE(dropEff20.name() == "clear");
REQUIRE(dropEff20.arguments().size() == 1u);
const auto &dropEff200 = dynamic_cast<const expressions::Variable &>(*dropEff20.arguments()[0]);
ASSERT_EQ(dropEff200.name(), "a1");
ASSERT_EQ(dropEff200.type(), &storearea);
REQUIRE(dropEff200.name() == "a1");
REQUIRE(dropEff200.type() == &storearea);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseStorageProblem)
TEST_CASE("[PDDL parser] A Storage problem is parsed correctly", "[PDDL parser]")
{
const auto description = Description::fromFiles({"data/storage-domain.pddl", "data/storage-problem.pddl"});
ASSERT_NO_THROW(description.problem());
REQUIRE_NOTHROW(description.problem());
const auto &problem = description.problem();
// Name
ASSERT_EQ(problem.name(), "storage-1");
ASSERT_EQ(problem.domain().name(), "storage-propositional");
REQUIRE(problem.name() == "storage-1");
REQUIRE(problem.domain().name() == "storage-propositional");
// Requirements
// TODO: compute domain vs. problem requirements correctly and check them
// Objects
ASSERT_EQ(problem.objects().size(), 7u);
REQUIRE(problem.objects().size() == 7u);
ASSERT_EQ(problem.objects()[0]->name(), "depot0-1-1");
ASSERT_NE(problem.objects()[0]->type(), nullptr);
ASSERT_EQ(problem.objects()[0]->type()->name(), "storearea");
ASSERT_EQ(problem.objects()[6]->name(), "loadarea");
ASSERT_NE(problem.objects()[6]->type(), nullptr);
ASSERT_EQ(problem.objects()[6]->type()->name(), "transitarea");
REQUIRE(problem.objects()[0]->name() == "depot0-1-1");
REQUIRE(problem.objects()[0]->type() != nullptr);
REQUIRE(problem.objects()[0]->type()->name() == "storearea");
REQUIRE(problem.objects()[6]->name() == "loadarea");
REQUIRE(problem.objects()[6]->type() != nullptr);
REQUIRE(problem.objects()[6]->type()->name() == "transitarea");
// Initial State
const auto &facts = problem.initialState().facts();
ASSERT_EQ(facts.size(), 10u);
REQUIRE(facts.size() == 10u);
const auto &fact0 = dynamic_cast<const expressions::Predicate &>(*facts[0].get());
ASSERT_EQ(fact0.name(), "in");
ASSERT_EQ(fact0.arguments().size(), 2u);
REQUIRE(fact0.name() == "in");
REQUIRE(fact0.arguments().size() == 2u);
const auto &fact01 = dynamic_cast<const expressions::Constant &>(*fact0.arguments()[1]);
ASSERT_EQ(fact01.name(), "depot0");
ASSERT_NE(fact01.type(), nullptr);
ASSERT_EQ(fact01.type()->name(), "depot");
REQUIRE(fact01.name() == "depot0");
REQUIRE(fact01.type() != nullptr);
REQUIRE(fact01.type()->name() == "depot");
const auto &fact9 = dynamic_cast<const expressions::Predicate &>(*facts[9].get());
ASSERT_EQ(fact9.name(), "available");
ASSERT_EQ(fact9.arguments().size(), 1u);
REQUIRE(fact9.name() == "available");
REQUIRE(fact9.arguments().size() == 1u);
const auto &fact90 = dynamic_cast<const expressions::Constant &>(*fact9.arguments()[0]);
ASSERT_EQ(fact90.name(), "hoist0");
ASSERT_NE(fact90.type(), nullptr);
ASSERT_EQ(fact90.type()->name(), "hoist");
REQUIRE(fact90.name() == "hoist0");
REQUIRE(fact90.type() != nullptr);
REQUIRE(fact90.type()->name() == "hoist");
// Goal
const auto &goal = dynamic_cast<const expressions::And &>(problem.goal());
ASSERT_EQ(goal.arguments().size(), 1u);
REQUIRE(goal.arguments().size() == 1u);
const auto &goal0 = dynamic_cast<const expressions::Predicate &>(*goal.arguments()[0]);
ASSERT_EQ(goal0.name(), "in");
ASSERT_EQ(goal0.arguments().size(), 2u);
REQUIRE(goal0.name() == "in");
REQUIRE(goal0.arguments().size() == 2u);
const auto &goal00 = dynamic_cast<const expressions::Constant &>(*goal0.arguments()[0]);
ASSERT_EQ(goal00.name(), "crate0");
REQUIRE(goal00.name() == "crate0");
const auto &goal01 = dynamic_cast<const expressions::Constant &>(*goal0.arguments()[1]);
ASSERT_EQ(goal01.name(), "depot0");
REQUIRE(goal01.name() == "depot0");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseConstants)
TEST_CASE("[PDDL parser] Constants are parsed correctly", "[PDDL parser]")
{
const auto description = Description::fromFile("data/woodworking-domain.pddl");
ASSERT_NO_THROW(description.domain());
REQUIRE_NOTHROW(description.domain());
const auto &domain = description.domain();
// Name
ASSERT_EQ(domain.name(), "woodworking");
REQUIRE(domain.name() == "woodworking");
// Types
const auto &acolour = *domain.types()[0];
@ -324,82 +324,82 @@ TEST(PDDLParserTests, ParseConstants)
const auto &treatmentstatus = *domain.types()[5];
// Constants
ASSERT_EQ(domain.constants().size(), 8u);
ASSERT_EQ(domain.constants()[0]->type(), &surface);
ASSERT_EQ(domain.constants()[2]->type(), &surface);
ASSERT_EQ(domain.constants()[3]->type(), &treatmentstatus);
ASSERT_EQ(domain.constants()[6]->type(), &treatmentstatus);
ASSERT_EQ(domain.constants()[7]->type(), &acolour);
REQUIRE(domain.constants().size() == 8u);
REQUIRE(domain.constants()[0]->type() == &surface);
REQUIRE(domain.constants()[2]->type() == &surface);
REQUIRE(domain.constants()[3]->type() == &treatmentstatus);
REQUIRE(domain.constants()[6]->type() == &treatmentstatus);
REQUIRE(domain.constants()[7]->type() == &acolour);
// TODO: add test with constants in predicates
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseWithWhiteSpace)
TEST_CASE("[PDDL parser] White spaces are ignored", "[PDDL parser]")
{
ASSERT_NO_THROW(Description::fromFile("data/white-space-test.pddl"));
REQUIRE_NOTHROW(Description::fromFile("data/white-space-test.pddl"));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, DetectWrongDomain)
TEST_CASE("[PDDL parser] Missing or unmatching domain descriptions are detected", "[PDDL parser]")
{
ASSERT_THROW(Description::fromFile("data/blocksworld-problem.pddl"), ConsistencyException);
ASSERT_THROW(Description::fromFiles({"data/blocksworld-problem.pddl", "data/storage-domain.pddl"}), plasp::utils::ParserException);
REQUIRE_THROWS_AS(Description::fromFile("data/blocksworld-problem.pddl"), ConsistencyException);
REQUIRE_THROWS_AS(Description::fromFiles({"data/blocksworld-problem.pddl", "data/storage-domain.pddl"}), plasp::utils::ParserException);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, DetectSyntaxErrors)
TEST_CASE("[PDDL parser] Common PDDL syntax errors are detected", "[PDDL parser]")
{
ASSERT_NO_THROW(Description::fromFile("data/pddl-syntax/domain-valid.pddl"));
REQUIRE_NOTHROW(Description::fromFile("data/pddl-syntax/domain-valid.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-expressions-1.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-expressions-2.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-expressions-3.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-expressions-1.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-expressions-2.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-expressions-3.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-expression-name-1.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-expression-name-2.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-expression-name-3.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-expression-name-1.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-expression-name-2.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-expression-name-3.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-parentheses-1.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-parentheses-2.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-parentheses-3.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-parentheses-4.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-parentheses-5.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-parentheses-6.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-parentheses-7.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-parentheses-8.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-parentheses-1.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-parentheses-2.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-parentheses-3.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-parentheses-4.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-parentheses-5.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-parentheses-6.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-parentheses-7.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-parentheses-8.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-section-name-1.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-section-name-2.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-section-name-3.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-section-name-4.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-section-name-5.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-section-name-6.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-section-name-7.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-section-name-1.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-section-name-2.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-section-name-3.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-section-name-4.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-section-name-5.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-section-name-6.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-section-name-7.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-types-1.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-types-2.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-types-3.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-types-4.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-types-1.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-types-2.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-types-3.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-types-4.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-variables-1.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-variables-2.pddl"));
ASSERT_ANY_THROW(Description::fromFile("data/pddl-syntax/domain-variables-3.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-variables-1.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-variables-2.pddl"));
REQUIRE_THROWS(Description::fromFile("data/pddl-syntax/domain-variables-3.pddl"));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, CheckIssues)
TEST_CASE("[PDDL parser] Former issues are fixed", "[PDDL parser]")
{
// Check white space issues with constants and parsing unsupported sections
ASSERT_NO_THROW(Description::fromFile("data/issues/issue-1.pddl"));
REQUIRE_NOTHROW(Description::fromFile("data/issues/issue-1.pddl"));
// Check white space issues with empty n-ary predicates
ASSERT_NO_THROW(Description::fromFile("data/issues/issue-2.pddl"));
REQUIRE_NOTHROW(Description::fromFile("data/issues/issue-2.pddl"));
// Check that comments are correctly ignored
ASSERT_NO_THROW(Description::fromFile("data/issues/issue-3.pddl"));
REQUIRE_NOTHROW(Description::fromFile("data/issues/issue-3.pddl"));
}

View File

@ -1,4 +1,4 @@
#include <gtest/gtest.h>
#include <catch.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/null.hpp>
@ -12,19 +12,19 @@ boost::iostreams::stream<boost::iostreams::null_sink> nullStream((boost::iostrea
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLTranslationTests, CheckIssues)
TEST_CASE("[PDDL translation] Former issues are fixed", "[PDDL translation]")
{
// Check that translating domains without typing information works
{
auto description = Description::fromFile("data/issues/issue-4.pddl");
const auto translator = TranslatorASP(description, description.context().logger.outputStream());
ASSERT_NO_THROW(translator.translate());
REQUIRE_NOTHROW(translator.translate());
}
// Check that translating the simple blocks world domain works
{
auto description = Description::fromFile("data/issues/issue-5.pddl");
const auto translator = TranslatorASP(description, description.context().logger.outputStream());
ASSERT_NO_THROW(translator.translate());
REQUIRE_NOTHROW(translator.translate());
}
}

View File

@ -1,4 +1,4 @@
#include <gtest/gtest.h>
#include <catch.hpp>
#include <fstream>
#include <iostream>
@ -9,10 +9,10 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
class SASParserTests : public ::testing::Test
class SASParserTestsFixture
{
protected:
SASParserTests()
SASParserTestsFixture()
: m_blocksworldTestFile(readFile("data/blocksworld.sas")),
m_cavedivingTestFile(readFile("data/cavediving.sas")),
m_freecellTestFile(readFile("data/freecell.sas")),
@ -42,74 +42,74 @@ class SASParserTests : public ::testing::Test
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(SASParserTests, ParseValidSASFile)
TEST_CASE_METHOD(SASParserTestsFixture, "[SAS parser] A valid SAS file is parsed correctly", "[SAS parser]")
{
try
{
const auto description = plasp::sas::Description::fromStream(m_philosophersTestFile);
ASSERT_FALSE(description.usesActionCosts());
REQUIRE_FALSE(description.usesActionCosts());
ASSERT_EQ(description.variables().size(), 37u);
ASSERT_EQ(description.variables()[0].axiomLayer(), -1);
ASSERT_EQ(description.variables()[0].values()[0].sign(), plasp::sas::Value::Sign::Positive);
ASSERT_EQ(description.variables()[0].values()[0].name(), "activate(philosopher-0, forks--pid-rfork)");
ASSERT_EQ(description.variables()[36].axiomLayer(), -1);
ASSERT_EQ(description.variables()[36].values()[1].sign(), plasp::sas::Value::Sign::Negative);
ASSERT_EQ(description.variables()[36].values()[1].name(), "queue-tail-msg(forks-1-, fork)");
REQUIRE(description.variables().size() == 37u);
REQUIRE(description.variables()[0].axiomLayer() == -1);
REQUIRE(description.variables()[0].values()[0].sign() == plasp::sas::Value::Sign::Positive);
REQUIRE(description.variables()[0].values()[0].name() == "activate(philosopher-0, forks--pid-rfork)");
REQUIRE(description.variables()[36].axiomLayer() == -1);
REQUIRE(description.variables()[36].values()[1].sign() == plasp::sas::Value::Sign::Negative);
REQUIRE(description.variables()[36].values()[1].name() == "queue-tail-msg(forks-1-, fork)");
ASSERT_EQ(description.mutexGroups().size(), 8u);
ASSERT_EQ(description.mutexGroups()[0].facts().size(), 9u);
ASSERT_EQ(&description.mutexGroups()[0].facts()[0].value(), &description.variables()[0].values()[0]);
ASSERT_EQ(description.mutexGroups()[7].facts().size(), 2u);
ASSERT_EQ(&description.mutexGroups()[7].facts()[1].value(), &description.variables()[34].values()[1]);
REQUIRE(description.mutexGroups().size() == 8u);
REQUIRE(description.mutexGroups()[0].facts().size() == 9u);
REQUIRE(&description.mutexGroups()[0].facts()[0].value() == &description.variables()[0].values()[0]);
REQUIRE(description.mutexGroups()[7].facts().size() == 2u);
REQUIRE(&description.mutexGroups()[7].facts()[1].value() == &description.variables()[34].values()[1]);
ASSERT_EQ(description.initialState().facts().size(), 37u);
ASSERT_EQ(&description.initialState().facts()[0].value(), &description.variables()[0].values()[8]);
ASSERT_EQ(&description.initialState().facts()[36].value(), &description.variables()[36].values()[1]);
REQUIRE(description.initialState().facts().size() == 37u);
REQUIRE(&description.initialState().facts()[0].value() == &description.variables()[0].values()[8]);
REQUIRE(&description.initialState().facts()[36].value() == &description.variables()[36].values()[1]);
ASSERT_EQ(description.goal().facts().size(), 2u);
ASSERT_EQ(&description.goal().facts()[0].value(), &description.variables()[6].values()[0]);
ASSERT_EQ(&description.goal().facts()[1].value(), &description.variables()[7].values()[0]);
REQUIRE(description.goal().facts().size() == 2u);
REQUIRE(&description.goal().facts()[0].value() == &description.variables()[6].values()[0]);
REQUIRE(&description.goal().facts()[1].value() == &description.variables()[7].values()[0]);
ASSERT_EQ(description.operators().size(), 34u);
ASSERT_EQ(description.operators()[0].predicate().name(), "activate-trans");
ASSERT_EQ(description.operators()[0].predicate().arguments().size(), 5u);
ASSERT_EQ(description.operators()[0].predicate().arguments()[0], "philosopher-0");
ASSERT_EQ(description.operators()[0].predicate().arguments()[4], "state-3");
ASSERT_EQ(description.operators()[0].preconditions().size(), 3u);
ASSERT_EQ(&description.operators()[0].preconditions()[0].value(), &description.variables()[4].values()[4]);
ASSERT_EQ(&description.operators()[0].preconditions()[1].value(), &description.variables()[16].values()[1]);
ASSERT_EQ(&description.operators()[0].preconditions()[2].value(), &description.variables()[0].values()[8]);
ASSERT_EQ(description.operators()[0].effects().size(), 1u);
ASSERT_EQ(description.operators()[0].effects()[0].conditions().size(), 0u);
ASSERT_EQ(&description.operators()[0].effects()[0].postcondition().value(), &description.variables()[0].values()[0]);
ASSERT_EQ(description.operators()[33].predicate().name(), "queue-write");
ASSERT_EQ(description.operators()[33].predicate().arguments().size(), 4u);
ASSERT_EQ(description.operators()[33].predicate().arguments()[0], "philosopher-1");
ASSERT_EQ(description.operators()[33].predicate().arguments()[3], "fork");
ASSERT_EQ(description.operators()[33].preconditions().size(), 2u);
ASSERT_EQ(&description.operators()[33].preconditions()[0].value(), &description.variables()[1].values()[3]);
ASSERT_EQ(&description.operators()[33].preconditions()[1].value(), &description.variables()[2].values()[2]);
ASSERT_EQ(description.operators()[33].effects().size(), 3u);
ASSERT_EQ(description.operators()[33].effects()[0].conditions().size(), 0u);
ASSERT_EQ(&description.operators()[33].effects()[0].postcondition().value(), &description.variables()[1].values()[7]);
ASSERT_EQ(&description.operators()[33].effects()[2].postcondition().value(), &description.variables()[35].values()[0]);
REQUIRE(description.operators().size() == 34u);
REQUIRE(description.operators()[0].predicate().name() == "activate-trans");
REQUIRE(description.operators()[0].predicate().arguments().size() == 5u);
REQUIRE(description.operators()[0].predicate().arguments()[0] == "philosopher-0");
REQUIRE(description.operators()[0].predicate().arguments()[4] == "state-3");
REQUIRE(description.operators()[0].preconditions().size() == 3u);
REQUIRE(&description.operators()[0].preconditions()[0].value() == &description.variables()[4].values()[4]);
REQUIRE(&description.operators()[0].preconditions()[1].value() == &description.variables()[16].values()[1]);
REQUIRE(&description.operators()[0].preconditions()[2].value() == &description.variables()[0].values()[8]);
REQUIRE(description.operators()[0].effects().size() == 1u);
REQUIRE(description.operators()[0].effects()[0].conditions().size() == 0u);
REQUIRE(&description.operators()[0].effects()[0].postcondition().value() == &description.variables()[0].values()[0]);
REQUIRE(description.operators()[33].predicate().name() == "queue-write");
REQUIRE(description.operators()[33].predicate().arguments().size() == 4u);
REQUIRE(description.operators()[33].predicate().arguments()[0] == "philosopher-1");
REQUIRE(description.operators()[33].predicate().arguments()[3] == "fork");
REQUIRE(description.operators()[33].preconditions().size() == 2u);
REQUIRE(&description.operators()[33].preconditions()[0].value() == &description.variables()[1].values()[3]);
REQUIRE(&description.operators()[33].preconditions()[1].value() == &description.variables()[2].values()[2]);
REQUIRE(description.operators()[33].effects().size() == 3u);
REQUIRE(description.operators()[33].effects()[0].conditions().size() == 0u);
REQUIRE(&description.operators()[33].effects()[0].postcondition().value() == &description.variables()[1].values()[7]);
REQUIRE(&description.operators()[33].effects()[2].postcondition().value() == &description.variables()[35].values()[0]);
ASSERT_EQ(description.axiomRules().size(), 33u);
ASSERT_EQ(description.axiomRules()[0].conditions().size(), 4u);
ASSERT_EQ(&description.axiomRules()[0].conditions()[0].value(), &description.variables()[0].values()[0]);
ASSERT_EQ(&description.axiomRules()[0].conditions()[2].value(), &description.variables()[27].values()[0]);
ASSERT_EQ(&description.axiomRules()[0].conditions()[3].value(), &description.variables()[8].values()[1]);
ASSERT_EQ(&description.axiomRules()[0].postcondition().value(), &description.variables()[8].values()[0]);
ASSERT_EQ(description.axiomRules()[32].conditions().size(), 2u);
ASSERT_EQ(&description.axiomRules()[32].conditions()[0].value(), &description.variables()[15].values()[0]);
ASSERT_EQ(&description.axiomRules()[32].conditions()[1].value(), &description.variables()[25].values()[0]);
ASSERT_EQ(&description.axiomRules()[32].postcondition().value(), &description.variables()[25].values()[1]);
REQUIRE(description.axiomRules().size() == 33u);
REQUIRE(description.axiomRules()[0].conditions().size() == 4u);
REQUIRE(&description.axiomRules()[0].conditions()[0].value() == &description.variables()[0].values()[0]);
REQUIRE(&description.axiomRules()[0].conditions()[2].value() == &description.variables()[27].values()[0]);
REQUIRE(&description.axiomRules()[0].conditions()[3].value() == &description.variables()[8].values()[1]);
REQUIRE(&description.axiomRules()[0].postcondition().value() == &description.variables()[8].values()[0]);
REQUIRE(description.axiomRules()[32].conditions().size() == 2u);
REQUIRE(&description.axiomRules()[32].conditions()[0].value() == &description.variables()[15].values()[0]);
REQUIRE(&description.axiomRules()[32].conditions()[1].value() == &description.variables()[25].values()[0]);
REQUIRE(&description.axiomRules()[32].postcondition().value() == &description.variables()[25].values()[1]);
}
catch (const std::exception &e)
{
FAIL() << e.what();
FAIL(e.what());
}
// TODO: add whitespace test
@ -117,71 +117,71 @@ TEST_F(SASParserTests, ParseValidSASFile)
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(SASParserTests, RemoveTrailingParentheses)
TEST_CASE_METHOD(SASParserTestsFixture, "[SAS parser] Trailing empty parentheses are removed", "[SAS parser]")
{
try
{
const auto description = plasp::sas::Description::fromStream(m_blocksworldTestFile);
ASSERT_EQ(description.variables()[4].values()[0].name(), "handempty");
ASSERT_EQ(description.variables()[5].values()[0].name(), "holding(a)");
REQUIRE(description.variables()[4].values()[0].name() == "handempty");
REQUIRE(description.variables()[5].values()[0].name() == "holding(a)");
}
catch (const std::exception &e)
{
FAIL() << e.what();
FAIL(e.what());
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(SASParserTests, ParseNoneValue)
TEST_CASE_METHOD(SASParserTestsFixture, "[SAS parser] “none” values are correctly parsed", "[SAS parser]")
{
try
{
const auto description = plasp::sas::Description::fromStream(m_freecellTestFile);
// TODO: compare by identity, not value
ASSERT_EQ(description.variables()[0].values()[3], plasp::sas::Value::None);
ASSERT_EQ(description.variables()[5].values()[6], plasp::sas::Value::None);
REQUIRE(description.variables()[0].values()[3] == plasp::sas::Value::None);
REQUIRE(description.variables()[5].values()[6] == plasp::sas::Value::None);
}
catch (const std::exception &e)
{
FAIL() << e.what();
FAIL(e.what());
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(SASParserTests, ParseRequirements)
TEST_CASE_METHOD(SASParserTestsFixture, "[SAS parser] SAS requirements are parsed correctly", "[SAS parser]")
{
try
{
const auto description = plasp::sas::Description::fromStream(m_cavedivingTestFile);
ASSERT_TRUE(description.usesActionCosts());
ASSERT_TRUE(description.usesConditionalEffects());
ASSERT_FALSE(description.usesAxiomRules());
REQUIRE(description.usesActionCosts());
REQUIRE(description.usesConditionalEffects());
REQUIRE_FALSE(description.usesAxiomRules());
ASSERT_EQ(description.operators().size(), 496u);
REQUIRE(description.operators().size() == 496u);
ASSERT_EQ(description.operators()[0].costs(), 1u);
ASSERT_EQ(description.operators()[172].costs(), 10u);
ASSERT_EQ(description.operators()[173].costs(), 63u);
REQUIRE(description.operators()[0].costs() == 1u);
REQUIRE(description.operators()[172].costs() == 10u);
REQUIRE(description.operators()[173].costs() == 63u);
ASSERT_EQ(description.operators()[172].effects().size(), 3u);
ASSERT_EQ(description.operators()[172].effects()[1].conditions().size(), 1u);
ASSERT_EQ(&description.operators()[172].effects()[1].conditions()[0].value(), &description.variables()[1].values()[4]);
REQUIRE(description.operators()[172].effects().size() == 3u);
REQUIRE(description.operators()[172].effects()[1].conditions().size() == 1u);
REQUIRE(&description.operators()[172].effects()[1].conditions()[0].value() == &description.variables()[1].values()[4]);
}
catch (const std::exception &e)
{
FAIL() << e.what();
FAIL(e.what());
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(SASParserTests, CheckIssues)
TEST_CASE("[SAS parser] Former issues are fixed", "[SAS parser]")
{
// Check issue where unexpected whitespaces in SAS files led to a parsing error
ASSERT_NO_THROW(plasp::sas::Description::fromFile("data/issues/issue-6.sas"));
REQUIRE_NOTHROW(plasp::sas::Description::fromFile("data/issues/issue-6.sas"));
}

View File

@ -1,73 +1,73 @@
#include <gtest/gtest.h>
#include <catch.hpp>
#include <plasp/utils/Parser.h>
#include <plasp/utils/ParserException.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(UtilsTests, ParserParse)
TEST_CASE("[parser] Simple strings are parsed correctly", "[parser]")
{
std::stringstream s(" identifier 5 \n-51\t 0 1 100 200 -300 -400");
plasp::utils::Parser<> p("input", s);
ASSERT_EQ(p.parse<std::string>(), "identifier");
ASSERT_EQ(p.parse<size_t>(), 5u);
ASSERT_EQ(p.parse<int>(), -51);
ASSERT_EQ(p.parse<bool>(), false);
ASSERT_EQ(p.parse<bool>(), true);
REQUIRE(p.parse<std::string>() == "identifier");
REQUIRE(p.parse<size_t>() == 5u);
REQUIRE(p.parse<int>() == -51);
REQUIRE(p.parse<bool>() == false);
REQUIRE(p.parse<bool>() == true);
ASSERT_EQ(p.parse<int>(), 100);
ASSERT_EQ(p.parse<size_t>(), 200u);
ASSERT_EQ(p.parse<int>(), -300);
ASSERT_THROW(p.parse<size_t>(), plasp::utils::ParserException);
REQUIRE(p.parse<int>() == 100);
REQUIRE(p.parse<size_t>() == 200u);
REQUIRE(p.parse<int>() == -300);
REQUIRE_THROWS_AS(p.parse<size_t>(), plasp::utils::ParserException);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(UtilsTests, ParserExpect)
TEST_CASE("[parser] Parsing exceptions are correctly reported", "[parser]")
{
std::stringstream s(" identifier 5 \n-51\t 0 1 100 200 -300 -400");
plasp::utils::Parser<> p("input", s);
ASSERT_NO_THROW(p.expect<std::string>("identifier"));
ASSERT_NO_THROW(p.expect<size_t>(5u));
ASSERT_NO_THROW(p.expect<int>(-51));
ASSERT_NO_THROW(p.expect<bool>(false));
ASSERT_NO_THROW(p.expect<bool>(true));
REQUIRE_NOTHROW(p.expect<std::string>("identifier"));
REQUIRE_NOTHROW(p.expect<size_t>(5u));
REQUIRE_NOTHROW(p.expect<int>(-51));
REQUIRE_NOTHROW(p.expect<bool>(false));
REQUIRE_NOTHROW(p.expect<bool>(true));
ASSERT_NO_THROW(p.expect<int>(100));
ASSERT_NO_THROW(p.expect<size_t>(200u));
ASSERT_NO_THROW(p.expect<int>(-300));
ASSERT_THROW(p.expect<size_t>(-400), plasp::utils::ParserException);
REQUIRE_NOTHROW(p.expect<int>(100));
REQUIRE_NOTHROW(p.expect<size_t>(200u));
REQUIRE_NOTHROW(p.expect<int>(-300));
REQUIRE_THROWS_AS(p.expect<size_t>(-400), plasp::utils::ParserException);
p.seek(0);
ASSERT_THROW(p.expect<std::string>("error"), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p.expect<std::string>("error"), plasp::utils::ParserException);
p.seek(14);
ASSERT_THROW(p.expect<size_t>(6u), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p.expect<size_t>(6u), plasp::utils::ParserException);
p.seek(17);
ASSERT_THROW(p.expect<int>(-50), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p.expect<int>(-50), plasp::utils::ParserException);
p.seek(24);
ASSERT_THROW(p.expect<bool>(true), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p.expect<bool>(true), plasp::utils::ParserException);
p.seek(26);
ASSERT_THROW(p.expect<bool>(false), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p.expect<bool>(false), plasp::utils::ParserException);
p.seek(28);
ASSERT_THROW(p.expect<int>(101), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p.expect<int>(101), plasp::utils::ParserException);
p.seek(31);
ASSERT_THROW(p.expect<size_t>(201), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p.expect<size_t>(201), plasp::utils::ParserException);
p.seek(34);
ASSERT_THROW(p.expect<int>(-299), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p.expect<int>(-299), plasp::utils::ParserException);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(UtilsTests, ParserTest)
TEST_CASE("[parser] While parsing, the cursor position is as expected", "[parser]")
{
std::stringstream s(" identifier 5 \n-51\t 0 1");
plasp::utils::Parser<> p("input", s);
@ -75,106 +75,106 @@ TEST(UtilsTests, ParserTest)
plasp::utils::Parser<>::Position pos;
pos = p.position();
ASSERT_EQ(p.testAndReturn<std::string>("error"), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndReturn<std::string>("identifier"), true);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<std::string>("error"), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<std::string>("identifier"), true);
ASSERT_EQ(p.position(), 12);
REQUIRE(p.testAndReturn<std::string>("error") == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndReturn<std::string>("identifier") == true);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<std::string>("error") == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<std::string>("identifier") == true);
REQUIRE(p.position() == 12);
pos = p.position();
ASSERT_EQ(p.testAndReturn<size_t>(6u), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndReturn<size_t>(5u), true);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<size_t>(6u), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<size_t>(5u), true);
ASSERT_EQ(p.position(), 15);
REQUIRE(p.testAndReturn<size_t>(6u) == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndReturn<size_t>(5u) == true);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<size_t>(6u) == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<size_t>(5u) == true);
REQUIRE(p.position() == 15);
pos = p.position();
ASSERT_EQ(p.testAndReturn<int>(-50), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndReturn<int>(-51), true);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<int>(-50), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<int>(-51), true);
ASSERT_EQ(p.position(), 22);
REQUIRE(p.testAndReturn<int>(-50) == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndReturn<int>(-51) == true);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<int>(-50) == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<int>(-51) == true);
REQUIRE(p.position() == 22);
pos = p.position();
ASSERT_EQ(p.testAndReturn<bool>(true), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndReturn<bool>(false), true);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<bool>(true), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<bool>(false), true);
ASSERT_EQ(p.position(), 25);
REQUIRE(p.testAndReturn<bool>(true) == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndReturn<bool>(false) == true);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<bool>(true) == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<bool>(false) == true);
REQUIRE(p.position() == 25);
pos = p.position();
ASSERT_EQ(p.testAndReturn<bool>(false), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndReturn<bool>(true), true);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<bool>(false), false);
ASSERT_EQ(p.position(), pos);
ASSERT_EQ(p.testAndSkip<bool>(true), true);
ASSERT_EQ(p.position(), 27);
REQUIRE(p.testAndReturn<bool>(false) == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndReturn<bool>(true) == true);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<bool>(false) == false);
REQUIRE(p.position() == pos);
REQUIRE(p.testAndSkip<bool>(true) == true);
REQUIRE(p.position() == 27);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(UtilsTests, ParseEndOfFile)
TEST_CASE("[parser] The end of the input stream is correctly handled", "[parser]")
{
std::stringstream s1("test");
plasp::utils::Parser<> p1("input", s1);
ASSERT_NO_THROW(p1.expect<std::string>("test"));
ASSERT_THROW(p1.parse<std::string>(), plasp::utils::ParserException);
REQUIRE_NOTHROW(p1.expect<std::string>("test"));
REQUIRE_THROWS_AS(p1.parse<std::string>(), plasp::utils::ParserException);
std::stringstream s2("test1 test2 test3");
plasp::utils::Parser<> p2("input", s2);
ASSERT_NO_THROW(p2.expect<std::string>("test1"));
ASSERT_NO_THROW(p2.expect<std::string>("test2"));
ASSERT_NO_THROW(p2.expect<std::string>("test3"));
ASSERT_THROW(p2.parse<std::string>(), plasp::utils::ParserException);
REQUIRE_NOTHROW(p2.expect<std::string>("test1"));
REQUIRE_NOTHROW(p2.expect<std::string>("test2"));
REQUIRE_NOTHROW(p2.expect<std::string>("test3"));
REQUIRE_THROWS_AS(p2.parse<std::string>(), plasp::utils::ParserException);
std::stringstream s3("-127");
plasp::utils::Parser<> p3("input", s3);
p3.expect<int>(-127);
ASSERT_THROW(p3.parse<int>(), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p3.parse<int>(), plasp::utils::ParserException);
std::stringstream s4("128 -1023 -4095");
plasp::utils::Parser<> p4("input", s4);
ASSERT_NO_THROW(p4.expect<size_t>(128));
ASSERT_NO_THROW(p4.expect<int>(-1023));
ASSERT_NO_THROW(p4.expect<int>(-4095));
ASSERT_THROW(p4.parse<int>(), plasp::utils::ParserException);
REQUIRE_NOTHROW(p4.expect<size_t>(128));
REQUIRE_NOTHROW(p4.expect<int>(-1023));
REQUIRE_NOTHROW(p4.expect<int>(-4095));
REQUIRE_THROWS_AS(p4.parse<int>(), plasp::utils::ParserException);
std::stringstream s5("0");
plasp::utils::Parser<> p5("input", s5);
p5.expect<bool>(false);
ASSERT_THROW(p5.parse<bool>(), plasp::utils::ParserException);
REQUIRE_THROWS_AS(p5.parse<bool>(), plasp::utils::ParserException);
std::stringstream s6("0 1 0");
plasp::utils::Parser<> p6("input", s6);
ASSERT_NO_THROW(p6.expect<bool>(false));
ASSERT_NO_THROW(p6.expect<bool>(true));
ASSERT_NO_THROW(p6.expect<bool>(false));
ASSERT_THROW(p6.parse<bool>(), plasp::utils::ParserException);
REQUIRE_NOTHROW(p6.expect<bool>(false));
REQUIRE_NOTHROW(p6.expect<bool>(true));
REQUIRE_NOTHROW(p6.expect<bool>(false));
REQUIRE_THROWS_AS(p6.parse<bool>(), plasp::utils::ParserException);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(UtilsTests, ParserPosition)
TEST_CASE("[parser] While parsing, the cursor coordinate is as expcected", "[parser]")
{
std::stringstream s("123 \n4\ntest1\n test2\ntest3 \ntest4\n\n\n\n");
plasp::utils::Parser<> p("input", s);
@ -184,105 +184,105 @@ TEST(UtilsTests, ParserPosition)
plasp::utils::StreamCoordinate c;
c = p.coordinate();
ASSERT_EQ(c.row, 1u);
ASSERT_EQ(c.column, 1u);
ASSERT_EQ(p.currentCharacter(), '1');
REQUIRE(c.row == 1u);
REQUIRE(c.column == 1u);
REQUIRE(p.currentCharacter() == '1');
ASSERT_NO_THROW(p.advance());
REQUIRE_NOTHROW(p.advance());
c = p.coordinate();
ASSERT_EQ(c.row, 1u);
ASSERT_EQ(c.column, 2u);
ASSERT_EQ(p.currentCharacter(), '2');
REQUIRE(c.row == 1u);
REQUIRE(c.column == 2u);
REQUIRE(p.currentCharacter() == '2');
ASSERT_NO_THROW(p.advance());
REQUIRE_NOTHROW(p.advance());
c = p.coordinate();
ASSERT_EQ(c.row, 1u);
ASSERT_EQ(c.column, 3u);
ASSERT_EQ(p.currentCharacter(), '3');
REQUIRE(c.row == 1u);
REQUIRE(c.column == 3u);
REQUIRE(p.currentCharacter() == '3');
ASSERT_NO_THROW(p.advance());
REQUIRE_NOTHROW(p.advance());
c = p.coordinate();
ASSERT_EQ(c.row, 1u);
ASSERT_EQ(c.column, 4u);
ASSERT_EQ(p.currentCharacter(), ' ');
REQUIRE(c.row == 1u);
REQUIRE(c.column == 4u);
REQUIRE(p.currentCharacter() == ' ');
ASSERT_NO_THROW(p.advance());
REQUIRE_NOTHROW(p.advance());
c = p.coordinate();
ASSERT_EQ(c.row, 1u);
ASSERT_EQ(c.column, 5u);
ASSERT_EQ(p.currentCharacter(), '\n');
REQUIRE(c.row == 1u);
REQUIRE(c.column == 5u);
REQUIRE(p.currentCharacter() == '\n');
ASSERT_NO_THROW(p.advance());
REQUIRE_NOTHROW(p.advance());
c = p.coordinate();
ASSERT_EQ(c.row, 2u);
ASSERT_EQ(c.column, 1u);
ASSERT_EQ(p.currentCharacter(), '4');
REQUIRE(c.row == 2u);
REQUIRE(c.column == 1u);
REQUIRE(p.currentCharacter() == '4');
ASSERT_NO_THROW(p.advance());
REQUIRE_NOTHROW(p.advance());
ASSERT_NO_THROW(p.expect<std::string>("test1"));
REQUIRE_NOTHROW(p.expect<std::string>("test1"));
c = p.coordinate();
ASSERT_EQ(c.row, 3u);
ASSERT_EQ(c.column, 6u);
REQUIRE(c.row == 3u);
REQUIRE(c.column == 6u);
ASSERT_NO_THROW(p.expect<std::string>("test2"));
REQUIRE_NOTHROW(p.expect<std::string>("test2"));
c = p.coordinate();
ASSERT_EQ(c.row, 4u);
ASSERT_EQ(c.column, 7u);
REQUIRE(c.row == 4u);
REQUIRE(c.column == 7u);
ASSERT_NO_THROW(p.expect<std::string>("test3"));
REQUIRE_NOTHROW(p.expect<std::string>("test3"));
c = p.coordinate();
ASSERT_EQ(c.row, 5u);
ASSERT_EQ(c.column, 6u);
REQUIRE(c.row == 5u);
REQUIRE(c.column == 6u);
ASSERT_NO_THROW(p.skipLine());
REQUIRE_NOTHROW(p.skipLine());
c = p.coordinate();
ASSERT_EQ(c.row, 6u);
ASSERT_EQ(c.column, 1u);
REQUIRE(c.row == 6u);
REQUIRE(c.column == 1u);
ASSERT_NO_THROW(p.skipLine());
REQUIRE_NOTHROW(p.skipLine());
c = p.coordinate();
ASSERT_EQ(c.row, 7u);
ASSERT_EQ(c.column, 1u);
REQUIRE(c.row == 7u);
REQUIRE(c.column == 1u);
ASSERT_NO_THROW(p.skipWhiteSpace());
REQUIRE_NOTHROW(p.skipWhiteSpace());
c = p.coordinate();
ASSERT_EQ(c.row, 10u);
ASSERT_EQ(c.column, 1u);
ASSERT_TRUE(p.atEnd());
REQUIRE(c.row == 10u);
REQUIRE(c.column == 1u);
REQUIRE(p.atEnd());
p.reset();
ASSERT_EQ(p.position(), startPosition);
ASSERT_FALSE(p.atEnd());
REQUIRE(p.position() == startPosition);
REQUIRE_FALSE(p.atEnd());
for (size_t i = 0; i < 5; i++)
p.advance();
ASSERT_EQ(p.position(), static_cast<std::istream::pos_type>(5));
REQUIRE(p.position() == static_cast<std::istream::pos_type>(5));
p.seek(static_cast<std::istream::pos_type>(7));
ASSERT_EQ(p.position(), static_cast<std::istream::pos_type>(7));
REQUIRE(p.position() == static_cast<std::istream::pos_type>(7));
ASSERT_NO_THROW(p.expect<std::string>("test1"));
REQUIRE_NOTHROW(p.expect<std::string>("test1"));
// TODO: test parser with multiple sections
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(UtilsTests, ParserRemoveComments)
TEST_CASE("[parser] Comments are correctly removed", "[parser]")
{
std::stringstream s1("; comment at beginning\ntest1; comment in between\ntest2; comment at end");
plasp::utils::Parser<> p1("input", s1);
@ -291,42 +291,42 @@ TEST(UtilsTests, ParserRemoveComments)
plasp::utils::StreamCoordinate c;
ASSERT_NO_THROW(p1.expect<std::string>("test1"));
REQUIRE_NOTHROW(p1.expect<std::string>("test1"));
c = p1.coordinate();
ASSERT_EQ(c.row, 2u);
ASSERT_EQ(c.column, 6u);
REQUIRE(c.row == 2u);
REQUIRE(c.column == 6u);
ASSERT_NO_THROW(p1.expect<std::string>("test2"));
REQUIRE_NOTHROW(p1.expect<std::string>("test2"));
c = p1.coordinate();
ASSERT_EQ(c.row, 3u);
ASSERT_EQ(c.column, 6u);
REQUIRE(c.row == 3u);
REQUIRE(c.column == 6u);
p1.skipWhiteSpace();
ASSERT_TRUE(p1.atEnd());
REQUIRE(p1.atEnd());
std::stringstream s2("test;");
plasp::utils::Parser<> p2("input", s2);
p2.removeComments(";", "\n", false);
ASSERT_NO_THROW(p2.expect<std::string>("test"));
REQUIRE_NOTHROW(p2.expect<std::string>("test"));
p2.skipWhiteSpace();
ASSERT_TRUE(p2.atEnd());
REQUIRE(p2.atEnd());
std::stringstream s3("/* comment at start */ test1 /* comment in between */ test2 /*");
plasp::utils::Parser<> p3("input", s3);
p3.removeComments("/*", "*/", true);
ASSERT_NO_THROW(p3.expect<std::string>("test1"));
ASSERT_NO_THROW(p3.expect<std::string>("test2"));
REQUIRE_NOTHROW(p3.expect<std::string>("test1"));
REQUIRE_NOTHROW(p3.expect<std::string>("test2"));
p3.skipWhiteSpace();
ASSERT_TRUE(p3.atEnd());
REQUIRE(p3.atEnd());
}

1
tests/catch Submodule

@ -0,0 +1 @@
Subproject commit 88732e85b2ac0233bba6fec5c032d02f9c5c230b

@ -1 +0,0 @@
Subproject commit c99458533a9b4c743ed51537e25989ea55944908

2
tests/main.cpp Normal file
View File

@ -0,0 +1,2 @@
#define CATCH_CONFIG_MAIN
#include <catch.hpp>