From 163d6a880f07596750c69d94f64e6fdde0a4fa31 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 9 Jun 2024 10:25:18 +0200 Subject: [PATCH] add test for no break time --- src/break.c | 6 ++++++ src/break.h | 7 +++++++ tests/CMakeLists.txt | 4 +++- tests/main.c | 12 +++++++++--- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/break.c create mode 100644 src/break.h diff --git a/src/break.c b/src/break.c new file mode 100644 index 0000000..a325052 --- /dev/null +++ b/src/break.c @@ -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 index 0000000..98507ce --- /dev/null +++ b/src/break.h @@ -0,0 +1,7 @@ +#ifndef BREAK_H +#define BREAK_H +#include + +int get_break_time(long worktime); + +#endif \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3c27b93..01cbf61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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}) diff --git a/tests/main.c b/tests/main.c index 2b03b4a..ad373ce 100644 --- a/tests/main.c +++ b/tests/main.c @@ -4,16 +4,22 @@ #include #include #include +#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); -- 2.39.5