knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
PrologTests.cpp File Reference
#include <boost/algorithm/string/replace.hpp>
#include "knowrob/Logger.h"
#include "knowrob/terms/ListTerm.h"
#include "knowrob/terms/OptionList.h"
#include "knowrob/reasoner/prolog/PrologTests.h"
#include "knowrob/integration/prolog/PrologBackend.h"
#include "knowrob/queries/QueryParser.h"
Include dependency graph for PrologTests.cpp:

Go to the source code of this file.

Namespaces

 knowrob
 
 knowrob::testing
 

Macros

#define EXPECT_ONLY_SOLUTION(phi, sol)
 
#define EXPECT_NO_SOLUTION(phi)   EXPECT_EQ(lookupAll(phi).size(),0)
 

Functions

 TEST_F (PrologReasonerTests, simple_conjunction)
 
 TEST_F (PrologReasonerTests, semweb)
 

Macro Definition Documentation

◆ EXPECT_NO_SOLUTION

#define EXPECT_NO_SOLUTION (   phi)    EXPECT_EQ(lookupAll(phi).size(),0)

Definition at line 127 of file PrologTests.cpp.

◆ EXPECT_ONLY_SOLUTION

#define EXPECT_ONLY_SOLUTION (   phi,
  sol 
)
Value:
{ \
auto sols = lookup(phi); \
EXPECT_EQ(sols.size(),1); \
if(sols.size()==1) { EXPECT_EQ(*sols[0], sol); } }

Definition at line 122 of file PrologTests.cpp.

Function Documentation

◆ TEST_F() [1/2]

TEST_F ( PrologReasonerTests  ,
semweb   
)

Definition at line 147 of file PrologTests.cpp.

147 { runTests(getPath("semweb.pl")); }

◆ TEST_F() [2/2]

TEST_F ( PrologReasonerTests  ,
simple_conjunction   
)

Definition at line 129 of file PrologTests.cpp.

129  {
130  auto p1 = QueryParser::parsePredicate("atom_concat(a,b,AB)");
131  auto p2 = QueryParser::parsePredicate("atom_concat(AB,c,ABC)");
132  auto queryFormula = std::make_shared<SimpleConjunction>(std::vector<FirstOrderLiteralPtr>{
133  std::make_shared<FirstOrderLiteral>(p1, false),
134  std::make_shared<FirstOrderLiteral>(p2, false)
135  });
137  // the query formula:
138  queryFormula,
139  // the expected solution as substitution mapping:
140  Bindings({
141  {std::make_shared<Variable>("AB"), Atom::Tabled("ab")},
142  {std::make_shared<Variable>("ABC"), Atom::Tabled("abc")}
143  }))
144 }
#define EXPECT_ONLY_SOLUTION(phi, sol)