Skip to content

Commit 327e95c

Browse files
committed
Check return value for trie_insert.
1 parent 2dbb044 commit 327e95c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/test-trie.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@ void test_trie_new_free(void)
7676

7777
trie = trie_new();
7878

79-
trie_insert(trie, "hello", "there");
80-
trie_insert(trie, "hell", "testing");
81-
trie_insert(trie, "testing", "testing");
82-
trie_insert(trie, "", "asfasf");
79+
assert(trie_insert(trie, "hello", "there") != 0);
80+
assert(trie_insert(trie, "hell", "testing") != 0);
81+
assert(trie_insert(trie, "testing", "testing") != 0);
82+
assert(trie_insert(trie, "", "asfasf") != 0);
8383

8484
trie_free(trie);
8585

8686
/* Add a value, remove it and then free */
8787

8888
trie = trie_new();
8989

90-
trie_insert(trie, "hello", "there");
91-
assert(trie_remove(trie, "hello") == 1);
90+
assert(trie_insert(trie, "hello", "there") != 0);
91+
assert(trie_remove(trie, "hello") != 0);
9292

9393
trie_free(trie);
9494

@@ -203,7 +203,7 @@ void test_replace(void)
203203

204204
val = malloc(sizeof(int));
205205
*val = 999;
206-
trie_insert(trie, "999", val);
206+
assert(trie_insert(trie, "999", val) != 0);
207207
assert(trie_num_entries(trie) == 100000);
208208

209209
assert(trie_lookup(trie, "999") == val);
@@ -220,8 +220,8 @@ void test_insert_empty(void)
220220

221221
/* Test insert on empty string */
222222

223-
trie_insert(trie, "", buf);
224-
assert(trie_num_entries(trie) == 1);
223+
assert(trie_insert(trie, "", buf) != 0);
224+
assert(trie_num_entries(trie) != 0);
225225
assert(trie_lookup(trie, "") == buf);
226226
assert(trie_remove(trie, "") != 0);
227227

0 commit comments

Comments
 (0)