diff options
author | Ronny Chevalier <chevalier.ronny@gmail.com> | 2015-04-10 16:53:17 +0200 |
---|---|---|
committer | Ronny Chevalier <chevalier.ronny@gmail.com> | 2015-04-10 17:13:15 +0200 |
commit | 756c09e672a08efd9e728a5cab50a641b022b84c (patch) | |
tree | 5361b58f9b8d79b671ba496c0d95f2f7713a4076 /src/test/test-set.c | |
parent | 17493fa5d17cadce3b773692d3eeab137de7d323 (diff) |
core: set_put never returns -EEXIST
When the value is already there it returns 0.
Also add a test to ensure this
Diffstat (limited to 'src/test/test-set.c')
-rw-r--r-- | src/test/test-set.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/test-set.c b/src/test/test-set.c index ac292ed680..0ee5ddcc9f 100644 --- a/src/test/test-set.c +++ b/src/test/test-set.c @@ -39,8 +39,25 @@ static void test_set_steal_first(void) { assert_se(set_isempty(m)); } +static void test_set_put(void) { + _cleanup_set_free_ Set *m = NULL; + + m = set_new(&string_hash_ops); + assert_se(m); + + assert_se(set_put(m, (void*) "1") == 1); + assert_se(set_put(m, (void*) "22") == 1); + assert_se(set_put(m, (void*) "333") == 1); + assert_se(set_put(m, (void*) "333") == 0); + assert_se(set_remove(m, (void*) "333")); + assert_se(set_put(m, (void*) "333") == 1); + assert_se(set_put(m, (void*) "333") == 0); + assert_se(set_put(m, (void*) "22") == 0); +} + int main(int argc, const char *argv[]) { test_set_steal_first(); + test_set_put(); return 0; } |