diff --git a/build/test/cache/test_add.c b/build/test/cache/test_add.c new file mode 100644 index 0000000..26907b6 --- /dev/null +++ b/build/test/cache/test_add.c @@ -0,0 +1,51 @@ +#include "src/main/c/Template/game100.h" +#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){ + + + +} + +void tearDown(void){ + +} + + + + + +void test_add(void){ + + + + int num1 = 10; + + int num2 = 5; + + int result; + + int addition = num1 + num2; + + + + + + result = addition; + + + + + + UnityAssertEqualNumber((UNITY_INT)((15)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(24), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/dependencies/test_add.d b/build/test/dependencies/test_add.d new file mode 100644 index 0000000..4a84e70 --- /dev/null +++ b/build/test/dependencies/test_add.d @@ -0,0 +1,4 @@ +build/test/out/c/test_add.o: test/Calculator/test_add.c \ + /var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + src/main/c/Template/game100.h diff --git a/build/test/dependencies/test_add_runner.d b/build/test/dependencies/test_add_runner.d new file mode 100644 index 0000000..e3f0886 --- /dev/null +++ b/build/test/dependencies/test_add_runner.d @@ -0,0 +1,3 @@ +build/test/out/c/test_add_runner.o: build/test/runners/test_add_runner.c \ + /var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/out/c/calculator.o b/build/test/out/c/calculator.o index b0c6aae..9bb982f 100644 Binary files a/build/test/out/c/calculator.o and b/build/test/out/c/calculator.o differ diff --git a/build/test/out/c/test_add.o b/build/test/out/c/test_add.o new file mode 100644 index 0000000..5e3770d Binary files /dev/null and b/build/test/out/c/test_add.o differ diff --git a/build/test/out/c/test_add_runner.o b/build/test/out/c/test_add_runner.o new file mode 100644 index 0000000..f018a39 Binary files /dev/null and b/build/test/out/c/test_add_runner.o differ diff --git a/build/test/out/test_add.out b/build/test/out/test_add.out new file mode 100755 index 0000000..24da445 Binary files /dev/null and b/build/test/out/test_add.out differ diff --git a/build/test/out/test_cbrt.out b/build/test/out/test_cbrt.out index a2da86b..0b7105f 100755 Binary files a/build/test/out/test_cbrt.out and b/build/test/out/test_cbrt.out differ diff --git a/build/test/out/test_divide.out b/build/test/out/test_divide.out index 9f48e14..9fa276d 100755 Binary files a/build/test/out/test_divide.out and b/build/test/out/test_divide.out differ diff --git a/build/test/out/test_factorial.out b/build/test/out/test_factorial.out index bb6cc10..ac29a81 100755 Binary files a/build/test/out/test_factorial.out and b/build/test/out/test_factorial.out differ diff --git a/build/test/out/test_log.out b/build/test/out/test_log.out index 75852f7..4c40fb4 100755 Binary files a/build/test/out/test_log.out and b/build/test/out/test_log.out differ diff --git a/build/test/out/test_mod.out b/build/test/out/test_mod.out index 9cc3169..956dc8c 100755 Binary files a/build/test/out/test_mod.out and b/build/test/out/test_mod.out differ diff --git a/build/test/out/test_pow.out b/build/test/out/test_pow.out index a9bcd93..8c03b38 100755 Binary files a/build/test/out/test_pow.out and b/build/test/out/test_pow.out differ diff --git a/build/test/out/test_sqrt.out b/build/test/out/test_sqrt.out index 1301f23..bd75723 100755 Binary files a/build/test/out/test_sqrt.out and b/build/test/out/test_sqrt.out differ diff --git a/build/test/preprocess/files/test_add.c b/build/test/preprocess/files/test_add.c new file mode 100644 index 0000000..26907b6 --- /dev/null +++ b/build/test/preprocess/files/test_add.c @@ -0,0 +1,51 @@ +#include "src/main/c/Template/game100.h" +#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){ + + + +} + +void tearDown(void){ + +} + + + + + +void test_add(void){ + + + + int num1 = 10; + + int num2 = 5; + + int result; + + int addition = num1 + num2; + + + + + + result = addition; + + + + + + UnityAssertEqualNumber((UNITY_INT)((15)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(24), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/includes/test_add.c b/build/test/preprocess/includes/test_add.c new file mode 100644 index 0000000..e60bf2a --- /dev/null +++ b/build/test/preprocess/includes/test_add.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/Template/game100.h diff --git a/build/test/results/test_add.pass b/build/test/results/test_add.pass new file mode 100644 index 0000000..009f601 --- /dev/null +++ b/build/test/results/test_add.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Calculator + :file: test_add.c +:successes: +- :test: test_add + :line: 13 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.006868249998660758 diff --git a/build/test/results/test_cbrt.pass b/build/test/results/test_cbrt.pass index e95950c..5181d7c 100644 --- a/build/test/results/test_cbrt.pass +++ b/build/test/results/test_cbrt.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0006476099952124059 +:time: 0.0062123289972078055 diff --git a/build/test/results/test_divide.pass b/build/test/results/test_divide.pass index 421094a..bddd3e8 100644 --- a/build/test/results/test_divide.pass +++ b/build/test/results/test_divide.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.007046165002975613 +:time: 0.006226740020792931 diff --git a/build/test/results/test_factorial.pass b/build/test/results/test_factorial.pass index 97232a1..e91b02f 100644 --- a/build/test/results/test_factorial.pass +++ b/build/test/results/test_factorial.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0032789550023153424 +:time: 0.006363478023558855 diff --git a/build/test/results/test_log.pass b/build/test/results/test_log.pass index 2416b02..77260d8 100644 --- a/build/test/results/test_log.pass +++ b/build/test/results/test_log.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0031624000112060457 +:time: 0.006499917013570666 diff --git a/build/test/results/test_mod.pass b/build/test/results/test_mod.pass index 75d7c0c..0106b0c 100644 --- a/build/test/results/test_mod.pass +++ b/build/test/results/test_mod.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0031652229954488575 +:time: 0.00630686100339517 diff --git a/build/test/results/test_multiply.pass b/build/test/results/test_multiply.pass index 8299cd9..4a34455 100644 --- a/build/test/results/test_multiply.pass +++ b/build/test/results/test_multiply.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.003240023012040183 +:time: 0.004303659981815144 diff --git a/build/test/results/test_pow.pass b/build/test/results/test_pow.pass index f2c83d1..31cacd6 100644 --- a/build/test/results/test_pow.pass +++ b/build/test/results/test_pow.pass @@ -19,4 +19,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0032584719883743674 +:time: 0.006403419014532119 diff --git a/build/test/results/test_sqrt.pass b/build/test/results/test_sqrt.pass index c6ff18b..4c256e7 100644 --- a/build/test/results/test_sqrt.pass +++ b/build/test/results/test_sqrt.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0032074050104711205 +:time: 0.006328894000034779 diff --git a/build/test/runners/test_add_runner.c b/build/test/runners/test_add_runner.c new file mode 100644 index 0000000..eab12b8 --- /dev/null +++ b/build/test/runners/test_add_runner.c @@ -0,0 +1,81 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_add(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + CMock_Verify(); +} + +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_add.c"); + run_test(test_add, "test_add", 13); + + return UnityEnd(); +} diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 6854565..a27f433 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -18,7 +18,7 @@ double sqrt(double num1); double cbrt(num1); int multiply (int num1,int num2); double divide (double num1, double num2); - +int add (int num1, int num2); int calculator() { int choice; @@ -188,3 +188,7 @@ double divide(double num1, double num2){ double division = num1 / num2; return division; } +int add(int num1, int num2){ + int addition = num1 + num2; + return addition; +} diff --git a/src/main/c/Calculator/calculator.h b/src/main/c/Calculator/calculator.h index 9e123ee..eb4f04d 100644 --- a/src/main/c/Calculator/calculator.h +++ b/src/main/c/Calculator/calculator.h @@ -10,4 +10,5 @@ double sqrt(double num1); double cbrt(double num1); int multiply(int num1,int num2); double divide(double num1,double num2); +int add(int num1 ,int num2); #endif diff --git a/test/Calculator/test_add.c b/test/Calculator/test_add.c new file mode 100644 index 0000000..57e6f55 --- /dev/null +++ b/test/Calculator/test_add.c @@ -0,0 +1,28 @@ +#ifdef TEST +#include "unity.h" +#include "game100.h" + + +void setUp(void){ + //Wenn Funktion Vorraussetzungen braucht +} +void tearDown(void){ +} + + +void test_add(void){ + /* arrange */ + int num1 = 10; + int num2 = 5; + int result; + int addition = num1 + num2; + + /* act */ + result = addition; + + /* assert */ + TEST_ASSERT_EQUAL_INT(15, result);// 10 + 5 = 15 +} + + +#endif // TEST