2017-06-15 23:33:25 +02:00
|
|
|
#include <catch.hpp>
|
|
|
|
|
|
|
|
#include <experimental/filesystem>
|
|
|
|
|
|
|
|
#include <pddlparse/AST.h>
|
|
|
|
#include <pddlparse/Parse.h>
|
|
|
|
|
|
|
|
namespace fs = std::experimental::filesystem;
|
|
|
|
|
2017-06-16 04:21:19 +02:00
|
|
|
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
|
|
|
|
const auto pddlInstanceBasePath = fs::path("data") / "pddl-instances";
|
|
|
|
|
2017-06-15 23:33:25 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-06-16 04:21:19 +02:00
|
|
|
TEST_CASE("[PDDL parser acceptance] All official PDDL domains are parsed without errors", "[PDDL parser acceptance]")
|
2017-06-15 23:33:25 +02:00
|
|
|
{
|
2017-06-16 04:21:19 +02:00
|
|
|
for (const auto &competitionDirectory : fs::directory_iterator(pddlInstanceBasePath))
|
2017-06-15 23:33:25 +02:00
|
|
|
{
|
|
|
|
if (!fs::is_directory(competitionDirectory))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (const auto &domainDirectory : fs::directory_iterator(competitionDirectory.path() / "domains"))
|
|
|
|
{
|
|
|
|
if (!fs::is_directory(domainDirectory))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const auto domainFile = domainDirectory / "domain.pddl";
|
|
|
|
|
|
|
|
pddl::Tokenizer tokenizer;
|
|
|
|
tokenizer.read(domainFile);
|
|
|
|
pddl::Context context(std::move(tokenizer), ignoreWarnings);
|
|
|
|
|
|
|
|
CHECK_NOTHROW(pddl::parseDescription(context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-06-16 04:21:19 +02:00
|
|
|
TEST_CASE("[PDDL parser acceptance] The first instance for all official PDDL domains is parsed without errors", "[PDDL parser acceptance]")
|
2017-06-15 23:33:25 +02:00
|
|
|
{
|
2017-06-16 04:21:19 +02:00
|
|
|
for (const auto &competitionDirectory : fs::directory_iterator(pddlInstanceBasePath))
|
2017-06-15 23:33:25 +02:00
|
|
|
{
|
|
|
|
if (!fs::is_directory(competitionDirectory))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (const auto &domainDirectory : fs::directory_iterator(competitionDirectory.path() / "domains"))
|
|
|
|
{
|
|
|
|
if (!fs::is_directory(domainDirectory))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const auto domainFile = domainDirectory / "domain.pddl";
|
|
|
|
const auto instanceFile = domainDirectory / "instances" / "instance-1.pddl";
|
|
|
|
|
|
|
|
pddl::Tokenizer tokenizer;
|
|
|
|
tokenizer.read(domainFile);
|
|
|
|
tokenizer.read(instanceFile);
|
|
|
|
pddl::Context context(std::move(tokenizer), ignoreWarnings);
|
|
|
|
|
|
|
|
CHECK_NOTHROW(pddl::parseDescription(context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|