Browse Source

tests: appease -Wwrite-strings

tags/json-c-0.14-20200419
Pierce Lopez 6 years ago
parent
commit
634900d270
2 changed files with 5 additions and 3 deletions
  1. +2
    -1
      tests/test_deep_copy.c
  2. +3
    -2
      tests/test_double_serializer.c

+ 2
- 1
tests/test_deep_copy.c View File

@@ -186,7 +186,8 @@ int main(int argc, char **argv)
printf("\nTesting deep_copy with a custom serializer set\n");
json_object *with_serializer = json_object_new_string("notemitted");

json_object_set_serializer(with_serializer, my_custom_serializer, "dummy userdata", NULL);
char udata[] = "dummy userdata";
json_object_set_serializer(with_serializer, my_custom_serializer, udata, NULL);
json_object_object_add(src1, "with_serializer", with_serializer);
dst1 = NULL;
/* With a custom serializer in use, a custom shallow_copy function must also be used */


+ 3
- 2
tests/test_double_serializer.c View File

@@ -11,16 +11,17 @@
int main()
{
struct json_object *obj = json_object_new_double(0.5);
char udata[] = "test";

printf("Test default serializer:\n");
printf("obj.to_string(standard)=%s\n", json_object_to_json_string(obj));

printf("Test default serializer with custom userdata:\n");
obj->_userdata = "test";
obj->_userdata = udata;
printf("obj.to_string(userdata)=%s\n", json_object_to_json_string(obj));

printf("Test explicit serializer with custom userdata:\n");
json_object_set_serializer(obj, json_object_double_to_json_string, "test", NULL);
json_object_set_serializer(obj, json_object_double_to_json_string, udata, NULL);
printf("obj.to_string(custom)=%s\n", json_object_to_json_string(obj));

printf("Test reset serializer:\n");


Loading…
Cancel
Save