[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/5] cmocka: examples: Fix assert macros usage


Replace macros with moresuitable for given context.

Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
---
 example/calculator_test.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/example/calculator_test.c b/example/calculator_test.c
index a1c9334..e148aa2 100644
--- a/example/calculator_test.c
+++ b/example/calculator_test.c
@@ -159,7 +159,7 @@ static void test_find_operator_function_by_string_null_string(void **state) {
 static void test_find_operator_function_by_string_valid_null_functions(void **state) {
         (void) state; /* unused */
 
-  assert_int_equal(find_operator_function_by_string(0, NULL, "test"), NULL);
+	assert_null(find_operator_function_by_string(0, NULL, "test"));
 }
 
 /* Ensure find_operator_function_by_string() returns NULL when searching for
@@ -173,9 +173,8 @@ static void test_find_operator_function_by_string_not_found(void **state) {
 
         (void) state; /* unused */
 
-	assert_int_equal(find_operator_function_by_string(
-	        array_length(operator_functions), operator_functions, "test"),
-	        NULL);
+	assert_null(find_operator_function_by_string(
+	        array_length(operator_functions), operator_functions, "test"));
 }
 
 /* Ensure find_operator_function_by_string() returns the correct function when
@@ -189,7 +188,7 @@ static void test_find_operator_function_by_string_found(void **state) {
 
         (void) state; /* unused */
 
-	assert_int_equal(find_operator_function_by_string(
+	assert_int_equal((uintptr_t)find_operator_function_by_string(
 	        array_length(operator_functions), operator_functions, "-"),
 	    0xDEADBEEF);
 }
@@ -414,7 +413,7 @@ static void test_perform_operation(void **state) {
 	    &intermediate_values, &error_occurred), 40);
 	assert_int_equal(error_occurred, 0);
 
-	assert_true(intermediate_values);
+	assert_non_null(intermediate_values);
 	assert_int_equal(intermediate_values[0], 4);
 	assert_int_equal(intermediate_values[1], 40);
 	test_free(intermediate_values);
-- 
1.7.9.5



References:
[PATCH 0/5] cmocka: Make casting macros publicKrzysztof Opasiak <k.opasiak@xxxxxxxxxxx>