removed unused code

pull/3/head
Falk Werner 4 years ago
parent 63cc5b5388
commit 59105c291e

@ -1,27 +0,0 @@
#include "webfuse_provider/impl/util/json_util.h"
int wfp_impl_json_get_integer(json_t const * object, char const * key, int default_value)
{
int result = default_value;
json_t * holder = json_object_get(object, key);
if (json_is_integer(holder))
{
result = json_integer_value(holder);
}
return result;
}
wfp_status
wfp_impl_jsonrpc_get_status(
json_t const * error)
{
wfp_status status = WFP_GOOD;
if (NULL != error)
{
status = wfp_impl_json_get_integer(error, "code", WFP_BAD_FORMAT);
}
return status;
}

@ -1,26 +0,0 @@
#ifndef WFP_JSON_UTIL_H
#define WFP_JSON_UTIL_H
#include <jansson.h>
#include "webfuse_provider/status.h"
#ifdef __cplusplus
extern "C"
{
#endif
extern int
wfp_impl_json_get_integer(
json_t const * object,
char const * key,
int default_value);
extern wfp_status
wfp_impl_jsonrpc_get_status(
json_t const * error);
#ifdef __cplusplus
}
#endif
#endif

@ -24,7 +24,6 @@ webfuse_provider_static = static_library('webfuse_provider',
'lib/webfuse_provider/impl/util/slist.c',
'lib/webfuse_provider/impl/util/base64.c',
'lib/webfuse_provider/impl/util/lws_log.c',
'lib/webfuse_provider/impl/util/json_util.c',
'lib/webfuse_provider/impl/util/url.c',
'lib/webfuse_provider/impl/timer/manager.c',
'lib/webfuse_provider/impl/timer/timepoint.c',
@ -127,7 +126,6 @@ alltests = executable('alltests',
'test/webfuse_provider/jsonrpc/test_response_parser.cc',
'test/webfuse_provider/timer/test_timepoint.cc',
'test/webfuse_provider/timer/test_timer.cc',
'test/webfuse_provider/util/test_util.cc',
'test/webfuse_provider/util/test_container_of.cc',
'test/webfuse_provider/util/test_slist.cc',
'test/webfuse_provider/util/test_base64.cc',

@ -130,4 +130,10 @@ TEST(json_parser, parse_fail_invalid_json)
ASSERT_EQ(nullptr, doc);
}
{
char text[] = "[\"method\",[], {}, \"params\":,42]";
wfp_json_doc * doc = parse_json(text);
ASSERT_EQ(nullptr, doc);
}
}

@ -1,72 +0,0 @@
#include <gtest/gtest.h>
#include "webfuse_provider/impl/util/json_util.h"
TEST(jsonrpc_util, get_int)
{
json_t * object = json_object();
json_object_set_new(object, "key", json_integer(23));
int value = wfp_impl_json_get_integer(object, "key", 42);
ASSERT_EQ(23, value);
json_decref(object);
}
TEST(jsonrpc_util, failed_to_get_null_object)
{
int value = wfp_impl_json_get_integer(nullptr, "key", 42);
ASSERT_EQ(42, value);
}
TEST(jsonrpc_util, failed_to_get_not_object)
{
json_t * object = json_array();
int value = wfp_impl_json_get_integer(nullptr, "key", 42);
ASSERT_EQ(42, value);
json_decref(object);
}
TEST(jsonrpc_util, failed_to_get_invalid_key)
{
json_t * object = json_object();
int value = wfp_impl_json_get_integer(object, "key", 42);
ASSERT_EQ(42, value);
json_decref(object);
}
TEST(jsonrpc_util, failed_to_get_invalid_value_type)
{
json_t * object = json_object();
json_object_set_new(object, "key", json_string("42"));
int value = wfp_impl_json_get_integer(object, "key", 42);
ASSERT_EQ(42, value);
json_decref(object);
}
TEST(jsonrpc_util, get_status_good_if_no_error)
{
json_t * error = nullptr;
wfp_status status = wfp_impl_jsonrpc_get_status(error);
ASSERT_EQ(WFP_GOOD, status);
}
TEST(jsonrpc_util, get_status)
{
json_t * error = json_object();
json_object_set_new(error, "code", json_integer(WFP_BAD_BUSY));
wfp_status status = wfp_impl_jsonrpc_get_status(error);
ASSERT_EQ(WFP_BAD_BUSY, status);
json_decref(error);
}
TEST(jsonrpc_util, get_status_bad_format)
{
json_t * error = json_array();
json_array_append_new(error, json_integer(WFP_BAD_BUSY));
wfp_status status = wfp_impl_jsonrpc_get_status(error);
ASSERT_EQ(WFP_BAD_FORMAT, status);
json_decref(error);
}
Loading…
Cancel
Save