Skip to content

Commit

Permalink
add exception test
Browse files Browse the repository at this point in the history
  • Loading branch information
try-agaaain committed Mar 17, 2024
1 parent 44392e4 commit 21c6248
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/test_rest_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ TEST_CASE("test_client_sync_call") {
CHECK(r);
auto result = client.call<int>("add", 1, 2);
CHECK_EQ(result, 3);
CHECK_THROWS_WITH_AS(client.call<int>("add", 1, "2"), "unpack failed: Args not match!", std::logic_error);
CHECK_THROWS_WITH_AS(client.call<int>("Add", 1, 2), "unknown function: 3961593724", std::logic_error);
}

TEST_CASE("test_client_sync_call_return_void") {
Expand Down Expand Up @@ -214,7 +216,9 @@ TEST_CASE("test_client_async_call") {
CHECK_EQ(p.name, "tom");
}
auto fu = client.async_call<FUTURE>("hello", "purecpp");
fu.get().as(); // no return
CHECK_NOTHROW(fu.get().as()); // no return
auto fu_err = client.async_call<FUTURE>("Hello", "purecpp");
CHECK_THROWS_WITH_AS(fu_err.get().as(), "unknown function: 2333776211", std::logic_error);
}
TEST_CASE("test_client_async_call_not_connect") {
rpc_client client("127.0.0.1", 9001);
Expand Down

0 comments on commit 21c6248

Please sign in to comment.