]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
run test all at once
authorBastian Dehn <hhaalo@arcor.de>
Tue, 5 May 2026 13:30:43 +0000 (15:30 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 5 May 2026 13:31:24 +0000 (15:31 +0200)
tests/CMakeLists.txt
tests/break_tests.c
tests/tests.c [new file with mode: 0644]
tests/time_format_tests.c
tests/validate_tests.c
tests/worktime_tests.c

index 0beffe863d05462ee0ac32a37028785c7fa63290..d48068aefcfe0e9223d26894c87d1785283fc588 100644 (file)
@@ -13,40 +13,22 @@ message(STATUS "CPPCHECK_VERSION: ${CPPCHECK_VERSION}")
 
 include_directories(${CMAKE_BINARY_DIR}/src)
 
-add_executable(break_tests
+add_executable(tests
+       tests.c
        break_tests.c
-       ../src/break.c)
-target_link_libraries(break_tests
-       ${CMOCKA})
-
-add_executable(worktime_tests
        worktime_tests.c
-       ../src/worktime.c
-       ../src/break.c)
-target_link_libraries(worktime_tests
-       ${CMOCKA})
-
-add_executable(time_format_tests
        time_format_tests.c
-       ../src/time_format.c)
-target_link_libraries(time_format_tests
-       ${CMOCKA})
-
-add_executable(validate_tests
        validate_tests.c
-       ../src/validate.c)
-target_link_libraries(validate_tests
+       ../src/validate.c
+       ../src/time_format.c
+       ../src/worktime.c
+       ../src/break.c)
+target_link_libraries(tests
        ${CMOCKA})
 
 add_custom_target(run_tests
-       ALL ./break_tests
-       COMMAND ./worktime_tests
-       COMMAND ./time_format_tests
-       COMMAND ./validate_tests
-       DEPENDS break_tests
-       worktime_tests
-       time_format_tests
-       validate_tests)
+       ALL ./tests
+       DEPENDS tests)
 
 if(CPPCHECK_VERSION VERSION_GREATER 2.10)
        add_custom_command(TARGET run_tests
index 1d6efb09ea214103bb0283529e4a728b1d776696..4a793da75c763ebd5f59b6a4a7d1b6834a3a9453 100644 (file)
@@ -141,9 +141,9 @@ void six_hours_and_fouty_six_minute_hours_minutes_fourty_five_minute_break_test(
        assert_int_equal(breaktime, 2700);
 }
 
-int main()
+int run_break_tests()
 {
-       const struct CMUnitTest tests[] = {
+       const struct CMUnitTest break_tests[] = {
                cmocka_unit_test(two_hours_zero_break_test),
                cmocka_unit_test(two_hours_and_one_minutes_one_minute_break_test),
                cmocka_unit_test(two_hours_and_two_minutes_two_minute_break_test),
@@ -161,5 +161,5 @@ int main()
                cmocka_unit_test(six_hours_and_fouty_six_minute_hours_minutes_fourty_five_minute_break_test),
        };
 
-       return cmocka_run_group_tests(tests, NULL, NULL);
+       return cmocka_run_group_tests(break_tests, NULL, NULL);
 }
\ No newline at end of file
diff --git a/tests/tests.c b/tests/tests.c
new file mode 100644 (file)
index 0000000..8f6442d
--- /dev/null
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+typedef int (*testgroupsfn)();
+
+int run_break_tests();
+int run_worktime_tests();
+int run_time_format_tests();
+int run_validate_tests();
+
+int main()
+{
+    testgroupsfn testgroups[] = {
+        run_break_tests,
+        run_worktime_tests,
+        run_time_format_tests,
+        run_validate_tests
+    };
+
+    size_t count = sizeof(testgroups) / sizeof(testgroupsfn);
+    for (size_t i = 0; i < count; i++) {
+        if (testgroups[i]())
+            return 1;
+    }
+
+    return 0;
+}
\ No newline at end of file
index ccbe3ba8034ee0dbad04809c05b95ba9cbde33c8..a0e65a7386ce219348a796bff7863c6ae33ef617 100644 (file)
@@ -249,9 +249,9 @@ void get_time_str_from_twenty_three_fity_nine_test(void** timestr)
        assert_string_equal(*timestr, "23:59");
 }
 
-int main()
+int run_time_format_tests()
 {
-       const struct CMUnitTest tests[] = {
+       const struct CMUnitTest time_format_tests[] = {
                cmocka_unit_test_teardown(get_zero_hour_and_fifteen_minutes_test, teardown),
                cmocka_unit_test_teardown(get_five_hour_fourty_five_test, teardown),
                cmocka_unit_test_teardown(get_minus_five_minutes_test, teardown),
@@ -284,5 +284,5 @@ int main()
                cmocka_unit_test_teardown(get_time_str_from_twenty_three_fity_nine_test, teardown)
        };
 
-       return cmocka_run_group_tests(tests, NULL, NULL);
+       return cmocka_run_group_tests(time_format_tests, NULL, NULL);
 }
\ No newline at end of file
index edecde4e1ddce7029422d143ea31aceb46bb5d47..a2e4bdf8b9a49006b6ae64b1b5bc24d0d6759116 100644 (file)
@@ -130,9 +130,9 @@ void validate_invalid_minutes_string_tests()
        validate_invalid_minutes_string_test("100");
 }
 
-int main()
+int run_validate_tests()
 {
-       const struct CMUnitTest tests[] = {
+       const struct CMUnitTest validate_tests[] = {
                cmocka_unit_test(validate_valid_date_string_tests),
                cmocka_unit_test(validate_invalid_date_string_tests),
                cmocka_unit_test(validate_valid_hour_string_tests),
@@ -141,5 +141,5 @@ int main()
                cmocka_unit_test(validate_invalid_minutes_string_tests)
        };
 
-       return cmocka_run_group_tests(tests, NULL, NULL);
+       return cmocka_run_group_tests(validate_tests, NULL, NULL);
 }
\ No newline at end of file
index f3895ad66e8c477bf19dfb854832d8142fa61f83..d78c4eabd179ea01901425a4782d114aa4268da7 100644 (file)
@@ -84,9 +84,9 @@ void get_diff_to_end_ten_hour_end_test()
        assert_int_equal(result, 21720);
 }
 
-int main()
+int run_worktime_tests()
 {
-       const struct CMUnitTest tests[] = {
+       const struct CMUnitTest worktime_tests[] = {
                cmocka_unit_test(get_eigth_hour_end_time_test),
                cmocka_unit_test(get_ten_hour_end_time_test),
                cmocka_unit_test(get_current_worktime_four_hours_thirteen_test),
@@ -97,5 +97,5 @@ int main()
                cmocka_unit_test(get_diff_to_end_ten_hour_end_test),
        };
 
-       return cmocka_run_group_tests(tests, NULL, NULL);
+       return cmocka_run_group_tests(worktime_tests, NULL, NULL);
 }
\ No newline at end of file