diff --git a/tests/router_test.cc b/tests/router_test.cc index 82674f7d4..036c76110 100644 --- a/tests/router_test.cc +++ b/tests/router_test.cc @@ -252,11 +252,23 @@ TEST(router_test, test_remove_not_existing) { SegmentTreeNode routes; - ASSERT_THROW(routes.removeRoute("/v1/hello"), std::runtime_error); - ASSERT_THROW(routes.removeRoute("/v1/hello/:name/"), std::runtime_error); - ASSERT_THROW(routes.removeRoute("/get/:key?/bar"), std::runtime_error); - ASSERT_THROW(routes.removeRoute("/say/*/to/*"), std::runtime_error); - ASSERT_THROW(routes.removeRoute("*/api"), std::runtime_error); + using testing::ThrowsMessage; + + ASSERT_THAT( + [&] { routes.removeRoute("/v1/hello"); }, + ThrowsMessage("Requested route does not exist.")); + ASSERT_THAT( + [&] { routes.removeRoute("/v1/hello/:name/"); }, + ThrowsMessage("Requested route does not exist.")); + ASSERT_THAT( + [&] { routes.removeRoute("/get/:key?/bar"); }, + ThrowsMessage("Requested route does not exist.")); + ASSERT_THAT( + [&] { routes.removeRoute("/say/*/to/*"); }, + ThrowsMessage("Requested route does not exist.")); + ASSERT_THAT( + [&] { routes.removeRoute("*/api"); }, + ThrowsMessage("Requested route does not exist.")); } class MyHandler