strset: set errno to ENOENT even if we return NULL.
[ccan] / ccan / strset / test / run.c
index cfda0ee38f0ce998a16c5779fc793d8bf0722565..412a1fdfb1b1532ccb41e03569bee8feff5c0cc7 100644 (file)
@@ -10,20 +10,25 @@ int main(void)
        char *dup = strdup(str);
 
        /* This is how many tests you plan to run */
-       plan_tests(26);
+       plan_tests(36);
 
        strset_init(&set);
 
        ok1(!strset_test(&set, str));
+       ok1(errno == ENOENT);
        ok1(!strset_test(&set, none));
+       ok1(errno == ENOENT);
        ok1(!strset_clear(&set, str));
+       ok1(errno == ENOENT);
        ok1(!strset_clear(&set, none));
+       ok1(errno == ENOENT);
 
        ok1(strset_set(&set, str));
        ok1(strset_test(&set, str));
        /* We compare the string, not the pointer. */
        ok1(strset_test(&set, dup));
        ok1(!strset_test(&set, none));
+       ok1(errno == ENOENT);
 
        /* Add of duplicate should fail. */
        ok1(!strset_set(&set, dup));
@@ -32,17 +37,22 @@ int main(void)
        /* Delete should return original string. */
        ok1(strset_clear(&set, dup) == str);
        ok1(!strset_test(&set, str));
+       ok1(errno == ENOENT);
        ok1(!strset_test(&set, none));
+       ok1(errno == ENOENT);
 
        /* Try insert and delete of empty string. */
        ok1(strset_set(&set, none));
        ok1(strset_test(&set, none));
        ok1(!strset_test(&set, str));
+       ok1(errno == ENOENT);
 
        /* Delete should return original string. */
        ok1(strset_clear(&set, "") == none);
        ok1(!strset_test(&set, str));
+       ok1(errno == ENOENT);
        ok1(!strset_test(&set, none));
+       ok1(errno == ENOENT);
 
        /* Both at once... */
        ok1(strset_set(&set, none));