From 3eaff2e1a76170d349624c67ec5daf344e90d8d4 Mon Sep 17 00:00:00 2001 From: Leon Wolf Date: Thu, 8 Feb 2024 17:32:58 +0100 Subject: [PATCH] Commit arithmetic Subtraction integer --- src/arithmeticSubtraction.c | 10 ++++++++++ src/arithmeticSubtraction.h | 7 +++++++ test/test_arithmeticSubtraction.c | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 src/arithmeticSubtraction.c create mode 100644 src/arithmeticSubtraction.h create mode 100644 test/test_arithmeticSubtraction.c diff --git a/src/arithmeticSubtraction.c b/src/arithmeticSubtraction.c new file mode 100644 index 0000000..f8a7eb5 --- /dev/null +++ b/src/arithmeticSubtraction.c @@ -0,0 +1,10 @@ + +#include "arithmeticSubtraction.h" + +#include + +int* subtraction_integer(int a, int b) { + int* result= malloc(sizeof (int)); + *result=a - b; + return result; +} diff --git a/src/arithmeticSubtraction.h b/src/arithmeticSubtraction.h new file mode 100644 index 0000000..5a36ba5 --- /dev/null +++ b/src/arithmeticSubtraction.h @@ -0,0 +1,7 @@ + +#ifndef THEADMIRALS_ARITHMETICSUBTRACTION_H +#define THEADMIRALS_ARITHMETICSUBTRACTION_H + +int* subtraction_integer(int a, int b); + +#endif //THEADMIRALS_ARITHMETICSUBTRACTION_H diff --git a/test/test_arithmeticSubtraction.c b/test/test_arithmeticSubtraction.c new file mode 100644 index 0000000..26d05c4 --- /dev/null +++ b/test/test_arithmeticSubtraction.c @@ -0,0 +1,18 @@ +#include "../src/arithmeticSubtraction.h" +#include "unity.h" +#include "limits.h" + +void setUp(void) { + // set stuff up here +} + +void tearDown(void) { + // clean stuff up here +} +void test_arithmeticSubtraction_subractionoftwonumbers(void) { + int expectedResult = 7; + int* result; + result = subtraction_integer(14, 7); + TEST_ASSERT_EQUAL_INT(expectedResult, *result); +} +