]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
add test for no break time
authorBastian Dehn <hhaalo@arcor.de>
Sun, 9 Jun 2024 08:25:18 +0000 (10:25 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 9 Jun 2024 08:25:35 +0000 (10:25 +0200)
src/break.c [new file with mode: 0644]
src/break.h [new file with mode: 0644]
tests/CMakeLists.txt
tests/main.c

diff --git a/src/break.c b/src/break.c
new file mode 100644 (file)
index 0000000..a325052
--- /dev/null
@@ -0,0 +1,6 @@
+#include "break.h"
+
+int get_break_time(long worktime)
+{
+       return 0;
+}
\ No newline at end of file
diff --git a/src/break.h b/src/break.h
new file mode 100644 (file)
index 0000000..98507ce
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef BREAK_H
+#define BREAK_H
+#include <time.h>
+
+int get_break_time(long worktime);
+
+#endif
\ No newline at end of file
index 3c27b93af20ce823f1020c69c2788390670923d6..01cbf61ccf2bc093b14eb46dd67f5cd0b1401e65 100644 (file)
@@ -2,7 +2,9 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.25.1)
 
 FIND_LIBRARY(CMOCKA cmocka REQUIRED)
 
-ADD_EXECUTABLE(feierabend-test main.c)
+ADD_EXECUTABLE(feierabend-test
+       main.c
+       ../src/break.c)
 TARGET_LINK_LIBRARIES(feierabend-test
        ${CMOCKA})
 
index 2b03b4ae3878d0a7b36f9d9e4f127459eaeeee38..ad373ce3a24dcfec6770b91ac25976f87196bf27 100644 (file)
@@ -4,16 +4,22 @@
 #include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
+#include "../src/break.h"
 
-void sanity_check()
+void two_hours_zero_break()
 {
-       assert_false(0);
+       const long TWO_HOURS = 7200;
+       long worktime = TWO_HOURS;
+
+       int breaktime = get_break_time(worktime);
+
+       assert_int_equal(breaktime, 0);
 }
 
 int main()
 {
        const struct CMUnitTest tests[] = {
-               cmocka_unit_test(sanity_check)
+               cmocka_unit_test(two_hours_zero_break)
        };
 
        return cmocka_run_group_tests(tests, NULL, NULL);