2020-06-16 21:39:45 +00:00
|
|
|
#include "webfuse_provider/impl/jsonrpc/request.h"
|
2020-07-12 13:13:34 +00:00
|
|
|
#include "webfuse_provider/test_util/json_doc.hpp"
|
2020-07-10 21:27:33 +00:00
|
|
|
#include <gtest/gtest.h>
|
2019-05-19 12:33:42 +00:00
|
|
|
|
2020-07-12 13:13:34 +00:00
|
|
|
using webfuse_test::JsonDoc;
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
TEST(wfp_jsonrpc_request, is_request_object_params)
|
2020-03-22 12:36:03 +00:00
|
|
|
{
|
2020-07-12 13:13:34 +00:00
|
|
|
JsonDoc doc("{\"method\": \"some_method\", \"params\": { }, \"id\": 42}");
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-12 13:13:34 +00:00
|
|
|
ASSERT_TRUE(wfp_jsonrpc_is_request(doc.root()));
|
2020-03-22 12:36:03 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
TEST(wfp_jsonrpc_request, is_request_fail_missing_params)
|
2020-03-22 12:36:03 +00:00
|
|
|
{
|
2020-07-12 13:13:34 +00:00
|
|
|
JsonDoc doc("{\"method\": \"some_method\", \"id\": 42}");
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-12 13:13:34 +00:00
|
|
|
ASSERT_FALSE(wfp_jsonrpc_is_request(doc.root()));
|
2020-03-22 12:36:03 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
TEST(wfp_jsonrpc_request, is_request_fail_params_wrong_type)
|
2020-03-22 12:36:03 +00:00
|
|
|
{
|
2020-07-12 13:13:34 +00:00
|
|
|
JsonDoc doc("{\"method\": \"some_method\", \"params\": \"invalid_params\", \"id\": 42}");
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-12 13:13:34 +00:00
|
|
|
ASSERT_FALSE(wfp_jsonrpc_is_request(doc.root()));
|
2020-03-22 12:36:03 +00:00
|
|
|
}
|