summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2017-10-26 13:58:28 -0700
committerEd Tanous <ed.tanous@intel.com>2017-10-30 11:37:34 -0700
commit1c74de8786b2e16de8281abf4d427644fc426ee8 (patch)
tree6ef427337f1303953403a0359c0e826e3eb541f1 /src
parentc963aa422e35a954229c3fcf9646150dc0066369 (diff)
downloadbmcweb-1c74de8786b2e16de8281abf4d427644fc426ee8.tar.gz
bmcweb-1c74de8786b2e16de8281abf4d427644fc426ee8.zip
Update get_routes to use trie for efficiency
This commit updates the behavior of request_routes to actually use the trie data structure to find the appropriate routes. This function was originaly intended for debugging, but now with redfish, it is being used to look up routes. Also, update the prototype so it returns a string pointer to the main route in the trie instead of copying the whole list of stings. A future optimization should also give the ability to pick a "stop at" character, or a depth so that users can decide how deep into the tree they want to iterate, instead of getting the whole subtree and filtering after the fact. Change-Id: I8b98fb3f19f59a043ae6aa583ed62ab89be10eb8
Diffstat (limited to 'src')
-rw-r--r--src/crow_getroutes_test.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/crow_getroutes_test.cpp b/src/crow_getroutes_test.cpp
index 6a9f538..d89c7c1 100644
--- a/src/crow_getroutes_test.cpp
+++ b/src/crow_getroutes_test.cpp
@@ -18,7 +18,8 @@ TEST(GetRoutes, TestOneRoute) {
decltype(app)::server_t server(&app, "127.0.0.1", 45451);
CROW_ROUTE(app, "/")([]() { return 200; });
- EXPECT_THAT(app.get_routes(), testing::ElementsAre("/"));
+ EXPECT_THAT(app.get_routes(),
+ testing::ElementsAre(testing::Pointee(std::string("/"))));
}
// Tests that static urls are correctly passed
@@ -32,7 +33,11 @@ TEST(GetRoutes, TestlotsOfRoutes) {
CROW_ROUTE(app, "/boo")([]() { return 200; });
CROW_ROUTE(app, "/moo")([]() { return 200; });
- EXPECT_THAT(app.get_routes(),
- testing::UnorderedElementsAre("/", "/foo", "/bar", "/baz", "/boo",
- "/moo"));
+ EXPECT_THAT(app.get_routes(), 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"))));
} \ No newline at end of file
OpenPOWER on IntegriCloud