test: cmocka: Use ARRAY_SIZE

Instead of computing array size, use the ARRAY_SIZE
macro defined in <sof/common.h>.

Signed-off-by: Sam Muhammed <jane.pnx9@gmail.com>
This commit is contained in:
Sam Muhammed 2020-03-30 13:44:44 -04:00 committed by Liam Girdwood
parent aa6c0f2ad1
commit 288b8f3ade
2 changed files with 6 additions and 4 deletions

View File

@ -5,6 +5,7 @@
// Author: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
#include <sof/math/numbers.h>
#include <sof/common.h>
#include <stdarg.h>
#include <stddef.h>
@ -18,7 +19,7 @@ static void test_math_numbers_find_max_abs_int32_for_neg100_99_98_50_equals_100
(void)state;
int32_t vec[] = {-100, 99, 98, 50};
int r = find_max_abs_int32(vec, sizeof(vec) / sizeof(int32_t));
int r = find_max_abs_int32(vec, ARRAY_SIZE(vec));
assert_int_equal(r, 100);
}
@ -29,7 +30,7 @@ static void test_math_numbers_find_max_abs_int32_for_neg100_99_98_50_101_equals_
(void)state;
int32_t vec[] = {-100, 99, 98, 50, 101};
int r = find_max_abs_int32(vec, sizeof(vec) / sizeof(int32_t));
int r = find_max_abs_int32(vec, ARRAY_SIZE(vec));
assert_int_equal(r, 101);
}

View File

@ -5,6 +5,7 @@
// Author: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
#include <sof/math/numbers.h>
#include <sof/common.h>
#include <stdarg.h>
#include <stddef.h>
@ -17,7 +18,7 @@ static void test_math_numbers_find_min_int16_for_2_equals_2(void **state)
(void)state;
int16_t vec[] = {2};
int r = find_min_int16(vec, sizeof(vec) / sizeof(int16_t));
int r = find_min_int16(vec, ARRAY_SIZE(vec));
assert_int_equal(r, 2);
}
@ -28,7 +29,7 @@ static void test_math_numbers_find_min_int16_for_5_2_3_4_1_equals_1
(void)state;
int16_t vec[] = {5, 2, 3, 4, 1};
int r = find_min_int16(vec, sizeof(vec) / sizeof(int16_t));
int r = find_min_int16(vec, ARRAY_SIZE(vec));
assert_int_equal(r, 1);
}