Implemented computation of derived requirements.
This commit is contained in:
57
tests/TestPDDLParser.cpp
Normal file
57
tests/TestPDDLParser.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <plasp/pddl/Description.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class PDDLParserTests : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
PDDLParserTests()
|
||||
: m_blocksworldDomainFile(readFile("data/blocksworld-domain.pddl"))
|
||||
{
|
||||
}
|
||||
|
||||
static std::stringstream readFile(const std::string &path)
|
||||
{
|
||||
std::ifstream fileStream(path, std::ios::in);
|
||||
|
||||
std::stringstream outputStream;
|
||||
|
||||
if (!fileStream.is_open())
|
||||
throw std::runtime_error("Could not open file \"" + path + "\"");
|
||||
|
||||
outputStream << fileStream.rdbuf();
|
||||
|
||||
return outputStream;
|
||||
}
|
||||
|
||||
std::stringstream m_blocksworldDomainFile;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_F(PDDLParserTests, ParseValidPDDLFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
const auto description = plasp::pddl::Description::fromStream(m_blocksworldDomainFile);
|
||||
|
||||
ASSERT_NO_THROW(description.domain());
|
||||
|
||||
const auto &domain = description.domain();
|
||||
|
||||
ASSERT_EQ(domain.requirements().size(), 2u);
|
||||
ASSERT_EQ(domain.requirements()[0], plasp::pddl::Requirement::Type::STRIPS);
|
||||
ASSERT_EQ(domain.requirements()[1], plasp::pddl::Requirement::Type::Typing);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
FAIL() << e.what();
|
||||
}
|
||||
}
|
@@ -175,11 +175,3 @@ TEST_F(SASParserTests, ParseRequirements)
|
||||
FAIL() << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
Reference in New Issue
Block a user