summaryrefslogtreecommitdiffstats
path: root/src/test/test-json.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-08-07 09:45:44 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-09-03 12:03:02 +0200
commited207e526117e39a3f3219b6c1d45c936ebce3e0 (patch)
tree8800a7e519f7216f8e6841fbe0ff9ea809b8111c /src/test/test-json.c
parentMerge pull request #34190 from DaanDeMeyer/repart-compress (diff)
downloadsystemd-ed207e526117e39a3f3219b6c1d45c936ebce3e0.tar.xz
systemd-ed207e526117e39a3f3219b6c1d45c936ebce3e0.zip
json-util: Add JSON_BUILD_STRING_ORDERED_SET()
Diffstat (limited to 'src/test/test-json.c')
-rw-r--r--src/test/test-json.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/test-json.c b/src/test/test-json.c
index aea4bbaf3e..f9dc9e74c7 100644
--- a/src/test/test-json.c
+++ b/src/test/test-json.c
@@ -12,6 +12,7 @@
#include "json-internal.h"
#include "json-util.h"
#include "math-util.h"
+#include "ordered-set.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
@@ -414,6 +415,19 @@ TEST(build) {
assert_se(sd_json_build(&ssv2, SD_JSON_BUILD_LITERAL("{\"zzz\":[\"kawumm\",\"pief\",\"xxxx\"]}")) >= 0);
assert_se(sd_json_variant_equal(ssv, ssv2));
+
+ _cleanup_ordered_set_free_ OrderedSet *oss = NULL;
+ assert_se(ordered_set_ensure_put(&oss, &string_hash_ops_free, ASSERT_PTR(strdup("pief"))) >= 0);
+ assert_se(ordered_set_ensure_put(&oss, &string_hash_ops_free, ASSERT_PTR(strdup("xxxx"))) >= 0);
+ assert_se(ordered_set_ensure_put(&oss, &string_hash_ops_free, ASSERT_PTR(strdup("kawumm"))) >= 0);
+
+ _cleanup_(sd_json_variant_unrefp) sd_json_variant *ossv = NULL;
+ assert_se(sd_json_build(&ossv, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("zzz", JSON_BUILD_STRING_ORDERED_SET(oss)))) >= 0);
+
+ _cleanup_(sd_json_variant_unrefp) sd_json_variant *ossv2 = NULL;
+ assert_se(sd_json_build(&ossv2, SD_JSON_BUILD_LITERAL("{\"zzz\":[\"pief\",\"xxxx\",\"kawumm\"]}")) >= 0);
+
+ assert_se(sd_json_variant_equal(ossv, ossv2));
}
TEST(json_buildo) {