Skip to content
Snippets Groups Projects
Commit c78ab31e authored by Jakob Olsson's avatar Jakob Olsson
Browse files

reintroduce parse tests

parent 867a96da
No related branches found
No related tags found
No related merge requests found
......@@ -15,17 +15,39 @@ struct test_env {
static void test_cfg_parse_success(void **state)
{
struct json_object *file = json_object_file_to_obj("test.json");
struct json_object *obj = json_object_new_object();
struct json_object *tot = json_object_new_object();
struct json_object *expected = json_tokener_parse("{\
\"test\":\"success\",\
\"nested\": { \
\"api\":\"test2\"\
},\
\"integer\": 1,\
\"simple_array\": [1, 2, 3, 4],\
\"array\": [[1, 2, 3],[4, 5, 6]],\
\"complex_nested\": {\
\"dummy\": {},\
\"array\": [\
{\
\"test\":\"1\",\
\"test2\":2\
},\
{\
\"test\": \"3\",\
\"test2\": 4\
}\
]\
}\
}");
assert_non_null(file);
printf("expected json: %s\n", json_object_get_string(file));
printf("read from file: %s\n", json_object_get_string(expected));
json_object_object_add(obj, "api", json_object_new_string("test2"));
json_object_object_add(tot, "nested", obj);
json_object_object_add(tot, "test", json_object_new_string("success"));
assert_non_null(file);
assert_non_null(expected);
assert_int_equal(1, json_object_equal(file, tot));
assert_int_equal(1, json_object_equal(file, expected));
json_object_put(file);
json_object_put(expected);
}
static void test_cfg_parse_fail(void **state)
......@@ -647,8 +669,8 @@ static int group_teardown(void** state) {
int main(void) {
const struct CMUnitTest tests[] = {
//cmocka_unit_test(test_cfg_parse_success),
//cmocka_unit_test(test_cfg_parse_fail),
cmocka_unit_test(test_cfg_parse_success),
cmocka_unit_test(test_cfg_parse_fail),
cmocka_unit_test(test_build_from_scratch),
cmocka_unit_test_setup_teardown(test_json_set_int, setup, teardown),
cmocka_unit_test_setup_teardown(test_json_set_int_nested, setup, teardown),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment