From f66613a3f43ab748d4a67ccbdb336ccf16545134 Mon Sep 17 00:00:00 2001 From: fdai7754 Date: Sat, 3 Feb 2024 18:38:37 +0100 Subject: [PATCH] rest funktion minirechner inkl. unittest --- src/minirechner.c | 5 +++++ src/minirechner.h | 1 + test/test_minirechner.c | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/src/minirechner.c b/src/minirechner.c index 6a133f3..cbc13ef 100644 --- a/src/minirechner.c +++ b/src/minirechner.c @@ -25,4 +25,9 @@ float dividieren(float a, float b) { else { return a / b; } +} + +//rest +float rest(float a, float b) { + return fmod(a, b); } \ No newline at end of file diff --git a/src/minirechner.h b/src/minirechner.h index 8c4466f..a2c989f 100644 --- a/src/minirechner.h +++ b/src/minirechner.h @@ -5,5 +5,6 @@ float addieren(float a, float b); float subtrahieren(float a, float b); float multiplizieren(float a, float b); float dividieren(float a, float b); +float rest(float a, float b); #endif // MINIRECHNER_H diff --git a/test/test_minirechner.c b/test/test_minirechner.c index 88e1df2..8df2c71 100644 --- a/test/test_minirechner.c +++ b/test/test_minirechner.c @@ -100,4 +100,11 @@ void test_minitaschenrechner_0_durch_5(void) TEST_ASSERT_EQUAL(0, result); } +// test rest +void test_minitaschenrechner_14_rest_5(void) +{ + float result = rest(14, 5); + TEST_ASSERT_EQUAL(4, result); +} + #endif // TEST