1 // SPDX-License-Identifier: BSD-3-Clause
2 //
3 // Copyright(c) 2018 Intel Corporation. All rights reserved.
4 //
5 // Author: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
6 
7 #include <sof/math/numbers.h>
8 #include <sof/common.h>
9 
10 #include <stdarg.h>
11 #include <stddef.h>
12 #include <setjmp.h>
13 #include <stdint.h>
14 #include <cmocka.h>
15 
test_math_numbers_find_min_int16_for_2_equals_2(void ** state)16 static void test_math_numbers_find_min_int16_for_2_equals_2(void **state)
17 {
18 	(void)state;
19 
20 	int16_t vec[] = {2};
21 	int r = find_min_int16(vec, ARRAY_SIZE(vec));
22 
23 	assert_int_equal(r, 2);
24 }
25 
test_math_numbers_find_min_int16_for_5_2_3_4_1_equals_1(void ** state)26 static void test_math_numbers_find_min_int16_for_5_2_3_4_1_equals_1
27 	(void **state)
28 {
29 	(void)state;
30 
31 	int16_t vec[] = {5, 2, 3, 4, 1};
32 	int r = find_min_int16(vec, ARRAY_SIZE(vec));
33 
34 	assert_int_equal(r, 1);
35 }
36 
main(void)37 int main(void)
38 {
39 	const struct CMUnitTest tests[] = {
40 		cmocka_unit_test
41 			(test_math_numbers_find_min_int16_for_2_equals_2),
42 		cmocka_unit_test
43 			(test_math_numbers_find_min_int16_for_5_2_3_4_1_equals_1)
44 	};
45 
46 	cmocka_set_message_output(CM_OUTPUT_TAP);
47 
48 	return cmocka_run_group_tests(tests, NULL, NULL);
49 }
50