Skip to content

Commit

Permalink
iox-eclipse-iceoryx#415 Address review findings from eclipse-iceoryx#860
Browse files Browse the repository at this point in the history
 renaming test cases and member variable

Signed-off-by: Simon Hoinkis <[email protected]>
  • Loading branch information
mossmaurice committed Sep 1, 2021
1 parent d193464 commit 0397cec
Showing 1 changed file with 78 additions and 78 deletions.
156 changes: 78 additions & 78 deletions iceoryx_posh/test/moduletests/test_roudi_service_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ class ServiceRegistry_test : public Test
std::cout << output << std::endl;
}
}
iox::roudi::ServiceRegistry registry;
iox::roudi::ServiceRegistry sut;

iox::roudi::ServiceRegistry::ServiceDescriptionVector_t searchResults;
};

TEST_F(ServiceRegistry_test, AddNoServiceDescriptionsAndWildcardSearchReturnsNothing)
{
registry.find(searchResults, Wildcard, Wildcard);
sut.find(searchResults, Wildcard, Wildcard);

EXPECT_THAT(searchResults.size(), Eq(0));
}
Expand All @@ -66,7 +66,7 @@ TEST_F(ServiceRegistry_test, AddMaximumNumberOfServiceDescriptionsWorks)

for (auto& service : services)
{
auto result = registry.add(service);
auto result = sut.add(service);
ASSERT_FALSE(result.has_error());
}
}
Expand All @@ -83,24 +83,24 @@ TEST_F(ServiceRegistry_test, AddMoreThanMaximumNumberOfServiceDescriptionsFails)

for (auto& service : services)
{
auto result = registry.add(service);
auto result = sut.add(service);
ASSERT_FALSE(result.has_error());
}

auto result = registry.add(iox::capro::ServiceDescription("Foo", "Bar", "Baz"));
auto result = sut.add(iox::capro::ServiceDescription("Foo", "Bar", "Baz"));
ASSERT_TRUE(result.has_error());
EXPECT_THAT(result.get_error(), Eq(ServiceRegistry::Error::SERVICE_REGISTRY_FULL));
}

TEST_F(ServiceRegistry_test, AddServiceDescriptionsWhichWasAlreadyAddedAndReturnsOneResult)
{
auto result1 = registry.add(ServiceDescription("Li", "La", "Launebaer"));
auto result1 = sut.add(ServiceDescription("Li", "La", "Launebaer"));
ASSERT_FALSE(result1.has_error());

auto result2 = registry.add(ServiceDescription("Li", "La", "Launebaer"));
auto result2 = sut.add(ServiceDescription("Li", "La", "Launebaer"));
ASSERT_FALSE(result2.has_error());

registry.find(searchResults, Wildcard, Wildcard);
sut.find(searchResults, Wildcard, Wildcard);

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(ServiceDescription("Li", "La", "Launebaer")));
Expand All @@ -109,15 +109,15 @@ TEST_F(ServiceRegistry_test, AddServiceDescriptionsWhichWasAlreadyAddedAndReturn

TEST_F(ServiceRegistry_test, AddServiceDescriptionsTwiceAndRemoveOnceAndReturnsOneResult)
{
auto result1 = registry.add(ServiceDescription("Li", "La", "Launebaerli"));
auto result1 = sut.add(ServiceDescription("Li", "La", "Launebaerli"));
ASSERT_FALSE(result1.has_error());

auto result2 = registry.add(ServiceDescription("Li", "La", "Launebaerli"));
auto result2 = sut.add(ServiceDescription("Li", "La", "Launebaerli"));
ASSERT_FALSE(result2.has_error());

registry.remove(ServiceDescription("Li", "La", "Launebaerli"));
sut.remove(ServiceDescription("Li", "La", "Launebaerli"));

registry.find(searchResults, Wildcard, Wildcard);
sut.find(searchResults, Wildcard, Wildcard);

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(ServiceDescription("Li", "La", "Launebaerli")));
Expand All @@ -126,54 +126,54 @@ TEST_F(ServiceRegistry_test, AddServiceDescriptionsTwiceAndRemoveOnceAndReturnsO

TEST_F(ServiceRegistry_test, AddInvalidServiceDescriptionsWorks)
{
auto result = registry.add(ServiceDescription());
auto result = sut.add(ServiceDescription());
ASSERT_FALSE(result.has_error());
}

TEST_F(ServiceRegistry_test, RemovingServiceDescriptionsWhichWasntAddedFails)
{
EXPECT_FALSE(registry.remove(ServiceDescription("Sim", "Sa", "Lambim")));
EXPECT_FALSE(sut.remove(ServiceDescription("Sim", "Sa", "Lambim")));
}

TEST_F(ServiceRegistry_test, RemovingInvalidServiceDescriptionsWorks)
{
ASSERT_FALSE(registry.add(ServiceDescription()).has_error());
EXPECT_TRUE(registry.remove(ServiceDescription()));
ASSERT_FALSE(sut.add(ServiceDescription()).has_error());
EXPECT_TRUE(sut.remove(ServiceDescription()));
}

TEST_F(ServiceRegistry_test, SingleInvalidServiceDescriptionsCanBeFoundWithWildcardSearch)
{
ASSERT_FALSE(registry.add(ServiceDescription()).has_error());
registry.find(searchResults, Wildcard, Wildcard);
ASSERT_FALSE(sut.add(ServiceDescription()).has_error());
sut.find(searchResults, Wildcard, Wildcard);

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(ServiceDescription()));
}

TEST_F(ServiceRegistry_test, SingleInvalidServiceDescriptionsCanBeFoundWithEmptyString)
{
ASSERT_FALSE(registry.add(ServiceDescription()).has_error());
registry.find(searchResults, "", "");
ASSERT_FALSE(sut.add(ServiceDescription()).has_error());
sut.find(searchResults, "", "");

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(ServiceDescription()));
}

