diff --git a/build/test/cache/test_divide.c b/build/test/cache/test_divide.c new file mode 100644 index 0000000..3763fc5 --- /dev/null +++ b/build/test/cache/test_divide.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_divide(void){ + + + + double num1 = 9; + + double num2 = 3; + + double division = num1 / num2; + + double result; + + + + + + result = division; + + + + + + UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(24), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/dependencies/test_divide.d b/build/test/dependencies/test_divide.d new file mode 100644 index 0000000..172e1ec --- /dev/null +++ b/build/test/dependencies/test_divide.d @@ -0,0 +1,4 @@ +build/test/out/c/test_divide.o: test/Calculator/test_divide.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_divide_runner.d b/build/test/dependencies/test_divide_runner.d new file mode 100644 index 0000000..b42c847 --- /dev/null +++ b/build/test/dependencies/test_divide_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_divide_runner.o: \ + build/test/runners/test_divide_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 a5f276f..b0c6aae 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_divide.o b/build/test/out/c/test_divide.o new file mode 100644 index 0000000..211bdcd Binary files /dev/null and b/build/test/out/c/test_divide.o differ diff --git a/build/test/out/c/test_divide_runner.o b/build/test/out/c/test_divide_runner.o new file mode 100644 index 0000000..417d68f Binary files /dev/null and b/build/test/out/c/test_divide_runner.o differ diff --git a/build/test/out/test_cbrt.out b/build/test/out/test_cbrt.out index 3cb78e6..a2da86b 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 new file mode 100755 index 0000000..9f48e14 Binary files /dev/null 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 8a59acf..bb6cc10 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 7bdd3bb..75852f7 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 b37fa74..9cc3169 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 d7d206f..a9bcd93 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 b6627c7..1301f23 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_divide.c b/build/test/preprocess/files/test_divide.c new file mode 100644 index 0000000..3763fc5 --- /dev/null +++ b/build/test/preprocess/files/test_divide.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_divide(void){ + + + + double num1 = 9; + + double num2 = 3; + + double division = num1 / num2; + + double result; + + + + + + result = division; + + + + + + UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(24), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/includes/test_divide.c b/build/test/preprocess/includes/test_divide.c new file mode 100644 index 0000000..f2efae7 --- /dev/null +++ b/build/test/preprocess/includes/test_divide.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_cbrt.pass b/build/test/results/test_cbrt.pass index b51bba7..e95950c 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.002984535996802151 +:time: 0.0006476099952124059 diff --git a/build/test/results/test_divide.pass b/build/test/results/test_divide.pass new file mode 100644 index 0000000..421094a --- /dev/null +++ b/build/test/results/test_divide.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Calculator + :file: test_divide.c +:successes: +- :test: test_divide + :line: 13 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.007046165002975613 diff --git a/build/test/results/test_factorial.pass b/build/test/results/test_factorial.pass index 2836ba0..97232a1 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.004264043003786355 +:time: 0.0032789550023153424 diff --git a/build/test/results/test_log.pass b/build/test/results/test_log.pass index fea15b6..2416b02 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.0032400870113633573 +:time: 0.0031624000112060457 diff --git a/build/test/results/test_mod.pass b/build/test/results/test_mod.pass index bf8198a..75d7c0c 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.0043334150104783475 +:time: 0.0031652229954488575 diff --git a/build/test/results/test_multiply.pass b/build/test/results/test_multiply.pass index 1384372..8299cd9 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.00700880799558945 +:time: 0.003240023012040183 diff --git a/build/test/results/test_pow.pass b/build/test/results/test_pow.pass index 7059cd5..f2c83d1 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.006334579986287281 +:time: 0.0032584719883743674 diff --git a/build/test/results/test_sqrt.pass b/build/test/results/test_sqrt.pass index b70f106..c6ff18b 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.0062521169893443584 +:time: 0.0032074050104711205 diff --git a/build/test/runners/test_divide_runner.c b/build/test/runners/test_divide_runner.c new file mode 100644 index 0000000..bf39076 --- /dev/null +++ b/build/test/runners/test_divide_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_divide(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_divide.c"); + run_test(test_divide, "test_divide", 13); + + return UnityEnd(); +} diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 3589de7..6854565 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -17,7 +17,7 @@ double log(num1); double sqrt(double num1); double cbrt(num1); int multiply (int num1,int num2); - +double divide (double num1, double num2); int calculator() { @@ -184,3 +184,7 @@ int multiply(int num1,int num2){ int product = num1 * num2; return product; } +double divide(double num1, double num2){ + double division = num1 / num2; + return division; +} diff --git a/src/main/c/Calculator/calculator.h b/src/main/c/Calculator/calculator.h index 73ab918..9e123ee 100644 --- a/src/main/c/Calculator/calculator.h +++ b/src/main/c/Calculator/calculator.h @@ -9,4 +9,5 @@ double log(double num1); double sqrt(double num1); double cbrt(double num1); int multiply(int num1,int num2); +double divide(double num1,double num2); #endif diff --git a/test/Calculator/test_divide.c b/test/Calculator/test_divide.c new file mode 100644 index 0000000..6b14a95 --- /dev/null +++ b/test/Calculator/test_divide.c @@ -0,0 +1,27 @@ +#ifdef TEST +#include "unity.h" +#include "calculator.h" + + +void setUp(void){ + //Wenn Funktion Vorraussetzungen braucht +} +void tearDown(void){ +} + + +void test_divide(void){ + /* arrange */ + double num1 = 9; + double num2 = 3; + double division = num1 / num2; + double result; + + /* act */ + result = division; + + /* assert */ + TEST_ASSERT_EQUAL_INT(3, result);// 9 / 3 = 3 +} + +#endif // TEST