From 4dd73a1cfa22ebf9b2ee2fd2aff6767eeb88e1c1 Mon Sep 17 00:00:00 2001 From: Nan Zhou Date: Mon, 13 Jun 2022 22:38:52 +0000 Subject: crow_getroutes_test: refactor tests It's a common practise to put tests to its corresponding namespace. This commit also removed duplicate namespace scoping (::testing). Tested: unit test passed Signed-off-by: Nan Zhou Change-Id: I447a4c05c4487245b1c31c5e19a8eac2c6086001 --- src/crow_getroutes_test.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/crow_getroutes_test.cpp b/src/crow_getroutes_test.cpp index 5352165b5b..f4d375b35b 100644 --- a/src/crow_getroutes_test.cpp +++ b/src/crow_getroutes_test.cpp @@ -1,17 +1,24 @@ -#include +#include "app.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" -using namespace crow; -using namespace std; +namespace crow +{ +namespace +{ + +using ::testing::Eq; +using ::testing::IsEmpty; +using ::testing::Pointee; +using ::testing::UnorderedElementsAre; TEST(GetRoutes, TestEmptyRoutes) { App app; app.validate(); - EXPECT_THAT(app.getRoutes(), testing::IsEmpty()); + EXPECT_THAT(app.getRoutes(), IsEmpty()); } // Tests that static urls are correctly passed @@ -24,7 +31,7 @@ TEST(GetRoutes, TestOneRoute) // TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once // it is fixed // EXPECT_THAT(app.getRoutes(), - // testing::ElementsAre(testing::Pointee(std::string("/")))); + // testing::ElementsAre(Pointee(Eq("/")))); } // Tests that static urls are correctly passed @@ -42,11 +49,11 @@ TEST(GetRoutes, TestlotsOfRoutes) // TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once // it is fixed - EXPECT_THAT(app.getRoutes(), testing::UnorderedElementsAre( - // testing::Pointee(std::string("/")), - testing::Pointee(std::string("/foo")), - testing::Pointee(std::string("/bar")), - testing::Pointee(std::string("/baz")), - testing::Pointee(std::string("/boo")), - testing::Pointee(std::string("/moo")))); + EXPECT_THAT(app.getRoutes(), UnorderedElementsAre( + // Pointee(Eq("/")), + Pointee(Eq("/foo")), Pointee(Eq("/bar")), + Pointee(Eq("/baz")), Pointee(Eq("/boo")), + Pointee(Eq("/moo")))); } +} // namespace +} // namespace crow \ No newline at end of file -- cgit v1.2.3