Browse Source

added feature "add" as a skeleton to use for other features

remotes/origin/userinput
TheUltimateOptimist 11 months ago
parent
commit
9f0ebb7fe5
  1. 5
      src/add/add.c
  2. 4
      src/add/add.h
  3. 10
      src/add/add_main.c
  4. 9
      test/add/test_add.c

5
src/add/add.c

@ -0,0 +1,5 @@
#include "add.h"
int add(int a, int b) {
return a + b;
}

4
src/add/add.h

@ -0,0 +1,4 @@
#ifndef SOME_H
#define SOME_H
int add(int a, int b);
#endif

10
src/add/add_main.c

@ -0,0 +1,10 @@
#include "add.h"
#include "../userinput.h"
#include <stdio.h>
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));
}

9
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));
}
Loading…
Cancel
Save