mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
refactor: replaced jansson by own json parser implementation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "webfuse_provider/impl/operation/close.h"
|
||||
#include "webfuse_provider/impl/json/parser.h"
|
||||
#include "webfuse_provider/mocks/mock_provider.hpp"
|
||||
#include "webfuse_provider/mocks/fake_invokation_context.hpp"
|
||||
|
||||
@@ -10,23 +11,16 @@ using ::testing::_;
|
||||
|
||||
TEST(wfp_close, close)
|
||||
{
|
||||
int inode = 42;
|
||||
int handle = 0xdeadbeef;
|
||||
int flags = 23;
|
||||
|
||||
MockProvider provider;
|
||||
EXPECT_CALL(provider, close(inode, handle, flags)).Times(1);
|
||||
EXPECT_CALL(provider, close(42, 101, 23)).Times(1);
|
||||
|
||||
wfp_impl_invokation_context context = create_context(provider);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(inode));
|
||||
json_array_append_new(params, json_integer(handle));
|
||||
json_array_append_new(params, json_integer(flags));
|
||||
char params[] = "[\"test.filesystem\", 42, 101, 23]";
|
||||
wfp_json_doc * doc = wfp_impl_json_parse(params);
|
||||
|
||||
wfp_impl_close(&context, params, 42);
|
||||
json_decref(params);
|
||||
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
|
||||
wfp_impl_json_dispose(doc);
|
||||
}
|
||||
|
||||
TEST(wfp_close, close_fail_invalid_param_count)
|
||||
@@ -36,9 +30,11 @@ TEST(wfp_close, close_fail_invalid_param_count)
|
||||
|
||||
wfp_impl_invokation_context context = create_context(provider);
|
||||
|
||||
json_t * params = json_array();
|
||||
wfp_impl_close(&context, params, 42);
|
||||
json_decref(params);
|
||||
char params[] = "[]";
|
||||
wfp_json_doc * doc = wfp_impl_json_parse(params);
|
||||
|
||||
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
|
||||
wfp_impl_json_dispose(doc);
|
||||
}
|
||||
|
||||
TEST(wfp_close, close_fail_inode_invalid_type)
|
||||
@@ -48,14 +44,11 @@ TEST(wfp_close, close_fail_inode_invalid_type)
|
||||
|
||||
wfp_impl_invokation_context context = create_context(provider);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_string("42"));
|
||||
json_array_append_new(params, json_integer(0));
|
||||
json_array_append_new(params, json_integer(0));
|
||||
char params[] = "[\"test.filesystem\", \"42\", 0, 0]";
|
||||
wfp_json_doc * doc = wfp_impl_json_parse(params);
|
||||
|
||||
wfp_impl_close(&context, params, 42);
|
||||
json_decref(params);
|
||||
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
|
||||
wfp_impl_json_dispose(doc);
|
||||
}
|
||||
|
||||
TEST(wfp_close, close_fail_handle_invalid_type)
|
||||
@@ -65,14 +58,11 @@ TEST(wfp_close, close_fail_handle_invalid_type)
|
||||
|
||||
wfp_impl_invokation_context context = create_context(provider);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(0));
|
||||
json_array_append_new(params, json_string("42"));
|
||||
json_array_append_new(params, json_integer(0));
|
||||
char params[] = "[\"test.filesystem\", 0, \"42\", 0]";
|
||||
wfp_json_doc * doc = wfp_impl_json_parse(params);
|
||||
|
||||
wfp_impl_close(&context, params, 42);
|
||||
json_decref(params);
|
||||
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
|
||||
wfp_impl_json_dispose(doc);
|
||||
}
|
||||
|
||||
TEST(wfp_close, close_fail_flags_invalid_type)
|
||||
@@ -82,14 +72,11 @@ TEST(wfp_close, close_fail_flags_invalid_type)
|
||||
|
||||
wfp_impl_invokation_context context = create_context(provider);
|
||||
|
||||
json_t * params = json_array();
|
||||
json_array_append_new(params, json_string("test.filesystem"));
|
||||
json_array_append_new(params, json_integer(0));
|
||||
json_array_append_new(params, json_integer(0));
|
||||
json_array_append_new(params, json_string("42"));
|
||||
char params[] = "[\"test.filesystem\", 0, 0, \"42\"]";
|
||||
wfp_json_doc * doc = wfp_impl_json_parse(params);
|
||||
|
||||
wfp_impl_close(&context, params, 42);
|
||||
json_decref(params);
|
||||
wfp_impl_close(&context, wfp_impl_json_root(doc), 42);
|
||||
wfp_impl_json_dispose(doc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user