]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: clarify that ordered_set_put() returns -EEXIST if entry is duplicated
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Jul 2020 12:28:53 +0000 (21:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Jul 2020 12:29:32 +0000 (21:29 +0900)
src/test/test-ordered-set.c

index 0d29fcfad25baa8cb6d755f717040e4aaa99feaf..581b0aa6a1a4bebaf60b2764947e43d28b4e258b 100644 (file)
@@ -57,7 +57,7 @@ static void test_set_free_with_hash_ops(void) {
 
 static void test_set_put(void) {
         _cleanup_ordered_set_free_ OrderedSet *m = NULL;
-        _cleanup_free_ char **t = NULL;
+        _cleanup_free_ char **t = NULL, *str = NULL;
 
         m = ordered_set_new(&string_hash_ops);
         assert_se(m);
@@ -71,6 +71,9 @@ static void test_set_put(void) {
         assert_se(ordered_set_put(m, (void*) "333") == 0);
         assert_se(ordered_set_put(m, (void*) "22") == 0);
 
+        assert_se(str = strdup("333"));
+        assert_se(ordered_set_put(m, str) == -EEXIST);
+
         assert_se(t = ordered_set_get_strv(m));
         assert_se(streq(t[0], "1"));
         assert_se(streq(t[1], "22"));