blob: 6a9f538378b962122852fd0a3a43b91064d725e7 [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
21 EXPECT_THAT(app.get_routes(), testing::ElementsAre("/"));
22}
23
24// Tests that static urls are correctly passed
25TEST(GetRoutes, TestlotsOfRoutes) {
26 SimpleApp app;
27 decltype(app)::server_t server(&app, "127.0.0.1", 45451);
28 CROW_ROUTE(app, "/")([]() { return 200; });
29 CROW_ROUTE(app, "/foo")([]() { return 200; });
30 CROW_ROUTE(app, "/bar")([]() { return 200; });
31 CROW_ROUTE(app, "/baz")([]() { return 200; });
32 CROW_ROUTE(app, "/boo")([]() { return 200; });
33 CROW_ROUTE(app, "/moo")([]() { return 200; });
34
35 EXPECT_THAT(app.get_routes(),
36 testing::UnorderedElementsAre("/", "/foo", "/bar", "/baz", "/boo",
37 "/moo"));
38}