blob: d89c7c192ef66e564b75fbd29077ce6895582cb2 [file] [log] [blame]
Ed Tanousb4a7bfa2017-04-04 17:23:00 -07001#include <crow/app.h>
2#include "gmock/gmock.h"
3#include "gtest/gtest.h"
4
5using namespace crow;
6using namespace std;
7
8TEST(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
16TEST(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 Tanous1c74de82017-10-26 13:58:28 -070021 EXPECT_THAT(app.get_routes(),
22 testing::ElementsAre(testing::Pointee(std::string("/"))));
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070023}
24
25// Tests that static urls are correctly passed
26TEST(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 Tanous1c74de82017-10-26 13:58:28 -070036 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 Tanousb4a7bfa2017-04-04 17:23:00 -070043}