Skip to content

Commit

Permalink
[CI] add isInferred and getInferenceExplanation to transitivity and c…
Browse files Browse the repository at this point in the history
…hain tests
  • Loading branch information
sarthou committed Nov 26, 2024
1 parent 37f97ac commit 3283581
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/tests/CI/reasoning_chain_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ TEST(reasoning_chain, chains_base)
res = onto_ptr->individuals.getOn("ball", "isIn");
EXPECT_TRUE(std::find(res.begin(), res.end(), "box") != res.end());

EXPECT_FALSE(onto_ptr->individuals.isInferred("ball", "isOn", "cube_base"));
EXPECT_TRUE(onto_ptr->individuals.isInferred("ball", "isIn", "box"));
auto exp = onto_ptr->individuals.getInferenceExplanation("ball", "isIn", "box");
EXPECT_EQ(exp.size(), 2);
EXPECT_TRUE(std::find(exp.begin(), exp.end(), "ball|isOn|cube_base") != res.end());
EXPECT_TRUE(std::find(exp.begin(), exp.end(), "cube_base|isIn|box") != res.end());

res = onto_ptr->individuals.getOn("ball", "thirdChain");
EXPECT_TRUE(std::find(res.begin(), res.end(), "table") != res.end());

Expand Down Expand Up @@ -54,6 +61,14 @@ TEST(reasoning_chain, chain_heritance)
res = onto_ptr->individuals.getOn("ball", "isIn");
EXPECT_TRUE(find(res.begin(), res.end(), "box") != res.end());

EXPECT_FALSE(onto_ptr->individuals.isInferred("ball", "isOnTop", "cube_base"));
EXPECT_TRUE(onto_ptr->individuals.isInferred("ball", "isIn", "box"));
auto exp = onto_ptr->individuals.getInferenceExplanation("ball", "isIn", "box");
EXPECT_EQ(exp.size(), 3);
EXPECT_TRUE(std::find(exp.begin(), exp.end(), "ball|isOnTop|cube_base") != res.end());
EXPECT_TRUE(std::find(exp.begin(), exp.end(), "isOnTop|isA|isOn") != res.end());
EXPECT_TRUE(std::find(exp.begin(), exp.end(), "cube_base|isIn|box") != res.end());

res = onto_ptr->individuals.getOn("ball", "thirdChain");
EXPECT_TRUE(find(res.begin(), res.end(), "table") != res.end());

Expand Down
7 changes: 7 additions & 0 deletions src/tests/CI/reasoning_transitivity_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ TEST(reasoning_transitivity, transitivity_base)
EXPECT_TRUE(std::find(res.begin(), res.end(), "b") != res.end());
EXPECT_TRUE(std::find(res.begin(), res.end(), "c") != res.end());

EXPECT_FALSE(onto_ptr->individuals.isInferred("a", "topTransitiveProperty", "b"));
EXPECT_TRUE(onto_ptr->individuals.isInferred("a", "topTransitiveProperty", "c"));
auto exp = onto_ptr->individuals.getInferenceExplanation("a", "topTransitiveProperty", "c");
EXPECT_EQ(exp.size(), 2);
EXPECT_TRUE(std::find(exp.begin(), exp.end(), "a|topTransitiveProperty|b") != res.end());
EXPECT_TRUE(std::find(exp.begin(), exp.end(), "b|topTransitiveProperty|c") != res.end());

onto_ptr->feeder.addRelation("c", "topTransitiveProperty", "d");
onto_ptr->feeder.waitUpdate(WAIT_TIME);

Expand Down

0 comments on commit 3283581

Please sign in to comment.