Skip to content

Commit a634261

Browse files
committed
Add failing test for removal of parameter route
1 parent 2e78447 commit a634261

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/HttpRouter.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,39 @@ void testBugReports() {
160160
uWS::HttpRouter<int> r;
161161
std::string result;
162162

163+
r.add({"GET"}, "/route", [&result](auto *) {
164+
result += "ROUTE";
165+
return true;
166+
}, r.MEDIUM_PRIORITY);
167+
168+
r.add({"GET"}, "/route/:id", [&result](auto *) {
169+
result += "ROUID";
170+
return true;
171+
}, r.MEDIUM_PRIORITY);
172+
173+
r.route("GET", "/route/21");
174+
assert(result == "ROUID");
175+
176+
result = "";
177+
r.route("GET", "/route");
178+
assert(result == "ROUTE");
179+
180+
result = "";
181+
r.remove("GET", "/route", r.MEDIUM_PRIORITY);
182+
r.route("GET", "/route");
183+
assert(result == "");
184+
185+
r.remove("GET", "/route/:id", r.MEDIUM_PRIORITY);
186+
187+
/* The bug is really only this line, it does not remove parameter routes */
188+
r.route("GET", "/route/21");
189+
std::cout << result << std::endl;
190+
assert(result == "");
191+
}
192+
{
193+
uWS::HttpRouter<int> r;
194+
std::string result;
195+
163196
r.add({"GET"}, "/foo//////bar/baz/qux", [&result](auto *) {
164197
result += "MANYSLASH";
165198
return false;

0 commit comments

Comments
 (0)