From 3c4f5f13005b3cd2719abadea5abe00de78a4ab1 Mon Sep 17 00:00:00 2001 From: Jakob Olsson <jakob.olsson@iopsys.eu> Date: Thu, 3 Oct 2019 14:19:57 +0200 Subject: [PATCH] stylistic test cleanup --- test/api_test.c | 198 ++++++++++++++++++++++++------------------------ 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/test/api_test.c b/test/api_test.c index 02f2a5f..76d5001 100644 --- a/test/api_test.c +++ b/test/api_test.c @@ -90,8 +90,8 @@ static void test_build_from_scratch(void **state) }\ }", json_type_object); - printf("e->file_obj=%s\n", json_object_get_string(file)); - printf("e->modify_obj=%s\n", json_object_get_string(jobj)); + printf("expected json: %s\n", json_object_get_string(file)); + printf("created json: %s\n", json_object_get_string(jobj)); assert_int_equal(1, json_object_equal(file, jobj)); json_object_put(jobj); @@ -109,8 +109,8 @@ static void test_json_set_object(void **state) json_object_set_by_string(&e->modify_obj, "string", "{\"test2\":\"success\"}", json_type_object); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -130,8 +130,8 @@ static void test_json_set_array(void **state) json_object_set_by_string(&e->modify_obj, "ints", "[ 1, 2, 3 ]", json_type_array); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -164,8 +164,8 @@ static void test_json_set_multi_types(void **state) json_object_set_by_string(&e->modify_obj, "string", "1", json_type_string); json_object_set_by_string(&e->modify_obj, "integer", "1", json_type_int); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -195,8 +195,8 @@ static void test_json_set_multi_obj(void **state) json_object_set_by_string(&e->modify_obj, NULL, "{ \"nested0\": {\"nested1\": {\"integer\": 1}}, \"ints\": [1, 2, 3], \"string\":\"1\", \"integer\": 1}", json_type_object); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -211,8 +211,8 @@ static void test_json_set_string(void **state) json_object_set_by_string(&e->modify_obj, "string", "1", json_type_string); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -238,8 +238,8 @@ static void test_json_set_overwrite_string(void **state) json_object_set_by_string(&e->modify_obj, "nested.api", "2", json_type_string); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -254,8 +254,8 @@ static void test_json_set_int(void **state) json_object_set_by_string(&e->modify_obj, "integer", "1", json_type_int); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -275,8 +275,8 @@ static void test_json_set_int_nested(void **state) json_object_set_by_string(&e->modify_obj, "nested0.nested1.integer", "1", json_type_int); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -298,8 +298,8 @@ static void test_json_set_array_int(void **state) json_object_set_by_string(&e->modify_obj, "array1[-1]", "1", json_type_int); json_object_set_by_string(&e->modify_obj, "inner.array[-1]", "1", json_type_int); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -325,8 +325,8 @@ static void test_json_set_array_object(void **state) json_object_set_by_string(&e->modify_obj, "array123[0].string", "test", json_type_string); json_object_set_by_string(&e->modify_obj, "array123[-1]", "{\"integer\": 1, \"string\":\"test\"}", json_type_object); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -358,8 +358,8 @@ static void test_json_set_array_nested_object(void **state) json_object_set_by_string(&e->modify_obj, "array123[-1].nested", "{\"nested1\": {\"integer\": 1}}", json_type_object); json_object_set_by_string(&e->modify_obj, "array123[-1]", "{\"nested\": {\"nested1\": {\"integer\": 1}}}", json_type_object); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -396,8 +396,8 @@ static void test_json_set_array_nested_array(void **state) json_object_set_by_string(&e->modify_obj, "array123[1][-1]", "6", json_type_int); json_object_set_by_string(&e->modify_obj, "array123[1][-1]", "7", json_type_int); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -407,141 +407,141 @@ static void test_json_set_array_nested_array(void **state) static void test_json_get_int(void **state) { struct test_env *e = (struct test_env *) *state; - struct json_object *tmp, *obj; + struct json_object *j_ptr, *obj; - json_object_object_get_ex(e->file_obj, "integer", &tmp); + json_object_object_get_ex(e->file_obj, "integer", &j_ptr); obj = json_object_get_by_string(e->file_obj, "integer"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("tmp=%s\n", json_object_get_string(tmp)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("getter value: %s\n", json_object_get_string(j_ptr)); - assert_non_null(e->file_obj); - assert_non_null(e->modify_obj); - assert_int_equal(1, json_object_equal(tmp, obj)); + assert_non_null(j_ptr); + assert_non_null(obj); + assert_int_equal(1, json_object_equal(j_ptr, obj)); } static void test_json_get_string(void **state) { struct test_env *e = (struct test_env *) *state; - struct json_object *tmp, *obj; + struct json_object *j_ptr, *obj; - json_object_object_get_ex(e->file_obj, "test", &tmp); + json_object_object_get_ex(e->file_obj, "test", &j_ptr); obj = json_object_get_by_string(e->file_obj, "test"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("tmp=%s\n", json_object_get_string(tmp)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("getter value: %s\n", json_object_get_string(j_ptr)); - assert_non_null(e->file_obj); - assert_non_null(e->modify_obj); - assert_int_equal(1, json_object_equal(tmp, obj)); + assert_non_null(j_ptr); + assert_non_null(obj); + assert_int_equal(1, json_object_equal(j_ptr, obj)); } static void test_json_get_array(void **state) { struct test_env *e = (struct test_env *) *state; - struct json_object *tmp, *obj; + struct json_object *j_ptr, *obj; - json_object_object_get_ex(e->file_obj, "simple_array", &tmp); + json_object_object_get_ex(e->file_obj, "simple_array", &j_ptr); obj = json_object_get_by_string(e->file_obj, "simple_array"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("tmp=%s\n", json_object_get_string(tmp)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("getter value: %s\n", json_object_get_string(j_ptr)); - assert_non_null(e->file_obj); - assert_non_null(e->modify_obj); - assert_int_equal(1, json_object_equal(tmp, obj)); + assert_non_null(j_ptr); + assert_non_null(obj); + assert_int_equal(1, json_object_equal(j_ptr, obj)); } static void test_json_get_object(void **state) { struct test_env *e = (struct test_env *) *state; - struct json_object *tmp, *obj; + struct json_object *j_ptr, *obj; - json_object_object_get_ex(e->file_obj, "nested", &tmp); + json_object_object_get_ex(e->file_obj, "nested", &j_ptr); obj = json_object_get_by_string(e->file_obj, "nested"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("tmp=%s\n", json_object_get_string(tmp)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("getter value: %s\n", json_object_get_string(j_ptr)); - assert_non_null(e->file_obj); - assert_non_null(e->modify_obj); - assert_int_equal(1, json_object_equal(tmp, obj)); + assert_non_null(j_ptr); + assert_non_null(obj); + assert_int_equal(1, json_object_equal(j_ptr, obj)); } static void test_json_get_nested_object(void **state) { struct test_env *e = (struct test_env *) *state; - struct json_object *tmp, *obj; + struct json_object *j_ptr, *obj; - json_object_object_get_ex(e->file_obj, "nested", &tmp); - json_object_object_get_ex(tmp, "api", &tmp); + json_object_object_get_ex(e->file_obj, "nested", &j_ptr); + json_object_object_get_ex(j_ptr, "api", &j_ptr); obj = json_object_get_by_string(e->file_obj, "nested.api"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("tmp=%s\n", json_object_get_string(tmp)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("getter value: %s\n", json_object_get_string(j_ptr)); - assert_non_null(e->file_obj); - assert_non_null(e->modify_obj); - assert_int_equal(1, json_object_equal(tmp, obj)); + assert_non_null(j_ptr); + assert_non_null(obj); + assert_int_equal(1, json_object_equal(j_ptr, obj)); } static void test_json_get_array_int(void **state) { struct test_env *e = (struct test_env *) *state; - struct json_object *tmp, *obj; + struct json_object *j_ptr, *obj; - json_object_object_get_ex(e->file_obj, "simple_array", &tmp); - tmp = json_object_array_get_idx(tmp, 1); + json_object_object_get_ex(e->file_obj, "simple_array", &j_ptr); + j_ptr = json_object_array_get_idx(j_ptr, 1); obj = json_object_get_by_string(e->file_obj, "simple_array[1]"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("tmp=%s\n", json_object_get_string(tmp)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("getter value: %s\n", json_object_get_string(j_ptr)); - assert_non_null(e->file_obj); - assert_non_null(e->modify_obj); - assert_int_equal(1, json_object_equal(tmp, obj)); + assert_non_null(j_ptr); + assert_non_null(obj); + assert_int_equal(1, json_object_equal(j_ptr, obj)); } static void test_json_get_array_nested_int(void **state) { struct test_env *e = (struct test_env *) *state; - struct json_object *tmp, *obj; + struct json_object *j_ptr, *obj; - json_object_object_get_ex(e->file_obj, "array", &tmp); - tmp = json_object_array_get_idx(tmp, 1); - tmp = json_object_array_get_idx(tmp, 2); + json_object_object_get_ex(e->file_obj, "array", &j_ptr); + j_ptr = json_object_array_get_idx(j_ptr, 1); + j_ptr = json_object_array_get_idx(j_ptr, 2); obj = json_object_get_by_string(e->file_obj, "array[1][-1]"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("tmp=%s\n", json_object_get_string(tmp)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("getter value: %s\n", json_object_get_string(j_ptr)); - assert_non_null(e->file_obj); - assert_non_null(e->modify_obj); - assert_int_equal(1, json_object_equal(tmp, obj)); + assert_non_null(j_ptr); + assert_non_null(obj); + assert_int_equal(1, json_object_equal(j_ptr, obj)); } static void test_json_get_object_array_nested_int(void **state) { struct test_env *e = (struct test_env *) *state; - struct json_object *tmp, *obj; + struct json_object *j_ptr, *obj; - json_object_object_get_ex(e->file_obj, "complex_nested", &tmp); - json_object_object_get_ex(tmp, "array", &tmp); - tmp = json_object_array_get_idx(tmp, 1); - json_object_object_get_ex(tmp, "test2", &tmp); + json_object_object_get_ex(e->file_obj, "complex_nested", &j_ptr); + json_object_object_get_ex(j_ptr, "array", &j_ptr); + j_ptr = json_object_array_get_idx(j_ptr, 1); + json_object_object_get_ex(j_ptr, "test2", &j_ptr); obj = json_object_get_by_string(e->file_obj, "complex_nested.array[1].test2"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("tmp=%s\n", json_object_get_string(tmp)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("getter value: %s\n", json_object_get_string(j_ptr)); - assert_non_null(e->file_obj); - assert_non_null(e->modify_obj); - assert_int_equal(1, json_object_equal(tmp, obj)); + assert_non_null(j_ptr); + assert_non_null(obj); + assert_int_equal(1, json_object_equal(j_ptr, obj)); } static void test_json_write_to_file(void **state) @@ -553,8 +553,8 @@ static void test_json_write_to_file(void **state) obj = json_object_file_to_obj("cpy.json"); - printf("obj=%s\n", json_object_get_string(obj)); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); + printf("expected value: %s\n", json_object_get_string(obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); assert_non_null(e->file_obj); assert_non_null(obj); @@ -573,8 +573,8 @@ static void test_json_set_object_invalid_format(void **state) json_object_set_by_string(&e->modify_obj, "string", "{\"test2\":\"success\"", json_type_object); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -594,8 +594,8 @@ static void test_json_set_array_invalid_format(void **state) json_object_set_by_string(&e->modify_obj, "ints", "[ 1, 2 3 ]", json_type_array); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -610,8 +610,8 @@ static void test_json_set_wrong_type_string_to_int(void **state) json_object_set_by_string(&e->modify_obj, "string", "abc", json_type_int); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->file_obj); assert_non_null(e->modify_obj); @@ -626,8 +626,8 @@ static void test_json_set_wrong_type_int_to_string(void **state) json_object_set_by_string(&e->modify_obj, "string", "1", json_type_string); - printf("e->file_obj=%s\n", json_object_get_string(e->file_obj)); - printf("e->modify_obj=%s\n", json_object_get_string(e->modify_obj)); + printf("expected json: %s\n", json_object_get_string(e->file_obj)); + printf("created json: %s\n", json_object_get_string(e->modify_obj)); assert_non_null(e->modify_obj); assert_int_not_equal(1, json_object_equal(e->modify_obj, e->file_obj)); -- GitLab