From: Kevin Day Date: Sun, 5 Jun 2022 22:42:57 +0000 (-0500) Subject: Update: Add unit tests for f_status. X-Git-Tag: 0.5.10~69 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=fc9c07b43c752c070a3af6c6f2c59e07a7cf729b;p=fll Update: Add unit tests for f_status. The f_status only has macros and I generally do not test macros. These are special macros used everywhere so I decided to add macro unit tests. --- diff --git a/build/scripts/test.sh b/build/scripts/test.sh index f4f3a38..27a22fd 100644 --- a/build/scripts/test.sh +++ b/build/scripts/test.sh @@ -52,8 +52,8 @@ test_main() { local verbose= local verbose_common= - local projects="f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_status_string f_serialize f_signal f_socket f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_path fll_print fll_program fll_status_string" - local projects_no_tests="f_type f_status" + local projects="f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_status_string f_thread fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_signal fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_fss_status_string fll_iki fll_path fll_print fll_program fll_status_string" + local projects_no_tests="f_type" let failure=0 diff --git a/level_0/f_status/data/build/dependencies-tests b/level_0/f_status/data/build/dependencies-tests new file mode 100644 index 0000000..dea3179 --- /dev/null +++ b/level_0/f_status/data/build/dependencies-tests @@ -0,0 +1,3 @@ +# fss-0001 + +cmocka 1.* diff --git a/level_0/f_status/data/build/settings-tests b/level_0/f_status/data/build/settings-tests new file mode 100644 index 0000000..a7dc096 --- /dev/null +++ b/level_0/f_status/data/build/settings-tests @@ -0,0 +1,53 @@ +# fss-0001 +# +# Builds a program that is links to the generated library and is executed to perform tests. +# +# Memory leaks in the test program can be checked for by running valgrind with this executable. +# + +build_name test-f_status + +version_major 0 +version_file major +version_target major + +modes individual clang test coverage +modes_default individual test + +build_compiler gcc +build_compiler-clang clang +build_indexer ar +build_indexer_arguments rcs +build_language c + +build_libraries -lc -lcmocka + +build_sources_program test-status-macro-is_error.c test-status-macro-is_fine.c test-status-macro-is_problem.c test-status-macro-is_signal.c test-status-macro-is_warning.c +build_sources_program test-status-macro-is_error_not.c test-status-macro-is_fine_not.c test-status-macro-is_problem_not.c test-status-macro-is_signal_not.c test-status-macro-is_warning_not.c +build_sources_program test-status-macro-set_error.c test-status-macro-set_fine.c test-status-macro-set_signal.c test-status-macro-set_warning.c +build_sources_program test-status.c + +build_script no +build_shared yes +build_static no + +path_headers tests/unit/c +path_sources tests/unit/c + +has_path_standard no +preserve_path_headers yes + +search_exclusive yes +search_shared yes +search_static yes + +defines -Ibuild/includes +defines_static -Lbuild/libraries/static +defines_shared -Lbuild/libraries/shared + +flags -O2 -z now -g -fdiagnostics-color=always -Wno-logical-not-parentheses -Wno-parentheses +flags-clang -Wno-logical-op-parentheses +flags-test -fstack-protector -Wall +flags-coverage -O0 --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ + +flags_program -fPIE diff --git a/level_0/f_status/data/build/testfile b/level_0/f_status/data/build/testfile new file mode 100644 index 0000000..9249e87 --- /dev/null +++ b/level_0/f_status/data/build/testfile @@ -0,0 +1,55 @@ +# fss-0005 iki-0002 + +settings: + load_build yes + fail exit + + environment LD_LIBRARY_PATH + environment CMOCKA_XML_FILE CMOCKA_MESSAGE_OUTPUT CMOCKA_TEST_ABORT + + # Cmcka is not fully thread-safe, set this to "1" to have cmocka call abort() on a test failure. + #CMOCKA_TEST_ABORT 1 + + # One of: STDOUT, SUBUNIT, TAP, or XML. + #define CMOCKA_MESSAGE_OUTPUT STDOUT + + # When in "XML" output mode, output to this file rather than stdout. + #define CMOCKA_XML_FILE ./out.xml + +main: + build settings individual test + build settings-tests individual test + + operate ld_library_path + + if exists build/programs/shared/test-f_status + shell build/programs/shared/test-f_status + + if exists build/programs/static/test-f_status + shell build/programs/static/test-f_status + + if not exists build/programs/shared/test-f_status + and not exists build/programs/static/test-f_status + operate not_created + +not_created: + print + print 'context:"error"Failed to test due to being unable to find either a shared or static test binary to perform tests. context:"reset"' + + exit failure + +ld_library_path: + if defined environment LD_LIBRARY_PATH + and defined parameter work + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared:define:"LD_LIBRARY_PATH"' + + else + if defined environment LD_LIBRARY_PATH + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:define:"LD_LIBRARY_PATH"' + + else + if defined parameter work + define LD_LIBRARY_PATH 'build/libraries/shared:parameter:"work:value"libraries/shared' + + else + define LD_LIBRARY_PATH build/libraries/shared diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_error.c b/level_0/f_status/tests/unit/c/test-status-macro-is_error.c new file mode 100644 index 0000000..cad6422 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_error.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_error__works(void **state) { + + assert_false(F_status_is_error(0)); + assert_false(F_status_is_error(F_none)); + assert_true(F_status_is_error(F_status_bit_error)); + assert_true(F_status_is_error(F_status_bit_signal)); // The signal bit uses the error bit. + assert_false(F_status_is_error(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_error.h b/level_0/f_status/tests/unit/c/test-status-macro-is_error.h new file mode 100644 index 0000000..d247ccc --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_error.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_error +#define _TEST__F_status__macro__is_error + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_error() + */ +extern void test__F_status_is_error__works(void **state); + +#endif // _TEST__F_status__macro__is_error diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_error_not.c b/level_0/f_status/tests/unit/c/test-status-macro-is_error_not.c new file mode 100644 index 0000000..f638f12 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_error_not.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_error_not.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_error_not__works(void **state) { + + assert_true(F_status_is_error_not(0)); + assert_true(F_status_is_error_not(F_none)); + assert_false(F_status_is_error_not(F_status_bit_error)); + assert_false(F_status_is_error_not(F_status_bit_signal)); // The signal bit uses the error bit. + assert_true(F_status_is_error_not(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_error_not.h b/level_0/f_status/tests/unit/c/test-status-macro-is_error_not.h new file mode 100644 index 0000000..46a4aba --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_error_not.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_error_not +#define _TEST__F_status__macro__is_error_not + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_error_not() + */ +extern void test__F_status_is_error_not__works(void **state); + +#endif // _TEST__F_status__macro__is_error_not diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_fine.c b/level_0/f_status/tests/unit/c/test-status-macro-is_fine.c new file mode 100644 index 0000000..8bd2141 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_fine.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_fine.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_fine__works(void **state) { + + assert_true(F_status_is_fine(0)); + assert_true(F_status_is_fine(F_none)); + assert_false(F_status_is_fine(F_status_bit_error)); + assert_false(F_status_is_fine(F_status_bit_signal)); + assert_false(F_status_is_fine(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_fine.h b/level_0/f_status/tests/unit/c/test-status-macro-is_fine.h new file mode 100644 index 0000000..7992b9a --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_fine.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_fine +#define _TEST__F_status__macro__is_fine + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_fine() + */ +extern void test__F_status_is_fine__works(void **state); + +#endif // _TEST__F_status__macro__is_fine diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_fine_not.c b/level_0/f_status/tests/unit/c/test-status-macro-is_fine_not.c new file mode 100644 index 0000000..0469073 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_fine_not.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_fine_not.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_fine_not__works(void **state) { + + assert_false(F_status_is_fine_not(0)); + assert_false(F_status_is_fine_not(F_none)); + assert_true(F_status_is_fine_not(F_status_bit_error)); + assert_true(F_status_is_fine_not(F_status_bit_signal)); + assert_true(F_status_is_fine_not(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_fine_not.h b/level_0/f_status/tests/unit/c/test-status-macro-is_fine_not.h new file mode 100644 index 0000000..afa200b --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_fine_not.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_fine_not +#define _TEST__F_status__macro__is_fine_not + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_fine_not() + */ +extern void test__F_status_is_fine_not__works(void **state); + +#endif // _TEST__F_status__macro__is_fine_not diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_problem.c b/level_0/f_status/tests/unit/c/test-status-macro-is_problem.c new file mode 100644 index 0000000..e95ad58 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_problem.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_problem.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_problem__works(void **state) { + + assert_false(F_status_is_problem(0)); + assert_false(F_status_is_problem(F_none)); + assert_true(F_status_is_problem(F_status_bit_error)); + assert_true(F_status_is_problem(F_status_bit_signal)); + assert_true(F_status_is_problem(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_problem.h b/level_0/f_status/tests/unit/c/test-status-macro-is_problem.h new file mode 100644 index 0000000..9981368 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_problem.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_problem +#define _TEST__F_status__macro__is_problem + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_problem() + */ +extern void test__F_status_is_problem__works(void **state); + +#endif // _TEST__F_status__macro__is_problem diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_problem_not.c b/level_0/f_status/tests/unit/c/test-status-macro-is_problem_not.c new file mode 100644 index 0000000..73bb487 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_problem_not.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_problem_not.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_problem_not__works(void **state) { + + assert_true(F_status_is_problem_not(0)); + assert_true(F_status_is_problem_not(F_none)); + assert_false(F_status_is_problem_not(F_status_bit_error)); + assert_false(F_status_is_problem_not(F_status_bit_signal)); + assert_false(F_status_is_problem_not(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_problem_not.h b/level_0/f_status/tests/unit/c/test-status-macro-is_problem_not.h new file mode 100644 index 0000000..c18be28 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_problem_not.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_problem_not +#define _TEST__F_status__macro__is_problem_not + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_problem_not() + */ +extern void test__F_status_is_problem_not__works(void **state); + +#endif // _TEST__F_status__macro__is_problem_not diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_signal.c b/level_0/f_status/tests/unit/c/test-status-macro-is_signal.c new file mode 100644 index 0000000..57ee47d --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_signal.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_signal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_signal__works(void **state) { + + assert_false(F_status_is_signal(0)); + assert_false(F_status_is_signal(F_none)); + assert_false(F_status_is_signal(F_status_bit_error)); + assert_true(F_status_is_signal(F_status_bit_signal)); + assert_false(F_status_is_signal(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_signal.h b/level_0/f_status/tests/unit/c/test-status-macro-is_signal.h new file mode 100644 index 0000000..27740f2 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_signal.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_signal +#define _TEST__F_status__macro__is_signal + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_signal() + */ +extern void test__F_status_is_signal__works(void **state); + +#endif // _TEST__F_status__macro__is_signal diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_signal_not.c b/level_0/f_status/tests/unit/c/test-status-macro-is_signal_not.c new file mode 100644 index 0000000..4d5a1d9 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_signal_not.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_signal_not.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_signal_not__works(void **state) { + + assert_true(F_status_is_signal_not(0)); + assert_true(F_status_is_signal_not(F_none)); + assert_true(F_status_is_signal_not(F_status_bit_error)); + assert_false(F_status_is_signal_not(F_status_bit_signal)); + assert_true(F_status_is_signal_not(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_signal_not.h b/level_0/f_status/tests/unit/c/test-status-macro-is_signal_not.h new file mode 100644 index 0000000..9c43017 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_signal_not.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_signal_not +#define _TEST__F_status__macro__is_signal_not + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_signal_not() + */ +extern void test__F_status_is_signal_not__works(void **state); + +#endif // _TEST__F_status__macro__is_signal_not diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_warning.c b/level_0/f_status/tests/unit/c/test-status-macro-is_warning.c new file mode 100644 index 0000000..81e0949 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_warning.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_warning.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_warning__works(void **state) { + + assert_false(F_status_is_warning(0)); + assert_false(F_status_is_warning(F_none)); + assert_false(F_status_is_warning(F_status_bit_error)); + assert_true(F_status_is_warning(F_status_bit_signal)); // The signal bit uses the warning bit. + assert_true(F_status_is_warning(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_warning.h b/level_0/f_status/tests/unit/c/test-status-macro-is_warning.h new file mode 100644 index 0000000..d548e60 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_warning.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_warning +#define _TEST__F_status__macro__is_warning + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_warning() + */ +extern void test__F_status_is_warning__works(void **state); + +#endif // _TEST__F_status__macro__is_warning diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_warning_not.c b/level_0/f_status/tests/unit/c/test-status-macro-is_warning_not.c new file mode 100644 index 0000000..0668b93 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_warning_not.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-is_warning_not.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_is_warning_not__works(void **state) { + + assert_true(F_status_is_warning_not(0)); + assert_true(F_status_is_warning_not(F_none)); + assert_true(F_status_is_warning_not(F_status_bit_error)); + assert_false(F_status_is_warning_not(F_status_bit_signal)); + assert_false(F_status_is_warning_not(F_status_bit_warning)); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-is_warning_not.h b/level_0/f_status/tests/unit/c/test-status-macro-is_warning_not.h new file mode 100644 index 0000000..90c9d5c --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-is_warning_not.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__is_warning_not +#define _TEST__F_status__macro__is_warning_not + +/** + * Test that parameter checking works as expected. + * + * @see F_status_is_warning_not() + */ +extern void test__F_status_is_warning_not__works(void **state); + +#endif // _TEST__F_status__macro__is_warning_not diff --git a/level_0/f_status/tests/unit/c/test-status-macro-set_error.c b/level_0/f_status/tests/unit/c/test-status-macro-set_error.c new file mode 100644 index 0000000..f7dba25 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-set_error.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-set_error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_set_error__works(void **state) { + + assert_true(F_status_is_error(F_status_set_error(0))); + assert_true(F_status_is_error(F_status_set_error(F_none))); + assert_true(F_status_is_error(F_status_set_error(F_status_bit_error))); + assert_true(F_status_is_error(F_status_set_error(F_status_bit_signal))); + assert_true(F_status_is_error(F_status_set_error(F_status_bit_warning))); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-set_error.h b/level_0/f_status/tests/unit/c/test-status-macro-set_error.h new file mode 100644 index 0000000..aa11ec8 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-set_error.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__set_error +#define _TEST__F_status__macro__set_error + +/** + * Test that parameter checking works as expected. + * + * @see F_status_set_error() + */ +extern void test__F_status_set_error__works(void **state); + +#endif // _TEST__F_status__macro__set_error diff --git a/level_0/f_status/tests/unit/c/test-status-macro-set_fine.c b/level_0/f_status/tests/unit/c/test-status-macro-set_fine.c new file mode 100644 index 0000000..b6be659 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-set_fine.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-set_fine.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_set_fine__works(void **state) { + + assert_true(F_status_is_fine(F_status_set_fine(0))); + assert_true(F_status_is_fine(F_status_set_fine(F_none))); + assert_true(F_status_is_fine(F_status_set_fine(F_status_bit_error))); + assert_true(F_status_is_fine(F_status_set_fine(F_status_bit_signal))); + assert_true(F_status_is_fine(F_status_set_fine(F_status_bit_warning))); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-set_fine.h b/level_0/f_status/tests/unit/c/test-status-macro-set_fine.h new file mode 100644 index 0000000..3e33f78 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-set_fine.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__set_fine +#define _TEST__F_status__macro__set_fine + +/** + * Test that parameter checking works as expected. + * + * @see F_status_set_fine() + */ +extern void test__F_status_set_fine__works(void **state); + +#endif // _TEST__F_status__macro__set_fine diff --git a/level_0/f_status/tests/unit/c/test-status-macro-set_signal.c b/level_0/f_status/tests/unit/c/test-status-macro-set_signal.c new file mode 100644 index 0000000..7b0037f --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-set_signal.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-set_signal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_set_signal__works(void **state) { + + assert_true(F_status_is_signal(F_status_set_signal(0))); + assert_true(F_status_is_signal(F_status_set_signal(F_none))); + assert_true(F_status_is_signal(F_status_set_signal(F_status_bit_error))); + assert_true(F_status_is_signal(F_status_set_signal(F_status_bit_signal))); + assert_true(F_status_is_signal(F_status_set_signal(F_status_bit_warning))); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-set_signal.h b/level_0/f_status/tests/unit/c/test-status-macro-set_signal.h new file mode 100644 index 0000000..2db4512 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-set_signal.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__set_signal +#define _TEST__F_status__macro__set_signal + +/** + * Test that parameter checking works as expected. + * + * @see F_status_set_signal() + */ +extern void test__F_status_set_signal__works(void **state); + +#endif // _TEST__F_status__macro__set_signal diff --git a/level_0/f_status/tests/unit/c/test-status-macro-set_warning.c b/level_0/f_status/tests/unit/c/test-status-macro-set_warning.c new file mode 100644 index 0000000..99ff0a7 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-set_warning.c @@ -0,0 +1,19 @@ +#include "test-status.h" +#include "test-status-macro-set_warning.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__F_status_set_warning__works(void **state) { + + assert_true(F_status_is_warning(F_status_set_warning(0))); + assert_true(F_status_is_warning(F_status_set_warning(F_none))); + assert_true(F_status_is_warning(F_status_set_warning(F_status_bit_error))); + assert_true(F_status_is_warning(F_status_set_warning(F_status_bit_signal))); + assert_true(F_status_is_warning(F_status_set_warning(F_status_bit_warning))); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status-macro-set_warning.h b/level_0/f_status/tests/unit/c/test-status-macro-set_warning.h new file mode 100644 index 0000000..71ff0fe --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status-macro-set_warning.h @@ -0,0 +1,20 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status__macro__set_warning +#define _TEST__F_status__macro__set_warning + +/** + * Test that parameter checking works as expected. + * + * @see F_status_set_warning() + */ +extern void test__F_status_set_warning__works(void **state); + +#endif // _TEST__F_status__macro__set_warning diff --git a/level_0/f_status/tests/unit/c/test-status.c b/level_0/f_status/tests/unit/c/test-status.c new file mode 100644 index 0000000..0547e82 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status.c @@ -0,0 +1,43 @@ +#include "test-status.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int setup(void **state) { + + return 0; +} + +int setdown(void **state) { + + return 0; +} + +int main(void) { + + const struct CMUnitTest tests[] = { + cmocka_unit_test(test__F_status_is_error__works), + cmocka_unit_test(test__F_status_is_fine__works), + cmocka_unit_test(test__F_status_is_problem__works), + cmocka_unit_test(test__F_status_is_signal__works), + cmocka_unit_test(test__F_status_is_warning__works), + + cmocka_unit_test(test__F_status_is_error_not__works), + cmocka_unit_test(test__F_status_is_fine_not__works), + cmocka_unit_test(test__F_status_is_problem_not__works), + cmocka_unit_test(test__F_status_is_signal_not__works), + cmocka_unit_test(test__F_status_is_warning_not__works), + + cmocka_unit_test(test__F_status_set_error__works), + cmocka_unit_test(test__F_status_set_fine__works), + cmocka_unit_test(test__F_status_set_signal__works), + cmocka_unit_test(test__F_status_set_warning__works), + }; + + return cmocka_run_group_tests(tests, setup, setdown); +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_status/tests/unit/c/test-status.h b/level_0/f_status/tests/unit/c/test-status.h new file mode 100644 index 0000000..e36b2c9 --- /dev/null +++ b/level_0/f_status/tests/unit/c/test-status.h @@ -0,0 +1,82 @@ +/** + * FLL - Level 0 + * + * Project: Status + * API Version: 0.5 + * Licenses: lgpl-2.1-or-later + * + * Test the status project. + */ +#ifndef _TEST__F_status_h +#define _TEST__F_status_h + +// Libc includes. +#include +#include +#include +#include + +// cmocka includes. +#include + +// FLL-0 includes. +#include + +// Test includes. +#include "test-status-macro-is_error.h" +#include "test-status-macro-is_error_not.h" +#include "test-status-macro-is_fine.h" +#include "test-status-macro-is_fine_not.h" +#include "test-status-macro-is_problem.h" +#include "test-status-macro-is_problem_not.h" +#include "test-status-macro-is_signal.h" +#include "test-status-macro-is_signal_not.h" +#include "test-status-macro-is_warning.h" +#include "test-status-macro-is_warning_not.h" +#include "test-status-macro-set_error.h" +#include "test-status-macro-set_fine.h" +#include "test-status-macro-set_signal.h" +#include "test-status-macro-set_warning.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Perform any setup operations. + * + * @param state + * The test state. + * + * @return + * The status of this function, where 0 means success. + */ +extern int setup(void **state); + +/** + * Peform any setdown operations. + * + * @param state + * The test state. + * + * @return + * The status of this function, where 0 means success. + */ +extern int setdown(void **state); + +/** + * Run all tests. + * + * @return + * The final result of the tests. + * + * @see cmocka_run_group_tests() + * @see cmocka_unit_test() + */ +extern int main(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _TEST__F_status_h