Fixed parsing of types.
This commit is contained in:
@@ -7,13 +7,14 @@
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
|
||||
const auto pddlInstanceBasePath = fs::path("data") / "pddl-instances";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_CASE("[PDDL parser acceptance] All the IPC domains are parsed without errors", "[PDDL parser acceptance]")
|
||||
TEST_CASE("[PDDL parser acceptance] All official PDDL domains are parsed without errors", "[PDDL parser acceptance]")
|
||||
{
|
||||
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
|
||||
|
||||
for (const auto &competitionDirectory : fs::directory_iterator("data/pddl-instances"))
|
||||
for (const auto &competitionDirectory : fs::directory_iterator(pddlInstanceBasePath))
|
||||
{
|
||||
if (!fs::is_directory(competitionDirectory))
|
||||
continue;
|
||||
@@ -36,11 +37,9 @@ TEST_CASE("[PDDL parser acceptance] All the IPC domains are parsed without error
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_CASE("[PDDL parser acceptance] The first instance of every IPC domain is parsed without errors", "[PDDL parser acceptance]")
|
||||
TEST_CASE("[PDDL parser acceptance] The first instance for all official PDDL domains is parsed without errors", "[PDDL parser acceptance]")
|
||||
{
|
||||
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
|
||||
|
||||
for (const auto &competitionDirectory : fs::directory_iterator("data/pddl-instances"))
|
||||
for (const auto &competitionDirectory : fs::directory_iterator(pddlInstanceBasePath))
|
||||
{
|
||||
if (!fs::is_directory(competitionDirectory))
|
||||
continue;
|
||||
|
40
lib/pddlparse/tests/TestOfficialPDDLInstances.cpp
Normal file
40
lib/pddlparse/tests/TestOfficialPDDLInstances.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <experimental/filesystem>
|
||||
|
||||
#include <pddlparse/AST.h>
|
||||
#include <pddlparse/Parse.h>
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
|
||||
const auto pddlInstanceBasePath = fs::path("data") / "pddl-instances";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_CASE("[PDDL parser] The official PDDL instances are parsed correctly", "[PDDL parser]")
|
||||
{
|
||||
std::cout << std::endl;
|
||||
|
||||
pddl::Tokenizer tokenizer;
|
||||
pddl::Context context(std::move(tokenizer), ignoreWarnings);
|
||||
|
||||
SECTION("“either” type in zenotravel domain")
|
||||
{
|
||||
const auto domainFile = pddlInstanceBasePath / "ipc-2002" / "domains" / "zenotravel-numeric-hand-coded" / "domain.pddl";
|
||||
context.tokenizer.read(domainFile);
|
||||
auto description = pddl::parseDescription(context);
|
||||
|
||||
const auto &predicates = description.domain->predicates;
|
||||
|
||||
REQUIRE(predicates.size() == 2);
|
||||
REQUIRE(predicates[0]->name == "at");
|
||||
REQUIRE(predicates[0]->parameters.size() == 2);
|
||||
REQUIRE(predicates[0]->parameters[0]->name == "x");
|
||||
REQUIRE(predicates[0]->parameters[0]->type);
|
||||
CHECK(predicates[0]->parameters[0]->type.value().is<pddl::ast::EitherPointer<pddl::ast::PrimitiveTypePointer>>());
|
||||
REQUIRE(predicates[0]->parameters[1]->name == "c");
|
||||
REQUIRE(predicates[0]->parameters[1]->type);
|
||||
CHECK(predicates[0]->parameters[1]->type.value().is<pddl::ast::PrimitiveTypePointer>());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user