Browse Source

subtraktion funktion minirechner inkl. unittest

remotes/origin/minirechnerdev
fdai7754 11 months ago
parent
commit
cf4865a852
  1. 5
      src/minirechner.c
  2. 1
      src/minirechner.h
  3. 8
      test/test_minirechner.c

5
src/minirechner.c

@ -5,3 +5,8 @@
float addieren(float a, float b) { float addieren(float a, float b) {
return a + b; return a + b;
} }
//subtrahieren
float subtrahieren(float a, float b) {
return a - b;
}

1
src/minirechner.h

@ -2,5 +2,6 @@
#define MINIRECHNER_H #define MINIRECHNER_H
float addieren(float a, float b); float addieren(float a, float b);
float subtrahieren(float a, float b);
#endif // MINIRECHNER_H #endif // MINIRECHNER_H

8
test/test_minirechner.c

@ -36,4 +36,12 @@ void test_minitaschenrechner_0_plus_2(void)
float result = addieren(0, 2); float result = addieren(0, 2);
TEST_ASSERT_EQUAL(2, result); 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 #endif // TEST
Loading…
Cancel
Save