Added test cases for all competition domains (not all of them supported yet).

This commit is contained in:
Patrick Lühne 2017-06-15 23:33:25 +02:00
parent 0b8da69394
commit 517698475c
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
2 changed files with 65 additions and 26 deletions

View File

@ -0,0 +1,64 @@
#include <catch.hpp>
#include <experimental/filesystem>
#include <pddlparse/AST.h>
#include <pddlparse/Parse.h>
namespace fs = std::experimental::filesystem;
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST_CASE("[PDDL parser] All the IPC domains are parsed without errors", "[PDDL parser]")
{
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
for (const auto &competitionDirectory : fs::directory_iterator("data/pddl-instances"))
{
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));
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST_CASE("[PDDL parser] The first instance of every IPC domain is parsed without errors", "[PDDL parser]")
{
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
for (const auto &competitionDirectory : fs::directory_iterator("data/pddl-instances"))
{
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));
}
}
}

View File

@ -1,27 +1,2 @@
/*#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include <catch.hpp> #include <catch.hpp>
*/
#include <pddlparse/AST.h>
#include <pddlparse/Parse.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
// TODO: reimplement unit tests
int main()
{
const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const auto &){};
pddl::Tokenizer tokenizer;
tokenizer.read("data/blocksworld-domain.pddl");
tokenizer.read("data/blocksworld-problem.pddl");
pddl::Context context(std::move(tokenizer), ignoreWarnings);
const auto description = pddl::parseDescription(context);
std::cout << description.domain->requirements.size() << std::endl;
std::cout << description.domain->predicates.size() << std::endl;
std::cout << description.domain->actions.size() << std::endl;
std::cout << description.problem.value()->name << std::endl;
std::cout << description.problem.value()->objects.size() << std::endl;
}