Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 1 | #include <crow/app.h> |
| 2 | #include "gmock/gmock.h" |
| 3 | #include "gtest/gtest.h" |
| 4 | |
| 5 | using namespace crow; |
| 6 | using namespace std; |
| 7 | |
| 8 | TEST(GetRoutes, TestEmptyRoutes) { |
| 9 | SimpleApp app; |
| 10 | decltype(app)::server_t server(&app, "127.0.0.1", 45451); |
| 11 | |
| 12 | EXPECT_THAT(app.get_routes(), testing::IsEmpty()); |
| 13 | } |
| 14 | |
| 15 | // Tests that static urls are correctly passed |
| 16 | TEST(GetRoutes, TestOneRoute) { |
| 17 | SimpleApp app; |
| 18 | decltype(app)::server_t server(&app, "127.0.0.1", 45451); |
| 19 | CROW_ROUTE(app, "/")([]() { return 200; }); |
| 20 | |
Ed Tanous | 1c74de8 | 2017-10-26 13:58:28 -0700 | [diff] [blame^] | 21 | EXPECT_THAT(app.get_routes(), |
| 22 | testing::ElementsAre(testing::Pointee(std::string("/")))); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | // Tests that static urls are correctly passed |
| 26 | TEST(GetRoutes, TestlotsOfRoutes) { |
| 27 | SimpleApp app; |
| 28 | decltype(app)::server_t server(&app, "127.0.0.1", 45451); |
| 29 | CROW_ROUTE(app, "/")([]() { return 200; }); |
| 30 | CROW_ROUTE(app, "/foo")([]() { return 200; }); |
| 31 | CROW_ROUTE(app, "/bar")([]() { return 200; }); |
| 32 | CROW_ROUTE(app, "/baz")([]() { return 200; }); |
| 33 | CROW_ROUTE(app, "/boo")([]() { return 200; }); |
| 34 | CROW_ROUTE(app, "/moo")([]() { return 200; }); |
| 35 | |
Ed Tanous | 1c74de8 | 2017-10-26 13:58:28 -0700 | [diff] [blame^] | 36 | EXPECT_THAT(app.get_routes(), testing::UnorderedElementsAre( |
| 37 | testing::Pointee(std::string("/")), |
| 38 | testing::Pointee(std::string("/foo")), |
| 39 | testing::Pointee(std::string("/bar")), |
| 40 | testing::Pointee(std::string("/baz")), |
| 41 | testing::Pointee(std::string("/boo")), |
| 42 | testing::Pointee(std::string("/moo")))); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 43 | } |