Skip to content

Commit

Permalink
Add failing router tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Nov 29, 2021
1 parent ce641a4 commit 2017892
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/HttpRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,52 @@ void testBugReports() {
r.route("get", "/static");
assert(result == "WWGSLAW");
}

{
uWS::HttpRouter<int> r;
std::string result;

r.add({"get"}, "/foo", [&result](auto *) {
result += "FOO";
return false;
}, r.MEDIUM_PRIORITY);

r.add({"get"}, "/:id", [&result](auto *) {
result += "ID";
return false;
}, r.MEDIUM_PRIORITY);

r.add({"get"}, "/1ab", [&result](auto *) {
result += "ONEAB";
return false;
}, r.MEDIUM_PRIORITY);

r.route("get", "/1ab");
// this one fails with IDONEAB
std::cout << result << std::endl;
assert(result == "ONEAB");
}

{
uWS::HttpRouter<int> r;
std::string result;

r.add({"get"}, "/*", [&result](auto *) {
result += "STAR";
return false;
}, r.MEDIUM_PRIORITY);

r.add({"get"}, "/", [&result](auto *) {
result += "STATIC";
return false;
}, r.MEDIUM_PRIORITY);

r.route("get", "/");
std::cout << result << std::endl;
// this one fails with STARSTATIC
assert(result == "STATICSTAR");
}

}

void testParameters() {
Expand Down

0 comments on commit 2017892

Please sign in to comment.