diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2022-11-25 09:34:38 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2022-11-28 13:25:03 +0100 |
commit | e8c111dd73f795a0305d457850b3ec719e4c3786 (patch) | |
tree | 34ec0a1c8bf82ed5c3111e4aee4decc5e6326f58 | |
parent | 15dcc205a721842ba90a48face261100c18ae6a9 (diff) | |
download | cmocka-e8c111dd73f795a0305d457850b3ec719e4c3786.zip cmocka-e8c111dd73f795a0305d457850b3ec719e4c3786.tar.gz cmocka-e8c111dd73f795a0305d457850b3ec719e4c3786.tar.bz2 |
tests: Add tests for assert_uint_not_in_set()
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/test_assert_set.c | 11 | ||||
-rw-r--r-- | tests/test_assert_set_fail.c | 20 |
3 files changed, 32 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1d1649e..4242445 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -97,7 +97,7 @@ set_tests_properties( test_assert_set_fail PROPERTIES PASS_REGULAR_EXPRESSION - "\\[ FAILED \\] set_fail_tests: 3 test" + "\\[ FAILED \\] set_fail_tests: 5 test" ) # test_expect_check_fail diff --git a/tests/test_assert_set.c b/tests/test_assert_set.c index 43d28f4..6174800 100644 --- a/tests/test_assert_set.c +++ b/tests/test_assert_set.c @@ -92,6 +92,16 @@ static void test_assert_uint_in_set_64(void **state) assert_int_in_set(UINT64_MAX, set, ARRAY_SIZE(set)); } +static void test_assert_uint_not_in_set_64(void **state) +{ + uint64_t set[] = {0, 1, 2, 3, UINT64_MAX - 1}; + + (void)state; /* unused */ + + assert_uint_not_in_set(UINT64_MAX, set, ARRAY_SIZE(set)); + assert_uint_not_in_set(4, set, ARRAY_SIZE(set)); +} + int main(void) { const struct CMUnitTest set_tests[] = { cmocka_unit_test(test_assert_int_in_set_8), @@ -102,6 +112,7 @@ int main(void) { cmocka_unit_test(test_assert_int_not_in_set_64), cmocka_unit_test(test_assert_uint_in_set_32), cmocka_unit_test(test_assert_uint_in_set_64), + cmocka_unit_test(test_assert_uint_not_in_set_64), }; return cmocka_run_group_tests(set_tests, NULL, NULL); diff --git a/tests/test_assert_set_fail.c b/tests/test_assert_set_fail.c index 1f8a03a..8368d30 100644 --- a/tests/test_assert_set_fail.c +++ b/tests/test_assert_set_fail.c @@ -34,11 +34,31 @@ static void test_assert_uint_in_set_fail(void **state) assert_int_in_set(0, set, ARRAY_SIZE(set)); } +static void test_assert_uint_not_in_set_fail_1(void **state) +{ + uint32_t set[] = {1, 2, 3, UINT32_MAX}; + + (void)state; /* unused */ + + assert_uint_not_in_set(3, set, ARRAY_SIZE(set)); +} + +static void test_assert_uint_not_in_set_fail_2(void **state) +{ + uint64_t set[] = {1, 2, 3, UINT64_MAX}; + + (void)state; /* unused */ + + assert_uint_not_in_set(UINT64_MAX, set, ARRAY_SIZE(set)); +} + int main(void) { const struct CMUnitTest set_fail_tests[] = { cmocka_unit_test(test_assert_int_in_set_fail), cmocka_unit_test(test_assert_int_not_in_set_fail), cmocka_unit_test(test_assert_uint_in_set_fail), + cmocka_unit_test(test_assert_uint_not_in_set_fail_1), + cmocka_unit_test(test_assert_uint_not_in_set_fail_2), }; return cmocka_run_group_tests(set_fail_tests, NULL, NULL); |