test-json-parser.c revision 95f5b08fa73ddd9a9de40a97aa141e9c74e0645e
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen/* Copyright (c) 2013-2017 Dovecot authors, see the included COPYING file */
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainenstatic const char json_input[] =
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\t\"key\"\t:\t\t\"string\","
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen " \"key2\" : 1234, \n"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key3\":true,"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key4\":false,"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"skip1\": \"jsifjaisfjiasji\","
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"skip2\": { \"x\":{ \"y\":123}, \"z\":[5,[6],{\"k\":0},3]},"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key5\":null,"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key6\": {},"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key7\": {"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen " \"sub1\":\"value\""
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key8\": {"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen " \"sub2\":-12.456,\n"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen " \"sub3\":12.456e9,\n"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen " \"sub4\":0.456e-789"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key9\": \"foo\\\\\\\"\\b\\f\\n\\r\\t\\u0001\\u10ff\","
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key10\": \"foo\\\\\\\"\\b\\f\\n\\r\\t\\u0001\\u10ff\","
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key11\": [],"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key12\": [ \"foo\" , 5.24,[true],{\"aobj\":[]}],"
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainen "\"key13\": \"\\ud801\\udc37\""
e8490a52a1bc71bc53034e68f464435684ad810fTimo Sirainenstatic const struct {
const unsigned char *data;
if (ret == 0)
int ret = 0;
pos++;
if (ret <= 0)
pos++;
test_end();
static void test_json_parser_skip_array(void)
static const char *test_input =
test_end();
int ret = 0;
ret++;
return ret;
static void test_json_parser_primitive_values(void)
const char *str;
int ret;
} test_inputs[] = {
test_assert_idx(test_json_parse_input(test_inputs[i].str, JSON_PARSER_NO_ROOT_OBJECT) == test_inputs[i].ret, i);
test_end();
static void test_json_parser_errors(void)
static const char *test_inputs[] = {
test_end();
static void test_json_append_escaped(void)
test_end();
static void test_json_append_escaped_data(void)
static const unsigned char test_input[] =
test_end();
void test_json_parser(void)