summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Haszlakiewicz <erh+git@nimenees.com>2022-07-30 19:27:14 +0000
committerEric Haszlakiewicz <erh+git@nimenees.com>2022-07-30 19:27:14 +0000
commit9749b0cb66b32ddac4bbbca28dd9009968722a9f (patch)
treeb95232e9864cc3c81b9915b46d492c21da88e7ff /tests
parent2e9b7456a5608efbd49fd4c4b51cb6ed7b63cc15 (diff)
downloadjson-c-9749b0cb66b32ddac4bbbca28dd9009968722a9f.tar.gz
When serializing with JSON_C_TO_STRING_PRETTY set, keep the opening and closing curly or square braces on same line for empty objects or arrays. Issue #778.
Diffstat (limited to 'tests')
-rw-r--r--tests/test1.c5
-rw-r--r--tests/test1.expected2
-rw-r--r--tests/test1Formatted_plain.expected2
-rw-r--r--tests/test1Formatted_pretty.expected4
-rw-r--r--tests/test1Formatted_spaced.expected2
-rw-r--r--tests/test1Formatted_spaced_pretty.expected4
-rw-r--r--tests/test1Formatted_spaced_pretty_pretty_tab.expected4
7 files changed, 17 insertions, 6 deletions
diff --git a/tests/test1.c b/tests/test1.c
index 01796ab..befd246 100644
--- a/tests/test1.c
+++ b/tests/test1.c
@@ -311,6 +311,11 @@ int main(int argc, char **argv)
{
printf("\t%s: %s\n", key, json_object_to_json_string(val));
}
+
+ json_object *empty_array = json_object_new_array();
+ json_object *empty_obj = json_object_new_object();
+ json_object_object_add(my_object, "empty_array", empty_array);
+ json_object_object_add(my_object, "empty_obj", empty_obj);
printf("my_object.to_string()=%s\n", json_object_to_json_string(my_object));
json_object_put(my_array);
diff --git a/tests/test1.expected b/tests/test1.expected
index 4b6b252..b473a8b 100644
--- a/tests/test1.expected
+++ b/tests/test1.expected
@@ -75,4 +75,4 @@ my_object=
foo: "bar"
bool0: false
bool1: true
-my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true }
+my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "empty_array": [ ], "empty_obj": { } }
diff --git a/tests/test1Formatted_plain.expected b/tests/test1Formatted_plain.expected
index 128e274..ad12d99 100644
--- a/tests/test1Formatted_plain.expected
+++ b/tests/test1Formatted_plain.expected
@@ -75,4 +75,4 @@ my_object=
foo: "bar"
bool0: false
bool1: true
-my_object.to_string()={"abc":12,"foo":"bar","bool0":false,"bool1":true}
+my_object.to_string()={"abc":12,"foo":"bar","bool0":false,"bool1":true,"empty_array":[],"empty_obj":{}}
diff --git a/tests/test1Formatted_pretty.expected b/tests/test1Formatted_pretty.expected
index b67185f..ab2cc78 100644
--- a/tests/test1Formatted_pretty.expected
+++ b/tests/test1Formatted_pretty.expected
@@ -97,5 +97,7 @@ my_object.to_string()={
"abc":12,
"foo":"bar",
"bool0":false,
- "bool1":true
+ "bool1":true,
+ "empty_array":[],
+ "empty_obj":{}
}
diff --git a/tests/test1Formatted_spaced.expected b/tests/test1Formatted_spaced.expected
index fe6979d..f57bd05 100644
--- a/tests/test1Formatted_spaced.expected
+++ b/tests/test1Formatted_spaced.expected
@@ -75,4 +75,4 @@ my_object=
foo: "bar"
bool0: false
bool1: true
-my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true }
+my_object.to_string()={ "abc": 12, "foo": "bar", "bool0": false, "bool1": true, "empty_array": [ ], "empty_obj": { } }
diff --git a/tests/test1Formatted_spaced_pretty.expected b/tests/test1Formatted_spaced_pretty.expected
index 104a554..c88729f 100644
--- a/tests/test1Formatted_spaced_pretty.expected
+++ b/tests/test1Formatted_spaced_pretty.expected
@@ -97,5 +97,7 @@ my_object.to_string()={
"abc": 12,
"foo": "bar",
"bool0": false,
- "bool1": true
+ "bool1": true,
+ "empty_array": [],
+ "empty_obj": {}
}
diff --git a/tests/test1Formatted_spaced_pretty_pretty_tab.expected b/tests/test1Formatted_spaced_pretty_pretty_tab.expected
index f9a8e87..bab239f 100644
--- a/tests/test1Formatted_spaced_pretty_pretty_tab.expected
+++ b/tests/test1Formatted_spaced_pretty_pretty_tab.expected
@@ -97,5 +97,7 @@ my_object.to_string()={
"abc": 12,
"foo": "bar",
"bool0": false,
- "bool1": true
+ "bool1": true,
+ "empty_array": [],
+ "empty_obj": {}
}