TEST_F(ServiceRegistry_test, SingleServiceDescriptionCanBeFoundWithWildcardSearch)
{
auto result = registry.add(ServiceDescription("Foo", "Bar", "Baz"));
auto result = sut.add(ServiceDescription("Foo", "Bar", "Baz"));
ASSERT_FALSE(result.has_error());
registry.find(searchResults, Wildcard, Wildcard);
sut.find(searchResults, Wildcard, Wildcard);

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(ServiceDescription("Foo", "Bar", "Baz")));
}

TEST_F(ServiceRegistry_test, SingleServiceDescriptionCanBeFoundWithInstanceName)
{
auto result = registry.add(ServiceDescription("Baz", "Bar", "Foo"));
auto result = sut.add(ServiceDescription("Baz", "Bar", "Foo"));
ASSERT_FALSE(result.has_error());
registry.find(searchResults, Wildcard, "Bar");
sut.find(searchResults, Wildcard, "Bar");

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(ServiceDescription("Baz", "Bar", "Foo")));
Expand All @@ -182,8 +182,8 @@ TEST_F(ServiceRegistry_test, SingleServiceDescriptionCanBeFoundWithInstanceName)
TEST_F(ServiceRegistry_test, SingleServiceDescriptionCanBeFoundWithServiceName)
{
iox::capro::ServiceDescription service1("a", "b", "c");
ASSERT_FALSE(registry.add(service1).has_error());
registry.find(searchResults, "a", Wildcard);
ASSERT_FALSE(sut.add(service1).has_error());
sut.find(searchResults, "a", Wildcard);

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(service1));
Expand All @@ -194,9 +194,9 @@ TEST_F(ServiceRegistry_test, ValidAndInvalidServiceDescriptionsCanAllBeFoundWith
ServiceDescription service1;
ServiceDescription service2("alpha", "bravo", "charlie");

ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
registry.find(searchResults, Wildcard, Wildcard);
ASSERT_FALSE(sut.add(service1).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
sut.find(searchResults, Wildcard, Wildcard);

EXPECT_THAT(searchResults.size(), Eq(2));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(service1));
Expand All @@ -209,10 +209,10 @@ TEST_F(ServiceRegistry_test, MultipleServiceDescriptionWithSameServiceNameCanAll
iox::capro::ServiceDescription service2("a", "c", "c");
iox::capro::ServiceDescription service3("a", "d", "d");

ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service3).has_error());
registry.find(searchResults, "a", Wildcard);
ASSERT_FALSE(sut.add(service1).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service3).has_error());
sut.find(searchResults, "a", Wildcard);

EXPECT_THAT(searchResults.size(), Eq(3));

Expand All @@ -238,15 +238,15 @@ TEST_F(ServiceRegistry_test, MultipleServiceDescriptionWithDifferentServiceNameC
iox::capro::ServiceDescription service1("a", "b", "b");
iox::capro::ServiceDescription service2("c", "d", "d");

ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
registry.find(searchResults, "a", Wildcard);
ASSERT_FALSE(sut.add(service1).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
sut.find(searchResults, "a", Wildcard);

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(service1));
searchResults.clear();

registry.find(searchResults, "c", Wildcard);
sut.find(searchResults, "c", Wildcard);
EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(service2));
}
Expand All @@ -257,10 +257,10 @@ TEST_F(ServiceRegistry_test, MultipleServiceDescriptionWithSameServiceNameFindsS
iox::capro::ServiceDescription service2("a", "c", "c");
iox::capro::ServiceDescription service3("a", "d", "d");

ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service3).has_error());
registry.find(searchResults, "a", "c");
ASSERT_FALSE(sut.add(service1).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service3).has_error());
sut.find(searchResults, "a", "c");

