From 643d1d52373c9264808887c7cffbd6830de479f5 Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Sun, 22 Mar 2020 13:36:03 +0100 Subject: [PATCH] increased test coverage --- .../jsonrpc/test/wf/jsonrpc/test_request.cc | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/wf/jsonrpc/test/wf/jsonrpc/test_request.cc b/lib/wf/jsonrpc/test/wf/jsonrpc/test_request.cc index eb15e91..a8f7986 100644 --- a/lib/wf/jsonrpc/test/wf/jsonrpc/test_request.cc +++ b/lib/wf/jsonrpc/test/wf/jsonrpc/test_request.cc @@ -101,3 +101,38 @@ TEST(wf_jsonrpc_request, respond_error) json_decref(response); } + +TEST(wf_jsonrpc_request, is_request_object_params) +{ + json_t * request = json_object(); + json_object_set_new(request, "method", json_string("some_method")); + json_object_set_new(request, "params", json_object()); + json_object_set_new(request, "id", json_integer(42)); + + ASSERT_TRUE(wf_jsonrpc_is_request(request)); + + json_decref(request); +} + +TEST(wf_jsonrpc_request, is_request_fail_missing_params) +{ + json_t * request = json_object(); + json_object_set_new(request, "method", json_string("some_method")); + json_object_set_new(request, "id", json_integer(42)); + + ASSERT_FALSE(wf_jsonrpc_is_request(request)); + + json_decref(request); +} + +TEST(wf_jsonrpc_request, is_request_fail_params_wrong_type) +{ + json_t * request = json_object(); + json_object_set_new(request, "method", json_string("some_method")); + json_object_set_new(request, "params", json_string("invalid_params")); + json_object_set_new(request, "id", json_integer(42)); + + ASSERT_FALSE(wf_jsonrpc_is_request(request)); + + json_decref(request); +}