mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
added test of json doc
This commit is contained in:
parent
b15130cda6
commit
679d7763dd
@ -122,6 +122,7 @@ test_certs_dep = declare_dependency(
|
||||
|
||||
alltests = executable('alltests',
|
||||
'test/webfuse/json/test_writer.cc',
|
||||
'test/webfuse/json/test_doc.cc',
|
||||
'test/webfuse/jsonrpc/mock_timer_callback.cc',
|
||||
'test/webfuse/jsonrpc/mock_timer.cc',
|
||||
'test/webfuse/jsonrpc/test_is_request.cc',
|
||||
|
23
test/webfuse/json/test_doc.cc
Normal file
23
test/webfuse/json/test_doc.cc
Normal file
@ -0,0 +1,23 @@
|
||||
#include "webfuse/impl/json/doc.h"
|
||||
#include "webfuse/impl/json/node.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(json_doc, loadb)
|
||||
{
|
||||
char text[] = "true";
|
||||
wf_json_doc * doc = wf_impl_json_doc_loadb(text, 4);
|
||||
ASSERT_NE(nullptr, doc);
|
||||
|
||||
wf_json const * root = wf_impl_jsoc_doc_root(doc);
|
||||
ASSERT_EQ(WF_JSON_TYPE_BOOL, wf_impl_json_type(root));
|
||||
ASSERT_TRUE(wf_impl_json_bool_get(root));
|
||||
|
||||
wf_impl_json_doc_dispose(doc);
|
||||
}
|
||||
|
||||
TEST(json_doc, loadb_fail_invalid_json)
|
||||
{
|
||||
char text[] = "true";
|
||||
wf_json_doc * doc = wf_impl_json_doc_loadb(text, 3);
|
||||
ASSERT_EQ(nullptr, doc);
|
||||
}
|
Loading…
Reference in New Issue
Block a user