From 152e2b6cff68af97efa25a200701788c9c9d5e7d Mon Sep 17 00:00:00 2001 From: Guillaume Sarthou Date: Thu, 31 Oct 2024 15:05:50 +0100 Subject: [PATCH] [CI] update CI tests --- src/tests/CI/copy_test.cpp | 8 +- src/tests/CI/globalFeatures.cpp | 45 +- src/tests/CI/library.cpp | 78 +- src/tests/CI/propertiesInheritage.cpp | 817 +++++++++------------ src/tests/CI/propertiesInheritageIndex.cpp | 510 ++++++------- src/tests/CI/requests.cpp | 178 ++--- 6 files changed, 710 insertions(+), 926 deletions(-) diff --git a/src/tests/CI/copy_test.cpp b/src/tests/CI/copy_test.cpp index 318712ef..75e03c4d 100644 --- a/src/tests/CI/copy_test.cpp +++ b/src/tests/CI/copy_test.cpp @@ -32,8 +32,8 @@ TEST(cpy_tests, reset) const std::string indiv = "redCube"; - EXPECT_TRUE(onto1.individual_graph_.getUp(indiv).size() == 11); - EXPECT_TRUE(onto2.individual_graph_.getUp(indiv).size() == 11); + EXPECT_EQ(onto1.individual_graph_.getUp(indiv).size(), 11); + EXPECT_EQ(onto2.individual_graph_.getUp(indiv).size(), 11); std::string type = "cube"; onto2.individual_graph_.removeInheritage(indiv, type); @@ -43,8 +43,8 @@ TEST(cpy_tests, reset) std::cout << "onto1 " << onto1.individual_graph_.getUp(indiv).size() << std::endl; std::cout << "onto2 " << onto2.individual_graph_.getUp(indiv).size() << std::endl; - EXPECT_TRUE(onto1.individual_graph_.getUp(indiv).size() == 11); - EXPECT_TRUE(onto2.individual_graph_.getUp(indiv).size() == 7); + EXPECT_EQ(onto1.individual_graph_.getUp(indiv).size(), 11); + EXPECT_EQ(onto2.individual_graph_.getUp(indiv).size(), 7); } int main(int argc, char** argv) diff --git a/src/tests/CI/globalFeatures.cpp b/src/tests/CI/globalFeatures.cpp index 70243a3b..65d75819 100644 --- a/src/tests/CI/globalFeatures.cpp +++ b/src/tests/CI/globalFeatures.cpp @@ -13,24 +13,24 @@ TEST(global_tests, reset) { std::vector res; - std::string test_word = "affair"; - res = onto_ptr->classes.find(test_word); - EXPECT_TRUE((res.size() == 1) && (res[0] == "affair")); + res = onto_ptr->classes.find("affair"); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "affair"); - test_word = "centimeter"; - res = onto_ptr->classes.find(test_word); - EXPECT_TRUE((res.size() == 1) && (res[0] == "centimeter")); + res = onto_ptr->classes.find("centimeter"); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "centimeter"); EXPECT_TRUE(onto_ptr->actions.clear()); EXPECT_TRUE(onto_ptr->actions.close()); - test_word = "affair"; - res = onto_ptr->classes.find(test_word); - EXPECT_FALSE((res.size() == 1) && (res[0] == "affair")); + res = onto_ptr->classes.find("affair"); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "affair"); - test_word = "centimeter"; - res = onto_ptr->classes.find(test_word); - EXPECT_FALSE((res.size() == 1) && (res[0] == "centimeter")); + res = onto_ptr->classes.find("centimeter"); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "centimeter"); EXPECT_TRUE(onto_ptr->actions.clear()); std::string path = ros::package::getPath("ontologenius"); @@ -39,13 +39,13 @@ TEST(global_tests, reset) EXPECT_TRUE(onto_ptr->actions.close()); - test_word = "affair"; - res = onto_ptr->classes.find(test_word); - EXPECT_TRUE((res.size() == 1) && (res[0] == "affair")); + res = onto_ptr->classes.find("affair"); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "affair"); - test_word = "centimeter"; - res = onto_ptr->classes.find(test_word); - EXPECT_FALSE((res.size() == 1) && (res[0] == "centimeter")); + res = onto_ptr->classes.find("centimeter"); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "centimeter"); } TEST(global_tests, language) @@ -63,7 +63,8 @@ TEST(global_tests, language) std::string test_word = "affair"; res = onto_ptr->classes.find(test_word); - EXPECT_TRUE((res.size() == 1) && (res[0] == "affair")); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "affair"); EXPECT_TRUE(onto_ptr->classes.getName(test_word) == "affair"); EXPECT_FALSE(onto_ptr->classes.getName(test_word) == "affaire"); @@ -71,11 +72,13 @@ TEST(global_tests, language) EXPECT_TRUE(onto_ptr->actions.setLang("fr")); res = onto_ptr->classes.find(test_word); - EXPECT_TRUE((res.size() == 1) && (res[0] == "affair")); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "affair"); test_word = "affaire"; res = onto_ptr->classes.find(test_word); - EXPECT_TRUE((res.size() == 1) && (res[0] == "affair")); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "affair"); test_word = "affair"; EXPECT_TRUE(onto_ptr->classes.getName(test_word) == "affaire"); diff --git a/src/tests/CI/library.cpp b/src/tests/CI/library.cpp index 9684ae29..296310a9 100644 --- a/src/tests/CI/library.cpp +++ b/src/tests/CI/library.cpp @@ -9,91 +9,47 @@ onto::OntologyManipulator* onto_ptr; TEST(library_tests, close_call) { - bool res_bool = onto_ptr->close(); - EXPECT_TRUE(res_bool); + EXPECT_TRUE(onto_ptr->close()); } TEST(library_tests, individuals_call) { - std::string test_word = "test"; - bool res_bool = true; - - for(size_t i = 0; i < 10; i++) - { - std::vector res = onto_ptr->individuals.getUp(test_word); - res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL")); - } - - EXPECT_TRUE(res_bool); + std::vector res = onto_ptr->individuals.getUp("test"); + EXPECT_NE(res.size(), 1); + EXPECT_NE(res.front(), "ERR:SERVICE_FAIL"); } TEST(library_tests, objectProperties_call) { - std::string test_word = "test"; - bool res_bool = true; - - for(size_t i = 0; i < 10; i++) - { - std::vector res = onto_ptr->objectProperties.getUp(test_word); - res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL")); - } - - EXPECT_TRUE(res_bool); + std::vector res = onto_ptr->objectProperties.getUp("test"); + EXPECT_NE(res.size(), 1); + EXPECT_NE(res.front(), "ERR:SERVICE_FAIL"); } TEST(library_tests, dataProperties_call) { - std::string test_word = "test"; - bool res_bool = true; - - for(size_t i = 0; i < 10; i++) - { - std::vector res = onto_ptr->dataProperties.getUp(test_word); - res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL")); - } - - EXPECT_TRUE(res_bool); + std::vector res = onto_ptr->dataProperties.getUp("test"); + EXPECT_NE(res.size(), 1); + EXPECT_NE(res.front(), "ERR:SERVICE_FAIL"); } TEST(library_tests, classes_call) { - std::vector res; - std::string test_word = "test"; - bool res_bool = true; - - for(size_t i = 0; i < 10; i++) - { - res = onto_ptr->classes.getUp(test_word); - res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL")); - } - - EXPECT_TRUE(res_bool); + std::vector res = onto_ptr->classes.getUp("test"); + EXPECT_NE(res.size(), 1); + EXPECT_NE(res.front(), "ERR:SERVICE_FAIL"); } TEST(library_tests, actions_call) { - bool res_bool = true; - - for(size_t i = 0; i < 10; i++) - { - res_bool = res_bool && onto_ptr->actions.setLang("en"); - } - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(onto_ptr->actions.setLang("en")); } TEST(library_tests, reasoners_call) { - std::vector res; - bool res_bool = true; - - for(size_t i = 0; i < 10; i++) - { - res = onto_ptr->reasoners.list(); - res_bool = res_bool && ((res.size() != 1) || (res[0] != "ERR:SERVICE_FAIL")); - } - - EXPECT_TRUE(res_bool); + std::vector res = onto_ptr->reasoners.list(); + EXPECT_NE(res.size(), 1); + EXPECT_NE(res.front(), "ERR:SERVICE_FAIL"); } int main(int argc, char** argv) diff --git a/src/tests/CI/propertiesInheritage.cpp b/src/tests/CI/propertiesInheritage.cpp index 8d525569..ab875559 100644 --- a/src/tests/CI/propertiesInheritage.cpp +++ b/src/tests/CI/propertiesInheritage.cpp @@ -12,246 +12,218 @@ onto::OntologyManipulator* onto_ptr; TEST(global_tests, class_getRelationFrom) { std::vector res; - std::string test_word = "human"; bool res_bool = true; - res = onto_ptr->classes.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "hasFather") != res.end()) && - (std::find(res.begin(), res.end(), "hasMother") != res.end()) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end()) && - (std::find(res.begin(), res.end(), "hasParent") != res.end())); - - test_word = "man"; - res = onto_ptr->classes.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "hasFather") != res.end()) && - (std::find(res.begin(), res.end(), "hasMother") != res.end()) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end()) && - (std::find(res.begin(), res.end(), "hasParent") != res.end())); - - test_word = "cube"; - res = onto_ptr->classes.getRelationFrom(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->classes.getRelationFrom("human"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "hasFather") != res.end()) && + (std::find(res.begin(), res.end(), "hasMother") != res.end()) && + (std::find(res.begin(), res.end(), "hasLeg") != res.end()) && + (std::find(res.begin(), res.end(), "hasParent") != res.end())); + EXPECT_TRUE(res_bool); + res = onto_ptr->classes.getRelationFrom("man"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "hasFather") != res.end()) && + (std::find(res.begin(), res.end(), "hasMother") != res.end()) && + (std::find(res.begin(), res.end(), "hasLeg") != res.end()) && + (std::find(res.begin(), res.end(), "hasParent") != res.end())); EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelationFrom("cube"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelatedFrom) { std::vector res; - std::string test_word = "hasLeg"; bool res_bool = true; - res = onto_ptr->classes.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "child") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "hasParent"; - res = onto_ptr->classes.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "child") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "hasMother"; - res = onto_ptr->classes.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "child") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "isOn"; - res = onto_ptr->classes.getRelatedFrom(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->classes.getRelatedFrom("hasLeg"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); + EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelatedFrom("hasParent"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); + EXPECT_TRUE(res_bool); + res = onto_ptr->classes.getRelatedFrom("hasMother"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelatedFrom("isOn"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelationOn) { std::vector res; - std::string test_word = "woman"; bool res_bool = true; - res = onto_ptr->classes.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "hasMother") != res.end()) && - (std::find(res.begin(), res.end(), "hasParent") != res.end())); - - test_word = "integer#2"; - res = onto_ptr->classes.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end())); - - test_word = "integer#0"; - res = onto_ptr->classes.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end())); + res = onto_ptr->classes.getRelationOn("woman"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "hasMother") != res.end()) && + (std::find(res.begin(), res.end(), "hasParent") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "human"; - res = onto_ptr->classes.getRelationOn(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->classes.getRelationOn("integer#2"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "hasLeg") != res.end()); + EXPECT_TRUE(res_bool); + res = onto_ptr->classes.getRelationOn("integer#0"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "hasLeg") != res.end()); EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelationOn("human"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelatedOn) { std::vector res; - std::string test_word = "hasLeg"; bool res_bool = true; - res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "integer#0") != res.end()) && - (std::find(res.begin(), res.end(), "integer#2") != res.end())); - - test_word = "hasMother"; - res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "hasFather"; - res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "man") != res.end())); + res = onto_ptr->classes.getRelatedOn("hasLeg"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "integer#0") != res.end()) && + (std::find(res.begin(), res.end(), "integer#2") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "hasParent"; - res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); + res = onto_ptr->classes.getRelatedOn("hasMother"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "woman") != res.end()); + EXPECT_TRUE(res_bool); - test_word = "isOn"; - res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->classes.getRelatedOn("hasFather"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "man") != res.end()); + EXPECT_TRUE(res_bool); + res = onto_ptr->classes.getRelatedOn("hasParent"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelatedOn("isOn"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelationWith) { std::vector res; - std::string test_word = "human"; bool res_bool = true; - res = onto_ptr->classes.getRelationWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "integer#2") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "child"; - res = onto_ptr->classes.getRelationWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "integer#2") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "man"; - res = onto_ptr->classes.getRelationWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "integer#0") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); + res = onto_ptr->classes.getRelationWith("human"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "integer#2") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "cube"; - res = onto_ptr->classes.getRelationWith(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->classes.getRelationWith("child"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "integer#2") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); + EXPECT_TRUE(res_bool); + res = onto_ptr->classes.getRelationWith("man"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "integer#0") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelationWith("cube"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelatedWith) { std::vector res; - std::string test_word = "woman"; bool res_bool = true; - res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "child") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "man"; - res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "child") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "integer#2"; - res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "child") != res.end()) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end())); - - test_word = "integer#0"; - res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "man") != res.end())); - - test_word = "human"; - res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->classes.getRelatedWith("woman"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); + EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelatedWith("man"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); + EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelatedWith("integer#2"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && + (std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end())); + EXPECT_TRUE(res_bool); + res = onto_ptr->classes.getRelatedWith("integer#0"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "man") != res.end()); EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getRelatedWith("human"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getFrom) { std::vector res; - std::string test_word = "woman"; - std::string test_word2 = "hasMother"; bool res_bool = true; - res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = ((res.size() == 4) && - (std::find(res.begin(), res.end(), "child") != res.end()) && + res = onto_ptr->classes.getFrom("hasMother", "woman"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && (std::find(res.begin(), res.end(), "man") != res.end()) && (std::find(res.begin(), res.end(), "human") != res.end()) && (std::find(res.begin(), res.end(), "woman") != res.end())); EXPECT_TRUE(res_bool); - test_word = "woman"; - test_word2 = "hasParent"; - res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = ((res.size() == 4) && - (std::find(res.begin(), res.end(), "child") != res.end()) && + res = onto_ptr->classes.getFrom("hasParent", "woman"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && (std::find(res.begin(), res.end(), "man") != res.end()) && (std::find(res.begin(), res.end(), "human") != res.end()) && (std::find(res.begin(), res.end(), "woman") != res.end())); EXPECT_TRUE(res_bool); - test_word = "integer#2"; - test_word2 = "hasLeg"; - res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), "child") != res.end()) && + res = onto_ptr->classes.getFrom("hasLeg", "integer#2"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "child") != res.end()) && (std::find(res.begin(), res.end(), "human") != res.end()) && (std::find(res.begin(), res.end(), "woman") != res.end())); EXPECT_TRUE(res_bool); - test_word = "integer#0"; - test_word2 = "hasLeg"; - res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "man") != res.end())); + res = onto_ptr->classes.getFrom("hasLeg", "integer#0"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "man") != res.end()); EXPECT_TRUE(res_bool); - test_word = "man"; - test_word2 = "hasMother"; - res = onto_ptr->classes.getFrom(test_word2, test_word); + res = onto_ptr->classes.getFrom("hasMother", "man"); res_bool = (res.empty()); EXPECT_TRUE(res_bool); } @@ -259,93 +231,70 @@ TEST(global_tests, class_getFrom) TEST(global_tests, class_getOn) { std::vector res; - std::string test_word = "man"; - std::string test_word2 = "hasLeg"; bool res_bool = true; - res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "integer#0") != res.end())); + res = onto_ptr->classes.getOn("man", "hasLeg"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "integer#0") != res.end()); EXPECT_TRUE(res_bool); - test_word = "child"; - test_word2 = "hasLeg"; - res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "integer#2") != res.end())); + res = onto_ptr->classes.getOn("child", "hasLeg"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "integer#2") != res.end()); EXPECT_TRUE(res_bool); - test_word = "woman"; - test_word2 = "hasFather"; - res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "man") != res.end())); + res = onto_ptr->classes.getOn("woman", "hasFather"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "man") != res.end()); EXPECT_TRUE(res_bool); - test_word = "human"; - test_word2 = "hasMother"; - res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "woman") != res.end())); + res = onto_ptr->classes.getOn("human", "hasMother"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "woman") != res.end()); EXPECT_TRUE(res_bool); - test_word = "human"; - test_word2 = "hasParent"; - res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), "woman") != res.end()) && + res = onto_ptr->classes.getOn("human", "hasParent"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "woman") != res.end()) && (std::find(res.begin(), res.end(), "man") != res.end())); EXPECT_TRUE(res_bool); - test_word = "cube"; - test_word2 = "isOn"; - res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + res = onto_ptr->classes.getOn("cube", "isOn"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getWith) { std::vector res; - std::string test_word = "human"; - std::string test_word2 = "man"; bool res_bool = true; - res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "hasFather") != res.end()) && - (std::find(res.begin(), res.end(), "hasParent") != res.end())); + res = onto_ptr->classes.getWith("human", "man"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "hasFather") != res.end()) && + (std::find(res.begin(), res.end(), "hasParent") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "man"; - test_word2 = "man"; - res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "hasFather") != res.end()) && - (std::find(res.begin(), res.end(), "hasParent") != res.end())); + res = onto_ptr->classes.getWith("man", "man"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "hasFather") != res.end()) && + (std::find(res.begin(), res.end(), "hasParent") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "child"; - test_word2 = "integer#2"; - res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end())); - - test_word = "man"; - test_word2 = "integer#0"; - res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end())); - - test_word = "human"; - test_word2 = "human"; - res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && (res.empty()); - - test_word = "man"; - test_word2 = "integer#2"; - res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && (res.empty()); + res = onto_ptr->classes.getWith("child", "integer#2"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "hasLeg") != res.end()); + EXPECT_TRUE(res_bool); + res = onto_ptr->classes.getWith("man", "integer#0"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "hasLeg") != res.end()); EXPECT_TRUE(res_bool); + + res = onto_ptr->classes.getWith("human", "human"); + EXPECT_TRUE(res.empty()); + + res = onto_ptr->classes.getWith("man", "integer#2"); + EXPECT_TRUE(res.empty()); } /******************* @@ -357,176 +306,161 @@ TEST(global_tests, class_getWith) TEST(global_tests, individual_getRelationFrom) { std::vector res; - std::string test_word = "alice"; bool res_bool = true; - res = onto_ptr->individuals.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "hasFather") != res.end()) && - (std::find(res.begin(), res.end(), "hasMother") != res.end()) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end()) && - (std::find(res.begin(), res.end(), "hasParent") != res.end())); - - test_word = "kevin"; - res = onto_ptr->individuals.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "hasFather") != res.end()) && - (std::find(res.begin(), res.end(), "hasMother") != res.end()) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end()) && - (std::find(res.begin(), res.end(), "hasParent") != res.end())); - - test_word = "cube1"; - res = onto_ptr->individuals.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 5) && - (std::find(res.begin(), res.end(), "isPositioned") != res.end()) && - (std::find(res.begin(), res.end(), "isOn") != res.end()) && - (std::find(res.begin(), res.end(), "objectHave3Dposition") != res.end()) && - (std::find(res.begin(), res.end(), "isIn") != res.end()) && - (std::find(res.begin(), res.end(), "have3Dposition") != res.end())); - - test_word = "man"; - res = onto_ptr->individuals.getRelationFrom(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->individuals.getRelationFrom("alice"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "hasFather") != res.end()) && + (std::find(res.begin(), res.end(), "hasMother") != res.end()) && + (std::find(res.begin(), res.end(), "hasLeg") != res.end()) && + (std::find(res.begin(), res.end(), "hasParent") != res.end())); + EXPECT_TRUE(res_bool); + res = onto_ptr->individuals.getRelationFrom("kevin"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "hasFather") != res.end()) && + (std::find(res.begin(), res.end(), "hasMother") != res.end()) && + (std::find(res.begin(), res.end(), "hasLeg") != res.end()) && + (std::find(res.begin(), res.end(), "hasParent") != res.end())); EXPECT_TRUE(res_bool); + + res = onto_ptr->individuals.getRelationFrom("cube1"); + EXPECT_EQ(res.size(), 5); + res_bool = ((std::find(res.begin(), res.end(), "isPositioned") != res.end()) && + (std::find(res.begin(), res.end(), "isOn") != res.end()) && + (std::find(res.begin(), res.end(), "objectHave3Dposition") != res.end()) && + (std::find(res.begin(), res.end(), "isIn") != res.end()) && + (std::find(res.begin(), res.end(), "have3Dposition") != res.end())); + EXPECT_TRUE(res_bool); + + res = onto_ptr->individuals.getRelationFrom("man"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getRelatedFrom) { std::vector res; - std::string test_word = "hasLeg"; bool res_bool = true; - res = onto_ptr->individuals.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && - (std::find(res.begin(), res.end(), "alice") != res.end()) && - (std::find(res.begin(), res.end(), "bob") != res.end())); - - test_word = "hasParent"; - res = onto_ptr->individuals.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && - (std::find(res.begin(), res.end(), "alice") != res.end()) && - (std::find(res.begin(), res.end(), "bob") != res.end())); - - test_word = "isOn"; - res = onto_ptr->individuals.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "cube1") != res.end()) && - (std::find(res.begin(), res.end(), "mini_box") != res.end()) && - (std::find(res.begin(), res.end(), "greenCube") != res.end()) && - (std::find(res.begin(), res.end(), "blueCube") != res.end())); + res = onto_ptr->individuals.getRelatedFrom("hasLeg"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && + (std::find(res.begin(), res.end(), "alice") != res.end()) && + (std::find(res.begin(), res.end(), "bob") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "human"; - res = onto_ptr->individuals.getRelatedFrom(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->individuals.getRelatedFrom("hasParent"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && + (std::find(res.begin(), res.end(), "alice") != res.end()) && + (std::find(res.begin(), res.end(), "bob") != res.end())); + EXPECT_TRUE(res_bool); + res = onto_ptr->individuals.getRelatedFrom("isOn"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "cube1") != res.end()) && + (std::find(res.begin(), res.end(), "mini_box") != res.end()) && + (std::find(res.begin(), res.end(), "greenCube") != res.end()) && + (std::find(res.begin(), res.end(), "blueCube") != res.end())); EXPECT_TRUE(res_bool); + + res = onto_ptr->individuals.getRelatedFrom("human"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getRelationOn) { std::vector res; - std::string test_word = "alice"; bool res_bool = true; - res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "hasMother") != res.end()) && - (std::find(res.begin(), res.end(), "hasParent") != res.end())); - - test_word = "cube1"; - res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "isUnder") != res.end()) && - (std::find(res.begin(), res.end(), "isPositioned") != res.end())); - - test_word = "integer#2"; - res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end())); + res = onto_ptr->individuals.getRelationOn("alice"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "hasMother") != res.end()) && + (std::find(res.begin(), res.end(), "hasParent") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "integer#0"; - res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end())); + res = onto_ptr->individuals.getRelationOn("cube1"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "isUnder") != res.end()) && + (std::find(res.begin(), res.end(), "isPositioned") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "human"; - res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->individuals.getRelationOn("integer#2"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "hasLeg") != res.end()); + EXPECT_TRUE(res_bool); + res = onto_ptr->individuals.getRelationOn("integer#0"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "hasLeg") != res.end()); EXPECT_TRUE(res_bool); + + res = onto_ptr->individuals.getRelationOn("human"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getRelatedOn) { std::vector res; - std::string test_word = "hasLeg"; bool res_bool = true; - res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "integer#0") != res.end()) && - (std::find(res.begin(), res.end(), "integer#2") != res.end())); - - test_word = "hasMother"; - res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "alice") != res.end())); + res = onto_ptr->individuals.getRelatedOn("hasLeg"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "integer#0") != res.end()) && + (std::find(res.begin(), res.end(), "integer#2") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "hasFather"; - res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "bob") != res.end())); + res = onto_ptr->individuals.getRelatedOn("hasMother"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "alice") != res.end()); + EXPECT_TRUE(res_bool); - test_word = "hasParent"; - res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "bob") != res.end()) && - (std::find(res.begin(), res.end(), "alice") != res.end())); + res = onto_ptr->individuals.getRelatedOn("hasFather"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "bob") != res.end()); + EXPECT_TRUE(res_bool); - test_word = "isIn"; - res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "big_box") != res.end())); + res = onto_ptr->individuals.getRelatedOn("hasParent"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "bob") != res.end()) && + (std::find(res.begin(), res.end(), "alice") != res.end())); + EXPECT_TRUE(res_bool); + res = onto_ptr->individuals.getRelatedOn("isIn"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "big_box") != res.end()); EXPECT_TRUE(res_bool); } TEST(global_tests, individual_getRelationWith) { std::vector res; - std::string test_word = "alice"; bool res_bool = true; - res = onto_ptr->individuals.getRelationWith(test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), "integer#2") != res.end()) && + res = onto_ptr->individuals.getRelationWith("alice"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "integer#2") != res.end()) && (std::find(res.begin(), res.end(), "man") != res.end()) && (std::find(res.begin(), res.end(), "woman") != res.end())); EXPECT_TRUE(res_bool); - test_word = "kevin"; - res = onto_ptr->individuals.getRelationWith(test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), "integer#0") != res.end()) && + res = onto_ptr->individuals.getRelationWith("kevin"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "integer#0") != res.end()) && (std::find(res.begin(), res.end(), "bob") != res.end()) && (std::find(res.begin(), res.end(), "alice") != res.end())); EXPECT_TRUE(res_bool); - test_word = "bob"; - res = onto_ptr->individuals.getRelationWith(test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), "integer#0") != res.end()) && + res = onto_ptr->individuals.getRelationWith("bob"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "integer#0") != res.end()) && (std::find(res.begin(), res.end(), "man") != res.end()) && (std::find(res.begin(), res.end(), "woman") != res.end())); EXPECT_TRUE(res_bool); - test_word = "cube1"; - res = onto_ptr->individuals.getRelationWith(test_word); - res_bool = ((res.size() == 4) && - (std::find(res.begin(), res.end(), "integer#236") != res.end()) && + res = onto_ptr->individuals.getRelationWith("cube1"); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), "integer#236") != res.end()) && (std::find(res.begin(), res.end(), "big_box") != res.end()) && (std::find(res.begin(), res.end(), "blueCube") != res.end()) && (std::find(res.begin(), res.end(), "redCube") != res.end())); @@ -536,202 +470,157 @@ TEST(global_tests, individual_getRelationWith) TEST(global_tests, individual_getRelatedWith) { std::vector res; - std::string test_word = "woman"; bool res_bool = true; - res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && - (std::find(res.begin(), res.end(), "alice") != res.end()) && - (std::find(res.begin(), res.end(), "bob") != res.end())); - - test_word = "man"; - res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && - (std::find(res.begin(), res.end(), "alice") != res.end()) && - (std::find(res.begin(), res.end(), "bob") != res.end())); - - test_word = "integer#2"; - res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), "alice") != res.end())); + res = onto_ptr->individuals.getRelatedWith("woman"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && + (std::find(res.begin(), res.end(), "alice") != res.end()) && + (std::find(res.begin(), res.end(), "bob") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "integer#0"; - res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && - (std::find(res.begin(), res.end(), "bob") != res.end())); + res = onto_ptr->individuals.getRelatedWith("man"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && + (std::find(res.begin(), res.end(), "alice") != res.end()) && + (std::find(res.begin(), res.end(), "bob") != res.end())); + EXPECT_TRUE(res_bool); - test_word = "human"; - res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && (res.empty()); + res = onto_ptr->individuals.getRelatedWith("integer#2"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "alice") != res.end()); + EXPECT_TRUE(res_bool); + res = onto_ptr->individuals.getRelatedWith("integer#0"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && + (std::find(res.begin(), res.end(), "bob") != res.end())); EXPECT_TRUE(res_bool); + + res = onto_ptr->individuals.getRelatedWith("human"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getFrom) { std::vector res; - std::string test_word = "woman"; - std::string test_word2 = "hasMother"; bool res_bool = true; - res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && + res = onto_ptr->individuals.getFrom("hasMother", "woman"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && (std::find(res.begin(), res.end(), "alice") != res.end()) && (std::find(res.begin(), res.end(), "bob") != res.end())); EXPECT_TRUE(res_bool); - test_word = "woman"; - test_word2 = "hasParent"; - res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && + res = onto_ptr->individuals.getFrom("hasParent", "woman"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && (std::find(res.begin(), res.end(), "alice") != res.end()) && (std::find(res.begin(), res.end(), "bob") != res.end())); EXPECT_TRUE(res_bool); - test_word = "human"; - test_word2 = "hasParent"; - res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && + res = onto_ptr->individuals.getFrom("hasParent", "human"); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && (std::find(res.begin(), res.end(), "alice") != res.end()) && (std::find(res.begin(), res.end(), "bob") != res.end())); EXPECT_TRUE(res_bool); - test_word = "integer#0"; - test_word2 = "hasLeg"; - res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), "kevin") != res.end()) && + res = onto_ptr->individuals.getFrom("hasLeg", "integer#0"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "kevin") != res.end()) && (std::find(res.begin(), res.end(), "bob") != res.end())); EXPECT_TRUE(res_bool); - test_word = "integer#2"; - test_word2 = "hasLeg"; - res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "alice") != res.end())); + res = onto_ptr->individuals.getFrom("hasLeg", "integer#2"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "alice") != res.end()); EXPECT_TRUE(res_bool); - test_word = "man"; - test_word2 = "hasMother"; - res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + res = onto_ptr->individuals.getFrom("hasMother", "man"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getOn) { std::vector res; - std::string test_word = "bob"; - std::string test_word2 = "hasLeg"; bool res_bool = true; - res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "integer#0") != res.end())); + res = onto_ptr->individuals.getOn("bob", "hasLeg"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "integer#0") != res.end()); EXPECT_TRUE(res_bool); - test_word = "kevin"; - test_word2 = "hasLeg"; - res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "integer#0") != res.end())); + res = onto_ptr->individuals.getOn("kevin", "hasLeg"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "integer#0") != res.end()); EXPECT_TRUE(res_bool); - test_word = "alice"; - test_word2 = "hasFather"; - res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "man") != res.end())); + res = onto_ptr->individuals.getOn("alice", "hasFather"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "man") != res.end()); EXPECT_TRUE(res_bool); - test_word = "bob"; - test_word2 = "hasMother"; - res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "woman") != res.end())); + res = onto_ptr->individuals.getOn("bob", "hasMother"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "woman") != res.end()); EXPECT_TRUE(res_bool); - test_word = "alice"; - test_word2 = "hasParent"; - res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), "woman") != res.end()) && + res = onto_ptr->individuals.getOn("alice", "hasParent"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "woman") != res.end()) && (std::find(res.begin(), res.end(), "man") != res.end())); EXPECT_TRUE(res_bool); - test_word = "kevin"; - test_word2 = "hasParent"; - res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), "alice") != res.end()) && + res = onto_ptr->individuals.getOn("kevin", "hasParent"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "alice") != res.end()) && (std::find(res.begin(), res.end(), "bob") != res.end())); EXPECT_TRUE(res_bool); - test_word = "man"; - test_word2 = "hasLeg"; - res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + res = onto_ptr->individuals.getOn("man", "hasLeg"); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getWith) { std::vector res; - std::string test_word = "kevin"; - std::string test_word2 = "bob"; bool res_bool = true; - res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), "hasFather") != res.end()) && + res = onto_ptr->individuals.getWith("kevin", "bob"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "hasFather") != res.end()) && (std::find(res.begin(), res.end(), "hasParent") != res.end())); EXPECT_TRUE(res_bool); - test_word = "bob"; - test_word2 = "man"; - res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), "hasFather") != res.end()) && + res = onto_ptr->individuals.getWith("bob", "man"); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "hasFather") != res.end()) && (std::find(res.begin(), res.end(), "hasParent") != res.end())); EXPECT_TRUE(res_bool); - test_word = "alice"; - test_word2 = "integer#2"; - res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end())); + res = onto_ptr->individuals.getWith("alice", "integer#2"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "hasLeg") != res.end()); EXPECT_TRUE(res_bool); - test_word = "bob"; - test_word2 = "integer#0"; - res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), "hasLeg") != res.end())); + res = onto_ptr->individuals.getWith("bob", "integer#0"); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), "hasLeg") != res.end()); EXPECT_TRUE(res_bool); - test_word = "alice"; - test_word2 = "human"; - res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + res = onto_ptr->individuals.getWith("alice", "human"); + EXPECT_TRUE(res.empty()); test_word = "bob"; test_word2 = "integer#2"; res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); - test_word = "cube1"; - test_word2 = "redCube"; - res = onto_ptr->individuals.getWith(test_word, test_word2); // use same as (cube1 = greenCube) - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), "isPositioned") != res.end()) && + res = onto_ptr->individuals.getWith("cube1", "redCube"); // use same as (cube1 = greenCube) + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), "isPositioned") != res.end()) && (std::find(res.begin(), res.end(), "isOn") != res.end())); EXPECT_TRUE(res_bool); } diff --git a/src/tests/CI/propertiesInheritageIndex.cpp b/src/tests/CI/propertiesInheritageIndex.cpp index 5f84d2dc..6c5ad979 100644 --- a/src/tests/CI/propertiesInheritageIndex.cpp +++ b/src/tests/CI/propertiesInheritageIndex.cpp @@ -16,25 +16,25 @@ TEST(global_tests, class_getRelationFrom) bool res_bool = true; res = onto_ptr->classes.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); res = onto_ptr->classes.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("cube"); res = onto_ptr->classes.getRelationFrom(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelatedFrom) @@ -44,33 +44,34 @@ TEST(global_tests, class_getRelatedFrom) bool res_bool = true; res = onto_ptr->classes.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->classes.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasMother"); res = onto_ptr->classes.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("isOn"); res = onto_ptr->classes.getRelatedFrom(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelationOn) @@ -80,25 +81,26 @@ TEST(global_tests, class_getRelationOn) bool res_bool = true; res = onto_ptr->classes.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#2"); res = onto_ptr->classes.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#0"); res = onto_ptr->classes.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("human"); res = onto_ptr->classes.getRelationOn(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelatedOn) @@ -108,31 +110,33 @@ TEST(global_tests, class_getRelatedOn) bool res_bool = true; res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasMother"); res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasFather"); res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("isOn"); res = onto_ptr->classes.getRelatedOn(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelationWith) @@ -142,30 +146,31 @@ TEST(global_tests, class_getRelationWith) bool res_bool = true; res = onto_ptr->classes.getRelationWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("child"); res = onto_ptr->classes.getRelationWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); res = onto_ptr->classes.getRelationWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("cube"); res = onto_ptr->classes.getRelationWith(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getRelatedWith) @@ -175,37 +180,39 @@ TEST(global_tests, class_getRelatedWith) bool res_bool = true; res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#2"); res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#0"); res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("human"); res = onto_ptr->classes.getRelatedWith(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getFrom) @@ -216,8 +223,8 @@ TEST(global_tests, class_getFrom) bool res_bool = true; res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); @@ -226,8 +233,8 @@ TEST(global_tests, class_getFrom) test_word = onto_ptr->conversion.classesId2Index("woman"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); @@ -236,8 +243,8 @@ TEST(global_tests, class_getFrom) test_word = onto_ptr->conversion.literalsId2Index("integer#2"); test_word2 = onto_ptr->conversion.dataPropertiesId2Index("hasLeg"); res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("child")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("human")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); EXPECT_TRUE(res_bool); @@ -245,15 +252,14 @@ TEST(global_tests, class_getFrom) test_word = onto_ptr->conversion.literalsId2Index("integer#0"); test_word2 = onto_ptr->conversion.dataPropertiesId2Index("hasLeg"); res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasMother"); res = onto_ptr->classes.getFrom(test_word2, test_word); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getOn) @@ -264,44 +270,43 @@ TEST(global_tests, class_getOn) bool res_bool = true; res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("child"); test_word2 = onto_ptr->conversion.dataPropertiesId2Index("hasLeg"); res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("woman"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasFather"); res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("human"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasMother"); res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("human"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end()) && + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("cube"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("isOn"); res = onto_ptr->classes.getOn(test_word, test_word2); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, class_getWith) @@ -312,40 +317,42 @@ TEST(global_tests, class_getWith) bool res_bool = true; res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); test_word2 = onto_ptr->conversion.classesId2Index("man"); res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("child"); test_word2 = onto_ptr->conversion.literalsId2Index("integer#2"); res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); test_word2 = onto_ptr->conversion.literalsId2Index("integer#0"); res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("human"); test_word2 = onto_ptr->conversion.classesId2Index("human"); res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && (res.empty()); + EXPECT_TRUE(res.empty()); test_word = onto_ptr->conversion.classesId2Index("man"); test_word2 = onto_ptr->conversion.literalsId2Index("integer#2"); res = onto_ptr->classes.getWith(test_word, test_word2); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } /******************* @@ -361,34 +368,35 @@ TEST(global_tests, individual_getRelationFrom) bool res_bool = true; res = onto_ptr->individuals.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("kevin"); res = onto_ptr->individuals.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("cube1"); res = onto_ptr->individuals.getRelationFrom(test_word); - res_bool = res_bool && ((res.size() == 5) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isPositioned")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isOn")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("objectHave3Dposition")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isIn")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("have3Dposition")) != res.end())); + EXPECT_EQ(res.size(), 5); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isPositioned")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isOn")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("objectHave3Dposition")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isIn")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("have3Dposition")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); res = onto_ptr->individuals.getRelationFrom(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getRelatedFrom) @@ -398,31 +406,32 @@ TEST(global_tests, individual_getRelatedFrom) bool res_bool = true; res = onto_ptr->individuals.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->individuals.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("isOn"); res = onto_ptr->individuals.getRelatedFrom(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("cube1")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("mini_box")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("greenCube")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("blueCube")) != res.end())); + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("cube1")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("mini_box")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("greenCube")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("blueCube")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("human"); res = onto_ptr->individuals.getRelatedFrom(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getRelationOn) @@ -432,31 +441,33 @@ TEST(global_tests, individual_getRelationOn) bool res_bool = true; res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasMother")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("cube1"); res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isUnder")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isPositioned")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isUnder")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isPositioned")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#2"); res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#0"); res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("human"); res = onto_ptr->individuals.getRelationOn(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getRelatedOn) @@ -466,31 +477,34 @@ TEST(global_tests, individual_getRelatedOn) bool res_bool = true; res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasMother"); res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasFather"); res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.objectPropertiesId2Index("isIn"); res = onto_ptr->individuals.getRelatedOn(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("big_box")) != res.end())); - + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("big_box")) != res.end()); EXPECT_TRUE(res_bool); } @@ -501,32 +515,32 @@ TEST(global_tests, individual_getRelationWith) bool res_bool = true; res = onto_ptr->individuals.getRelationWith(test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end()) && + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#2")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("kevin"); res = onto_ptr->individuals.getRelationWith(test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("bob"); res = onto_ptr->individuals.getRelationWith(test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("cube1"); res = onto_ptr->individuals.getRelationWith(test_word); - res_bool = ((res.size() == 4) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#236")) != res.end()) && + EXPECT_EQ(res.size(), 4); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#236")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("big_box")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("blueCube")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("redCube")) != res.end())); @@ -540,34 +554,36 @@ TEST(global_tests, individual_getRelatedWith) bool res_bool = true; res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#2"); res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#0"); res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); + EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("human"); res = onto_ptr->individuals.getRelatedWith(test_word); - res_bool = res_bool && (res.empty()); - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getFrom) @@ -578,8 +594,8 @@ TEST(global_tests, individual_getFrom) bool res_bool = true; res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); EXPECT_TRUE(res_bool); @@ -587,8 +603,8 @@ TEST(global_tests, individual_getFrom) test_word = onto_ptr->conversion.classesId2Index("woman"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); EXPECT_TRUE(res_bool); @@ -596,8 +612,8 @@ TEST(global_tests, individual_getFrom) test_word = onto_ptr->conversion.classesId2Index("human"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 3) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + EXPECT_EQ(res.size(), 3); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); EXPECT_TRUE(res_bool); @@ -605,23 +621,22 @@ TEST(global_tests, individual_getFrom) test_word = onto_ptr->conversion.literalsId2Index("integer#0"); test_word2 = onto_ptr->conversion.dataPropertiesId2Index("hasLeg"); res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("kevin")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.literalsId2Index("integer#2"); test_word2 = onto_ptr->conversion.dataPropertiesId2Index("hasLeg"); res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasMother"); res = onto_ptr->individuals.getFrom(test_word2, test_word); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getOn) @@ -632,52 +647,51 @@ TEST(global_tests, individual_getOn) bool res_bool = true; res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("kevin"); test_word2 = onto_ptr->conversion.dataPropertiesId2Index("hasLeg"); res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.literalsId2Index("integer#0")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("alice"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasFather"); res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("bob"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasMother"); res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("alice"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end()) && + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("woman")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.classesId2Index("man")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("kevin"); test_word2 = onto_ptr->conversion.objectPropertiesId2Index("hasParent"); res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("alice")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.individualsId2Index("bob")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.classesId2Index("man"); test_word2 = onto_ptr->conversion.dataPropertiesId2Index("hasLeg"); res = onto_ptr->individuals.getOn(test_word, test_word2); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); } TEST(global_tests, individual_getWith) @@ -688,50 +702,48 @@ TEST(global_tests, individual_getWith) bool res_bool = true; res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("bob"); test_word2 = onto_ptr->conversion.classesId2Index("man"); res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasFather")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("hasParent")) != res.end())); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("alice"); test_word2 = onto_ptr->conversion.literalsId2Index("integer#2"); res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("bob"); test_word2 = onto_ptr->conversion.literalsId2Index("integer#0"); res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = ((res.size() == 1) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end())); + EXPECT_EQ(res.size(), 1); + res_bool = (std::find(res.begin(), res.end(), onto_ptr->conversion.dataPropertiesId2Index("hasLeg")) != res.end()); EXPECT_TRUE(res_bool); test_word = onto_ptr->conversion.individualsId2Index("alice"); test_word2 = onto_ptr->conversion.classesId2Index("human"); res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); test_word = onto_ptr->conversion.individualsId2Index("bob"); test_word2 = onto_ptr->conversion.literalsId2Index("integer#2"); res = onto_ptr->individuals.getWith(test_word, test_word2); - res_bool = (res.empty()); - EXPECT_TRUE(res_bool); + EXPECT_TRUE(res.empty()); test_word = onto_ptr->conversion.individualsId2Index("cube1"); test_word2 = onto_ptr->conversion.individualsId2Index("redCube"); res = onto_ptr->individuals.getWith(test_word, test_word2); // use same as (cube1 = greenCube) - res_bool = ((res.size() == 2) && - (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isPositioned")) != res.end()) && + EXPECT_EQ(res.size(), 2); + res_bool = ((std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isPositioned")) != res.end()) && (std::find(res.begin(), res.end(), onto_ptr->conversion.objectPropertiesId2Index("isOn")) != res.end())); EXPECT_TRUE(res_bool); } diff --git a/src/tests/CI/requests.cpp b/src/tests/CI/requests.cpp index 3a1de59a..f53373a7 100644 --- a/src/tests/CI/requests.cpp +++ b/src/tests/CI/requests.cpp @@ -1,154 +1,89 @@ +#include #include #include #include #include #include #include -#include #include "ontologenius/API/ontologenius/OntologyManipulator.h" -#define NB_TRY 10 - onto::OntologyManipulator* onto_ptr; TEST(requests_tests, getName_call) { - std::string res; - std::string test_word = "human"; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res = onto_ptr->classes.getName(test_word); - res_bool = res_bool && (res == "human"); - } - - EXPECT_TRUE(res_bool); + std::string res = onto_ptr->classes.getName("human"); + EXPECT_EQ(res, "human"); } TEST(requests_tests, find_call) { - std::vector res; - std::string test_word = "human"; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res = onto_ptr->classes.find(test_word); - res_bool = res_bool && ((res.size() == 1) && (res[0] == "human")); - } - - EXPECT_TRUE(res_bool); + std::vector res = onto_ptr->classes.find("human"); + EXPECT_EQ(res.size(), 1); + EXPECT_EQ(res.front(), "human"); } TEST(requests_tests, getUp_call) { - std::vector res; - std::string test_word = "human"; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res = onto_ptr->classes.getUp(test_word); - res_bool = res_bool && ((res.size() == 8) && - (std::find(res.begin(), res.end(), "entity") != res.end()) && - (std::find(res.begin(), res.end(), "animate") != res.end()) && - (std::find(res.begin(), res.end(), "activity") != res.end()) && - (std::find(res.begin(), res.end(), "attribute") != res.end()) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "agent") != res.end()) && - (std::find(res.begin(), res.end(), "vitality") != res.end()) && - (std::find(res.begin(), res.end(), "living") != res.end())); - } - + std::vector res = onto_ptr->classes.getUp("human"); + EXPECT_EQ(res.size(), 8); + bool res_bool = ((std::find(res.begin(), res.end(), "entity") != res.end()) && + (std::find(res.begin(), res.end(), "animate") != res.end()) && + (std::find(res.begin(), res.end(), "activity") != res.end()) && + (std::find(res.begin(), res.end(), "attribute") != res.end()) && + (std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "agent") != res.end()) && + (std::find(res.begin(), res.end(), "vitality") != res.end()) && + (std::find(res.begin(), res.end(), "living") != res.end())); EXPECT_TRUE(res_bool); } TEST(requests_tests, getDown_call) { - std::vector res; - std::string test_word = "human"; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res = onto_ptr->classes.getDown(test_word); - res_bool = res_bool && ((res.size() == 4) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "woman") != res.end()) && - (std::find(res.begin(), res.end(), "man") != res.end()) && - (std::find(res.begin(), res.end(), "child") != res.end())); - } + std::vector res = onto_ptr->classes.getDown("human"); + EXPECT_EQ(res.size(), 4); + bool res_bool = ((std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "woman") != res.end()) && + (std::find(res.begin(), res.end(), "man") != res.end()) && + (std::find(res.begin(), res.end(), "child") != res.end())); EXPECT_TRUE(res_bool); } TEST(requests_tests, getDisjoint_call) { - std::vector res; - std::string test_word = "woman"; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res = onto_ptr->classes.getDisjoint(test_word); - res_bool = res_bool && ((res.size() == 63) && - (std::find(res.begin(), res.end(), "man") != res.end())); - } - + std::vector res = onto_ptr->classes.getDisjoint("woman"); + EXPECT_EQ(res.size(), 63); + bool res_bool = (std::find(res.begin(), res.end(), "man") != res.end()); EXPECT_TRUE(res_bool); } TEST(requests_tests, depth_call) { - std::vector res; - std::string test_word = "human"; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res = onto_ptr->classes.getUp(test_word, 1); - res_bool = res_bool && ((res.size() == 3) && - (std::find(res.begin(), res.end(), "human") != res.end()) && - (std::find(res.begin(), res.end(), "agent") != res.end()) && - (std::find(res.begin(), res.end(), "living") != res.end())); - } - + std::vector res = onto_ptr->classes.getUp("human", 1); + EXPECT_EQ(res.size(), 3); + bool res_bool = ((std::find(res.begin(), res.end(), "human") != res.end()) && + (std::find(res.begin(), res.end(), "agent") != res.end()) && + (std::find(res.begin(), res.end(), "living") != res.end())); EXPECT_TRUE(res_bool); } TEST(requests_tests, select_true_call) { - std::string test_word = "human"; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res_bool = res_bool && onto_ptr->classes.isA(test_word, "entity"); - } - - EXPECT_TRUE(res_bool); + EXPECT_TRUE(onto_ptr->classes.isA("human", "entity")); } TEST(requests_tests, reasoners_list_call) { - std::vector res; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res = onto_ptr->reasoners.list(); - res_bool = res_bool && ((res.size() >= 7) && - (std::find(res.begin(), res.end(), "ontologenius::ReasonerChain") != res.end()) && - (std::find(res.begin(), res.end(), "ontologenius::ReasonerDictionary") != res.end()) && - (std::find(res.begin(), res.end(), "ontologenius::ReasonerInverseOf") != res.end()) && - (std::find(res.begin(), res.end(), "ontologenius::ReasonerNone") != res.end()) && - (std::find(res.begin(), res.end(), "ontologenius::ReasonerSymmetric") != res.end()) && - (std::find(res.begin(), res.end(), "ontologenius::ReasonerGeneralize") != res.end()) && - (std::find(res.begin(), res.end(), "ontologenius::ReasonerRangeDomain") != res.end())); - } - + std::vector res = onto_ptr->reasoners.list(); + EXPECT_GE(res.size(), 7); + bool res_bool = ((std::find(res.begin(), res.end(), "ontologenius::ReasonerChain") != res.end()) && + (std::find(res.begin(), res.end(), "ontologenius::ReasonerDictionary") != res.end()) && + (std::find(res.begin(), res.end(), "ontologenius::ReasonerInverseOf") != res.end()) && + (std::find(res.begin(), res.end(), "ontologenius::ReasonerNone") != res.end()) && + (std::find(res.begin(), res.end(), "ontologenius::ReasonerSymmetric") != res.end()) && + (std::find(res.begin(), res.end(), "ontologenius::ReasonerGeneralize") != res.end()) && + (std::find(res.begin(), res.end(), "ontologenius::ReasonerRangeDomain") != res.end())); EXPECT_TRUE(res_bool); } @@ -157,34 +92,23 @@ TEST(requests_tests, reasoner_description_call) std::string res; bool res_bool = true; - for(size_t i = 0; i < NB_TRY; i++) - { - res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerChain"); - res_bool = res_bool && (res == "This reasoner resolve the properties chains axioms.\n - post reasoning"); - res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerDictionary"); - res_bool = res_bool && (res == "This reasoner creates several alternative dictionaries to avoid too many restrictive labels.\n - post reasoning"); - res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerInverseOf"); - res_bool = res_bool && (res == "This reasoner creates the inverse properties for each individual.\n - post reasoning"); - res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerNone"); - res_bool = res_bool && (res == "This is an reasoner model to show how to create your own reasoner plugin\n - post reasoning\n - pre reasoning\n - periodic reasoning"); - res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerSymmetric"); - res_bool = res_bool && (res == "This reasoner creates the symetric properties for each individual.\n - post reasoning"); - } + res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerChain"); + res_bool = res_bool && (res == "This reasoner resolve the properties chains axioms.\n - post reasoning"); + res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerDictionary"); + res_bool = res_bool && (res == "This reasoner creates several alternative dictionaries to avoid too many restrictive labels.\n - post reasoning"); + res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerInverseOf"); + res_bool = res_bool && (res == "This reasoner creates the inverse properties for each individual.\n - post reasoning"); + res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerNone"); + res_bool = res_bool && (res == "This is an reasoner model to show how to create your own reasoner plugin\n - post reasoning\n - pre reasoning\n - periodic reasoning"); + res = onto_ptr->reasoners.getDescription("ontologenius::ReasonerSymmetric"); + res_bool = res_bool && (res == "This reasoner creates the symetric properties for each individual.\n - post reasoning"); EXPECT_TRUE(res_bool); } TEST(requests_tests, select_false_call) { - std::string test_word = "human"; - bool res_bool = true; - - for(size_t i = 0; i < NB_TRY; i++) - { - res_bool = res_bool && (!onto_ptr->classes.isA(test_word, "animal")); - } - - EXPECT_TRUE(res_bool); + EXPECT_FALSE(onto_ptr->classes.isA("human", "animal")); } int main(int argc, char** argv)