diff --git a/build/test/cache/test_subtract.c b/build/test/cache/test_subtract.c new file mode 100644 index 0000000..a44beb1 --- /dev/null +++ b/build/test/cache/test_subtract.c @@ -0,0 +1,51 @@ +#include "src/main/c/Calculator/calculator.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_subtract(void){ + + + + int num1 = 14; + + int num2 = 7; + + int result; + + int subtraction = num1 - num2; + + + + + + result = subtraction; + + + + + + UnityAssertEqualNumber((UNITY_INT)((7)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(24), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/dependencies/test_subtract.d b/build/test/dependencies/test_subtract.d new file mode 100644 index 0000000..e479202 --- /dev/null +++ b/build/test/dependencies/test_subtract.d @@ -0,0 +1,4 @@ +build/test/out/c/test_subtract.o: test/Calculator/test_subtract.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/Calculator/calculator.h diff --git a/build/test/dependencies/test_subtract_runner.d b/build/test/dependencies/test_subtract_runner.d new file mode 100644 index 0000000..a980be6 --- /dev/null +++ b/build/test/dependencies/test_subtract_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_subtract_runner.o: \ + build/test/runners/test_subtract_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 9bb982f..e40528b 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_subtract.o b/build/test/out/c/test_subtract.o new file mode 100644 index 0000000..4b92b47 Binary files /dev/null and b/build/test/out/c/test_subtract.o differ diff --git a/build/test/out/c/test_subtract_runner.o b/build/test/out/c/test_subtract_runner.o new file mode 100644 index 0000000..05a7a82 Binary files /dev/null and b/build/test/out/c/test_subtract_runner.o differ diff --git a/build/test/out/test_cbrt.out b/build/test/out/test_cbrt.out index 0b7105f..80f91dc 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 9fa276d..74178ad 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 ac29a81..38854ff 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 4c40fb4..5f870cf 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 956dc8c..cb79470 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 8c03b38..c0c356f 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 bd75723..b0ea718 100755 Binary files a/build/test/out/test_sqrt.out and b/build/test/out/test_sqrt.out differ diff --git a/build/test/out/test_subtract.out b/build/test/out/test_subtract.out new file mode 100755 index 0000000..b88257c Binary files /dev/null and b/build/test/out/test_subtract.out differ diff --git a/build/test/preprocess/files/test_subtract.c b/build/test/preprocess/files/test_subtract.c new file mode 100644 index 0000000..a44beb1 --- /dev/null +++ b/build/test/preprocess/files/test_subtract.c @@ -0,0 +1,51 @@ +#include "src/main/c/Calculator/calculator.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_subtract(void){ + + + + int num1 = 14; + + int num2 = 7; + + int result; + + int subtraction = num1 - num2; + + + + + + result = subtraction; + + + + + + UnityAssertEqualNumber((UNITY_INT)((7)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(24), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/includes/test_subtract.c b/build/test/preprocess/includes/test_subtract.c new file mode 100644 index 0000000..f2efae7 --- /dev/null +++ b/build/test/preprocess/includes/test_subtract.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/Calculator/calculator.h diff --git a/build/test/results/test_add.pass b/build/test/results/test_add.pass index 009f601..183d0f1 100644 --- a/build/test/results/test_add.pass +++ b/build/test/results/test_add.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.006868249998660758 +:time: 0.001341750001301989 diff --git a/build/test/results/test_cbrt.pass b/build/test/results/test_cbrt.pass index 5181d7c..3cdfbbf 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.0062123289972078055 +:time: 0.003224601998226717 diff --git a/build/test/results/test_divide.pass b/build/test/results/test_divide.pass index bddd3e8..572c1f8 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.006226740020792931 +:time: 0.0032165549928322434 diff --git a/build/test/results/test_factorial.pass b/build/test/results/test_factorial.pass index e91b02f..f83a2cc 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.006363478023558855 +:time: 0.0032816580205690116 diff --git a/build/test/results/test_log.pass b/build/test/results/test_log.pass index 77260d8..43a709b 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.006499917013570666 +:time: 0.003215620992705226 diff --git a/build/test/results/test_mod.pass b/build/test/results/test_mod.pass index 0106b0c..3fc4e25 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.00630686100339517 +:time: 0.003226413013180718 diff --git a/build/test/results/test_multiply.pass b/build/test/results/test_multiply.pass index 4a34455..ba83e9d 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.004303659981815144 +:time: 0.00324131001252681 diff --git a/build/test/results/test_pow.pass b/build/test/results/test_pow.pass index 31cacd6..ece0fb8 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.006403419014532119 +:time: 0.0032054850016720593 diff --git a/build/test/results/test_sqrt.pass b/build/test/results/test_sqrt.pass index 4c256e7..ba299e8 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.006328894000034779 +:time: 0.0031778719858266413 diff --git a/build/test/results/test_subtract.pass b/build/test/results/test_subtract.pass new file mode 100644 index 0000000..b972628 --- /dev/null +++ b/build/test/results/test_subtract.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Calculator + :file: test_subtract.c +:successes: +- :test: test_subtract + :line: 13 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.006584955001017079 diff --git a/build/test/runners/test_subtract_runner.c b/build/test/runners/test_subtract_runner.c new file mode 100644 index 0000000..75730b2 --- /dev/null +++ b/build/test/runners/test_subtract_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_subtract(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_subtract.c"); + run_test(test_subtract, "test_subtract", 13); + + return UnityEnd(); +} diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index a27f433..5be62fa 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -19,6 +19,7 @@ double cbrt(num1); int multiply (int num1,int num2); double divide (double num1, double num2); int add (int num1, int num2); +int subtract(int num1, int num2); int calculator() { int choice; @@ -192,3 +193,7 @@ int add(int num1, int num2){ int addition = num1 + num2; return addition; } +int subtract(int num1, int num2){ + int subtraction = num1 - num2; + return subtraction; +} diff --git a/src/main/c/Calculator/calculator.h b/src/main/c/Calculator/calculator.h index eb4f04d..9e34df5 100644 --- a/src/main/c/Calculator/calculator.h +++ b/src/main/c/Calculator/calculator.h @@ -11,4 +11,5 @@ double cbrt(double num1); int multiply(int num1,int num2); double divide(double num1,double num2); int add(int num1 ,int num2); +int subtract(int num1, int num2); #endif diff --git a/test/Calculator/test_subtract.c b/test/Calculator/test_subtract.c new file mode 100644 index 0000000..408c98b --- /dev/null +++ b/test/Calculator/test_subtract.c @@ -0,0 +1,28 @@ +#ifdef TEST +#include "unity.h" +#include "calculator.h" + + +void setUp(void){ + //Wenn Funktion Vorraussetzungen braucht +} +void tearDown(void){ +} + + +void test_subtract(void){ + /* arrange */ + int num1 = 14; + int num2 = 7; + int result; + int subtraction = num1 - num2; + + /* act */ + result = subtraction; + + /* assert */ + TEST_ASSERT_EQUAL_INT(7, result);// 14 - 7 = 7 +} + + +#endif // TEST