mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
added test for dirbuffer
This commit is contained in:
parent
60141c4d8a
commit
0502580850
@ -244,6 +244,7 @@ alltests = executable('alltests',
|
|||||||
'test/webfuse/tests/adapter/operation/test_getattr.cc',
|
'test/webfuse/tests/adapter/operation/test_getattr.cc',
|
||||||
'test/webfuse/tests/adapter/operation/test_lookup.cc',
|
'test/webfuse/tests/adapter/operation/test_lookup.cc',
|
||||||
'test/webfuse/tests/provider/test_client_protocol.cc',
|
'test/webfuse/tests/provider/test_client_protocol.cc',
|
||||||
|
'test/webfuse/tests/provider/test_dirbuffer.cc',
|
||||||
'test/webfuse/tests/provider/operation/test_close.cc',
|
'test/webfuse/tests/provider/operation/test_close.cc',
|
||||||
'test/webfuse/tests/provider/operation/test_getattr.cc',
|
'test/webfuse/tests/provider/operation/test_getattr.cc',
|
||||||
'test/webfuse/tests/provider/operation/test_lookup.cc',
|
'test/webfuse/tests/provider/operation/test_lookup.cc',
|
||||||
|
32
test/webfuse/tests/provider/test_dirbuffer.cc
Normal file
32
test/webfuse/tests/provider/test_dirbuffer.cc
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "webfuse/provider/impl/dirbuffer.h"
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
TEST(DirBuffer, CreateDispose)
|
||||||
|
{
|
||||||
|
wfp_dirbuffer * buffer = wfp_impl_dirbuffer_create();
|
||||||
|
wfp_impl_dirbuffer_dispose(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DirBuffer, Add)
|
||||||
|
{
|
||||||
|
wfp_dirbuffer * buffer = wfp_impl_dirbuffer_create();
|
||||||
|
wfp_impl_dirbuffer_add(buffer, "answer", 42);
|
||||||
|
|
||||||
|
ASSERT_EQ(1, json_array_size(buffer->entries));
|
||||||
|
|
||||||
|
json_t * entry = json_array_get(buffer->entries, 0);
|
||||||
|
ASSERT_STREQ("answer", json_string_value(json_object_get(entry, "name")));
|
||||||
|
ASSERT_EQ(42, json_integer_value(json_object_get(entry, "inode")));
|
||||||
|
|
||||||
|
wfp_impl_dirbuffer_dispose(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DirBuffer, Take)
|
||||||
|
{
|
||||||
|
wfp_dirbuffer * buffer = wfp_impl_dirbuffer_create();
|
||||||
|
json_t * entries = wfp_impl_dirbuffer_take(buffer);
|
||||||
|
wfp_impl_dirbuffer_dispose(buffer);
|
||||||
|
|
||||||
|
ASSERT_TRUE(json_is_array(entries));
|
||||||
|
json_decref(entries);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user