From cf4865a8525fa2fd685fa942105b15d6c8b48e45 Mon Sep 17 00:00:00 2001 From: fdai7754 Date: Sat, 3 Feb 2024 17:58:16 +0100 Subject: [PATCH] subtraktion funktion minirechner inkl. unittest --- src/minirechner.c | 5 +++++ src/minirechner.h | 1 + test/test_minirechner.c | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/src/minirechner.c b/src/minirechner.c index b5bf37b..036ebbe 100644 --- a/src/minirechner.c +++ b/src/minirechner.c @@ -4,4 +4,9 @@ //addieren float addieren(float a, float b) { return a + b; +} + +//subtrahieren +float subtrahieren(float a, float b) { + return a - b; } \ No newline at end of file diff --git a/src/minirechner.h b/src/minirechner.h index 63695c7..0a61c42 100644 --- a/src/minirechner.h +++ b/src/minirechner.h @@ -2,5 +2,6 @@ #define MINIRECHNER_H float addieren(float a, float b); +float subtrahieren(float a, float b); #endif // MINIRECHNER_H diff --git a/test/test_minirechner.c b/test/test_minirechner.c index cacd21b..cba19de 100644 --- a/test/test_minirechner.c +++ b/test/test_minirechner.c @@ -36,4 +36,12 @@ void test_minitaschenrechner_0_plus_2(void) float result = addieren(0, 2); TEST_ASSERT_EQUAL(2, result); } + +// test subtraktion +void test_minitaschenrechner_5_minus_2(void) +{ + float result = subtrahieren(5, 2); + TEST_ASSERT_EQUAL(3, result); +} + #endif // TEST