Started testing PDDL problem parsing for a Blocks World problem.

This commit is contained in:
Patrick Lühne 2016-06-08 13:52:36 +02:00
parent ad23c89266
commit d23ec14e9d
4 changed files with 56 additions and 8 deletions

View File

@ -27,6 +27,7 @@ class Description
public:
const Domain &domain() const;
const Problem &problem() const;
private:
Description();

View File

@ -88,6 +88,15 @@ const Domain &Description::domain() const
////////////////////////////////////////////////////////////////////////////////////////////////////
const Problem &Description::problem() const
{
BOOST_ASSERT(m_problem);
return *m_problem;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Description::parseContent()
{
// First, determine the locations of domain and problem

View File

@ -13,12 +13,12 @@
#include <plasp/pddl/expressions/PrimitiveType.h>
#include <plasp/pddl/expressions/Reference.h>
using namespace plasp::pddl;
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseBlocksWorldDomain)
{
using namespace plasp::pddl;
const auto description = Description::fromFile("data/blocksworld-domain.pddl");
ASSERT_NO_THROW(description.domain());
@ -96,10 +96,38 @@ TEST(PDDLParserTests, ParseBlocksWorldDomain)
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseBlocksWorldProblem)
{
const auto description = Description::fromFiles({"data/blocksworld-domain.pddl", "data/blocksworld-problem.pddl"});
ASSERT_NO_THROW(description.problem());
const auto &problem = description.problem();
// Name
ASSERT_EQ(problem.name(), "blocks-4-0");
ASSERT_EQ(problem.domain().name(), "blocks");
// Requirements
// TODO: compute domain vs. problem requirements correctly and check them
// Objects
ASSERT_EQ(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");
// TODO: check initial state and goal
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseStorageDomain)
{
using namespace plasp::pddl;
const auto description = plasp::pddl::Description::fromFile("data/storage-domain.pddl");
ASSERT_NO_THROW(description.domain());
@ -191,8 +219,6 @@ TEST(PDDLParserTests, ParseStorageDomain)
TEST(PDDLParserTests, ParseConstants)
{
using namespace plasp::pddl;
const auto description = Description::fromFile("data/woodworking-domain.pddl");
ASSERT_NO_THROW(description.domain());
@ -222,7 +248,12 @@ TEST(PDDLParserTests, ParseConstants)
TEST(PDDLParserTests, ParseWithWhiteSpace)
{
using namespace plasp::pddl;
ASSERT_NO_THROW(Description::fromFile("data/white-space-test.pddl"));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(PDDLParserTests, ParseWithoutDomain)
{
ASSERT_THROW(Description::fromFile("data/blocksworld-problem.pddl"), plasp::pddl::ConsistencyException);
}

View File

@ -0,0 +1,7 @@
(define (problem BLOCKS-4-0)
(:domain BLOCKS)
(:objects D B A C - block)
(:INIT (CLEAR C) (CLEAR A) (CLEAR B) (CLEAR D) (ONTABLE C) (ONTABLE A)
(ONTABLE B) (ONTABLE D) (HANDEMPTY))
(:goal (AND (ON D C) (ON C B) (ON B A)))
)