Skip to content

Commit 37919af

Browse files
kartbendkalowsk
authored andcommitted
tests: lib: min_heap: use more descriptive assert_ macros
make test cases more readable using more direct assert_ macros, for example zassert_not_null(foo, ...) instead of zassert_true(foo != NULL, ...). Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent b33e28d commit 37919af

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/lib/min_heap/src/test_min_heap.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static void validate_heap_order_gt(struct min_heap *h)
7676

7777
while (h->size > 0) {
7878
ret = min_heap_pop(h, &temp);
79-
zassert_true(ret == true, "pop failure");
79+
zassert_true(ret, "pop failure");
8080
memcpy(&result[idx++], &temp, sizeof(struct data));
8181
}
8282

@@ -97,7 +97,7 @@ static void validate_heap_order_ls(struct min_heap *h)
9797

9898
while (h->size > 0) {
9999
ret = min_heap_pop(h, &temp);
100-
zassert_true(ret == true, "pop failure");
100+
zassert_true(ret, "pop failure");
101101
memcpy(&result[idx++], &temp, sizeof(struct data));
102102
}
103103

@@ -149,8 +149,8 @@ ZTEST(min_heap_api, test_peek_and_pop)
149149
peek_key = peek->key;
150150
min_heap_pop(&runtime_heap, &pop);
151151

152-
zassert_true(peek_key == pop.key, "Peek/pop error");
153-
zassert_true(pop.key == LOWEST_PRIORITY_LS, "heap error %d", pop.key);
152+
zassert_equal(peek_key, pop.key, "Peek/pop error");
153+
zassert_equal(pop.key, LOWEST_PRIORITY_LS, "heap error %d", pop.key);
154154
validate_heap_order_ls(&runtime_heap);
155155
}
156156

@@ -170,10 +170,10 @@ ZTEST(min_heap_api, test_find_and_remove)
170170

171171
found = min_heap_find(&my_heap, match_key, &target_key, &index);
172172

173-
zassert_true(found != NULL, "min_heap_find failure");
173+
zassert_not_null(found, "min_heap_find failure");
174174
min_heap_remove(&my_heap, index, &removed);
175175
validate_heap_order_ls(&my_heap);
176-
zassert_true(min_heap_is_empty(&my_heap) != false, "Empty check fail");
176+
zassert_true(min_heap_is_empty(&my_heap), "Empty check fail");
177177
}
178178

179179
ZTEST_SUITE(min_heap_api, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)