From 9f0ebb7fe5f951e744ea284019e2c13ce95bb5a8 Mon Sep 17 00:00:00 2001 From: TheUltimateOptimist Date: Mon, 29 Jan 2024 00:13:29 +0100 Subject: [PATCH] added feature "add" as a skeleton to use for other features --- src/add/add.c | 5 +++++ src/add/add.h | 4 ++++ src/add/add_main.c | 10 ++++++++++ test/add/test_add.c | 9 +++++++++ 4 files changed, 28 insertions(+) create mode 100644 src/add/add.c create mode 100644 src/add/add.h create mode 100644 src/add/add_main.c create mode 100644 test/add/test_add.c diff --git a/src/add/add.c b/src/add/add.c new file mode 100644 index 0000000..f2b0a32 --- /dev/null +++ b/src/add/add.c @@ -0,0 +1,5 @@ +#include "add.h" + +int add(int a, int b) { + return a + b; +} \ No newline at end of file diff --git a/src/add/add.h b/src/add/add.h new file mode 100644 index 0000000..5b40b2f --- /dev/null +++ b/src/add/add.h @@ -0,0 +1,4 @@ +#ifndef SOME_H +#define SOME_H +int add(int a, int b); +#endif \ No newline at end of file diff --git a/src/add/add_main.c b/src/add/add_main.c new file mode 100644 index 0000000..c846a32 --- /dev/null +++ b/src/add/add_main.c @@ -0,0 +1,10 @@ +#include "add.h" +#include "../userinput.h" +#include + +int main() { + printf("add two numbers:\n"); + int firstNum = getd("first number: ", NULL, NULL); + int secondNum = getd("second number: ", NULL, NULL); + printf("The result is: %d\n", add(firstNum, secondNum)); +} \ No newline at end of file diff --git a/test/add/test_add.c b/test/add/test_add.c new file mode 100644 index 0000000..616f7a5 --- /dev/null +++ b/test/add/test_add.c @@ -0,0 +1,9 @@ +#include "unity.h" +#include "add.h" + +void setUp(void){} +void tearDown(void){} + +void test_add(void) { + TEST_ASSERT_EQUAL_INT(100, add(50, 50)); +}