EXPECT_THAT(searchResults.size(), Eq(1));
EXPECT_THAT(searchResults[0].serviceDescription, Eq(service2));
Expand All @@ -274,15 +274,15 @@ TEST_F(ServiceRegistry_test, MultipleServiceDescriptionAddedInNonLinearOrderFind
iox::capro::ServiceDescription service4("d", "4", "moep");
iox::capro::ServiceDescription service5("e", "5", "moep");

ASSERT_FALSE(registry.add(service5).has_error());
ASSERT_FALSE(registry.add(service3).has_error());
ASSERT_FALSE(registry.add(service4).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(sut.add(service5).has_error());
ASSERT_FALSE(sut.add(service3).has_error());
ASSERT_FALSE(sut.add(service4).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service1).has_error());

ASSERT_TRUE(registry.remove(service5));
ASSERT_TRUE(registry.remove(service1));
registry.find(searchResults, "a", Wildcard);
ASSERT_TRUE(sut.remove(service5));
ASSERT_TRUE(sut.remove(service1));
sut.find(searchResults, "a", Wildcard);

EXPECT_THAT(searchResults.size(), Eq(0));
}
Expand All @@ -293,10 +293,10 @@ TEST_F(ServiceRegistry_test, FindSpecificNonExistingServiceDescriptionFails)
iox::capro::ServiceDescription service2("a", "c", "c");
iox::capro::ServiceDescription service3("a", "d", "d");

ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service3).has_error());
registry.find(searchResults, "a", "g");
ASSERT_FALSE(sut.add(service1).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service3).has_error());
sut.find(searchResults, "a", "g");

EXPECT_THAT(searchResults.size(), Eq(0));
}
Expand All @@ -307,30 +307,30 @@ TEST_F(ServiceRegistry_test, AddingMultipleServiceDescriptionWithSameServicesAnd
iox::capro::ServiceDescription service2("a", "c", "c");
iox::capro::ServiceDescription service3("a", "d", "d");

ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service3).has_error());
ASSERT_FALSE(sut.add(service1).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service3).has_error());

EXPECT_TRUE(registry.remove(service2));
EXPECT_TRUE(sut.remove(service2));

registry.find(searchResults, "a", "c");
sut.find(searchResults, "a", "c");
EXPECT_THAT(searchResults.size(), Eq(0));
}

TEST_F(ServiceRegistry_test,
AddingMultipleServiceDescriptionWithDifferentServicesAndRemovingSpecificDoesNotFindSpecific)
ServiceNotFoundAfterAddingAndRemovingToServiceRegistry)
{
iox::capro::ServiceDescription service1("a", "b", "b");
iox::capro::ServiceDescription service2("b", "c", "c");
iox::capro::ServiceDescription service3("c", "d", "d");

ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service3).has_error());
ASSERT_FALSE(sut.add(service1).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service3).has_error());

EXPECT_TRUE(registry.remove(service2));
EXPECT_TRUE(sut.remove(service2));

registry.find(searchResults, "b", "c");
sut.find(searchResults, "b", "c");
EXPECT_THAT(searchResults.size(), Eq(0));
}

Expand All @@ -340,15 +340,15 @@ TEST_F(ServiceRegistry_test, AddingMultipleServiceDescriptionAndRemovingAllDoesN
iox::capro::ServiceDescription service2("a", "c", "c");
iox::capro::ServiceDescription service3("a", "d", "d");

ASSERT_FALSE(registry.add(service1).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service3).has_error());
ASSERT_FALSE(sut.add(service1).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service3).has_error());

EXPECT_TRUE(registry.remove(service1));
EXPECT_TRUE(registry.remove(service2));
EXPECT_TRUE(registry.remove(service3));
EXPECT_TRUE(sut.remove(service1));
EXPECT_TRUE(sut.remove(service2));
EXPECT_TRUE(sut.remove(service3));

registry.find(searchResults, "a", Wildcard);
sut.find(searchResults, "a", Wildcard);
EXPECT_THAT(searchResults.size(), Eq(0));
}

Expand All @@ -359,14 +359,14 @@ TEST_F(ServiceRegistry_test, AddingVariousServiceDescriptionAndGetServicesDoesNo
iox::capro::ServiceDescription service3("a", "d", "d");
iox::capro::ServiceDescription service4("e", "f", "f");

ASSERT_FALSE(registry.add(service1).has_error());
// add same service a, instance c to check if in registry only one entry is created
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service2).has_error());
ASSERT_FALSE(registry.add(service3).has_error());
ASSERT_FALSE(registry.add(service4).has_error());
ASSERT_FALSE(sut.add(service1).has_error());
// add same service a, instance c to check if in sut only one entry is created
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service2).has_error());
ASSERT_FALSE(sut.add(service3).has_error());
ASSERT_FALSE(sut.add(service4).has_error());

auto serviceDescriptionVector = registry.getServices();
auto serviceDescriptionVector = sut.getServices();

bool service1Found = false;
bool service2Found = false;
Expand Down

0 comments on commit 0397cec

Please sign in to comment.