From: Kevin Day Date: Tue, 3 Jan 2023 20:47:46 +0000 (-0600) Subject: Bugfix: The f_signal unit tests after significant change. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=78a85a7d8de3138e1bddebfc5093307faf5990fc;p=fll Bugfix: The f_signal unit tests after significant change. The bugfix from commit 3a5a4e73f16b0285e9cfb436481835e192896ef8 didn't include checking and updating the unit tests. --- diff --git a/level_0/f_signal/tests/unit/c/test-signal-close.c b/level_0/f_signal/tests/unit/c/test-signal-close.c index 910b457..4ce6745 100644 --- a/level_0/f_signal/tests/unit/c/test-signal-close.c +++ b/level_0/f_signal/tests/unit/c/test-signal-close.c @@ -27,6 +27,8 @@ void test__f_signal_close__fails(void **state) { F_failure, }; + signal.id = 0; + for (int i = 0; i < 6; ++i) { will_return(__wrap_close, true); @@ -47,12 +49,25 @@ void test__f_signal_close__parameter_checking(void **state) { } } +void test__f_signal_close__returns_data_not(void **state) { + + f_signal_t signal = f_signal_t_initialize; + + { + const f_status_t status = f_signal_close(&signal); + + assert_int_equal(status, F_data_not); + } +} + void test__f_signal_close__works(void **state) { f_signal_t signal = f_signal_t_initialize; + signal.id = 0; + { - will_return(__wrap_close, false); + will_return(__wrap_close, 0); const f_status_t status = f_signal_close(&signal); diff --git a/level_0/f_signal/tests/unit/c/test-signal-close.h b/level_0/f_signal/tests/unit/c/test-signal-close.h index 4dd8769..e1aa39b 100644 --- a/level_0/f_signal/tests/unit/c/test-signal-close.h +++ b/level_0/f_signal/tests/unit/c/test-signal-close.h @@ -25,6 +25,13 @@ extern void test__f_signal_close__fails(void **state); extern void test__f_signal_close__parameter_checking(void **state); /** + * Test that function works but returns F_data_not when file descriptor is -1. + * + * @see f_signal_close() + */ +extern void test__f_signal_close__returns_data_not(void **state); + +/** * Test that function works. * * @see f_signal_close() diff --git a/level_0/f_signal/tests/unit/c/test-signal.c b/level_0/f_signal/tests/unit/c/test-signal.c index 6e61a62..dd7dc8d 100644 --- a/level_0/f_signal/tests/unit/c/test-signal.c +++ b/level_0/f_signal/tests/unit/c/test-signal.c @@ -23,6 +23,7 @@ int main(void) { cmocka_unit_test(test__f_signal_action__works), cmocka_unit_test(test__f_signal_close__fails), + cmocka_unit_test(test__f_signal_close__returns_data_not), cmocka_unit_test(test__f_signal_close__works), cmocka_unit_test(test__f_signal_mask__fails),