3 static const char buf[3];
5 static void test_min(void **state) {
8 assert_int_equal(-1, MIN(1, -1));
9 assert_int_equal(-2, MIN(1 + 2 * 3, 3 - 2 * 5 / 2));
11 assert_ptr_equal(buf[0], MIN(buf[1], buf[0]));
14 static void test_max(void **state) {
17 assert_int_equal(1, MAX(1, -1));
18 assert_int_equal(4, MAX(1 + 3 - 3 / 4 * 5, 10 / 5 + 2 - 2));
20 assert_ptr_equal(buf[1], MAX(buf[1], buf[0]));
23 static void test_clamp(void **state) {
26 assert_int_equal(10, CLAMP(INT_MAX, -10, 10));
27 assert_int_equal(-10, CLAMP(INT_MIN, -10, 10));
28 assert_int_equal(7, CLAMP(3 + 4, 6, 8));
30 assert_int_equal(5, CLAMP(-1000, 5, 5));
31 assert_int_equal(5, CLAMP(0, 5, 5));
32 assert_int_equal(5, CLAMP(1000, 5, 5));
34 assert_ptr_equal(buf[1], CLAMP(buf[2], buf[0], buf[1]));
38 const struct CMUnitTest tests[] = {
39 cmocka_unit_test(test_min),
40 cmocka_unit_test(test_max),
41 cmocka_unit_test(test_clamp),
43 return cmocka_run_group_tests(tests, NULL, NULL);