mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
added test of json writer
This commit is contained in:
parent
9fa6241b6b
commit
860757ea4c
@ -212,4 +212,58 @@ TEST(json_writer, reset)
|
||||
wf_impl_json_write_int(writer,42);
|
||||
|
||||
ASSERT_EQ("42", writer.take());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(json_writer, write_object_null)
|
||||
{
|
||||
writer writer;
|
||||
wf_impl_json_write_object_begin(writer);
|
||||
wf_impl_json_write_object_null(writer, "error");
|
||||
wf_impl_json_write_object_end(writer);
|
||||
|
||||
ASSERT_EQ("{\"error\":null}", writer.take());
|
||||
}
|
||||
|
||||
TEST(json_writer, write_object_bool)
|
||||
{
|
||||
writer writer;
|
||||
wf_impl_json_write_object_begin(writer);
|
||||
wf_impl_json_write_object_bool(writer, "result", true);
|
||||
wf_impl_json_write_object_end(writer);
|
||||
|
||||
ASSERT_EQ("{\"result\":true}", writer.take());
|
||||
}
|
||||
|
||||
TEST(json_writer, write_object_string_nocheck)
|
||||
{
|
||||
writer writer;
|
||||
wf_impl_json_write_object_begin(writer);
|
||||
wf_impl_json_write_object_string(writer, "result", "Hello,\tWorld!");
|
||||
wf_impl_json_write_object_end(writer);
|
||||
|
||||
ASSERT_EQ("{\"result\": \"Hello,\tWorld!\"}", writer.take());
|
||||
}
|
||||
|
||||
TEST(json_writer, write_object_bytes)
|
||||
{
|
||||
writer writer;
|
||||
wf_impl_json_write_object_begin(writer);
|
||||
wf_impl_json_write_object_bytes(writer, "result", "\0\0", 2);
|
||||
wf_impl_json_write_object_end(writer);
|
||||
|
||||
ASSERT_EQ("{\"result\": \"AAA\"}", writer.take());
|
||||
}
|
||||
|
||||
TEST(json_writer, realloc_buffer)
|
||||
{
|
||||
writer writer(1);
|
||||
wf_impl_json_write_string(writer, "very large contents");
|
||||
|
||||
ASSERT_EQ("very large contents", writer.take());
|
||||
}
|
||||
|
||||
TEST(json_writer, unexpected_end)
|
||||
{
|
||||
writer writer;
|
||||
wf_impl_json_write_array_end(writer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user