diff --git a/build/test/cache/test_sqrt.c b/build/test/cache/test_sqrt.c new file mode 100644 index 0000000..2fc2a2d --- /dev/null +++ b/build/test/cache/test_sqrt.c @@ -0,0 +1,47 @@ +#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_sqrt(void){ + + + + double result; + + double a = 25; + + + + + + result = sqrt(25); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/dependencies/test_sqrt.d b/build/test/dependencies/test_sqrt.d new file mode 100644 index 0000000..dd1c1a5 --- /dev/null +++ b/build/test/dependencies/test_sqrt.d @@ -0,0 +1,4 @@ +build/test/out/c/test_sqrt.o: test/Calculator/test_sqrt.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_sqrt_runner.d b/build/test/dependencies/test_sqrt_runner.d new file mode 100644 index 0000000..03a1b1d --- /dev/null +++ b/build/test/dependencies/test_sqrt_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_sqrt_runner.o: \ + build/test/runners/test_sqrt_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 a125ff4..fe6dc14 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_sqrt.o b/build/test/out/c/test_sqrt.o new file mode 100644 index 0000000..04d17ed Binary files /dev/null and b/build/test/out/c/test_sqrt.o differ diff --git a/build/test/out/c/test_sqrt_runner.o b/build/test/out/c/test_sqrt_runner.o new file mode 100644 index 0000000..6a1bce8 Binary files /dev/null and b/build/test/out/c/test_sqrt_runner.o differ diff --git a/build/test/out/test_factorial.out b/build/test/out/test_factorial.out index 2c6920e..ca8671c 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 537fdff..aa8b46f 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 d525312..9d2af7c 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 6dffc28..5e6864d 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 new file mode 100755 index 0000000..c404a3f Binary files /dev/null and b/build/test/out/test_sqrt.out differ diff --git a/build/test/preprocess/files/test_sqrt.c b/build/test/preprocess/files/test_sqrt.c new file mode 100644 index 0000000..2fc2a2d --- /dev/null +++ b/build/test/preprocess/files/test_sqrt.c @@ -0,0 +1,47 @@ +#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_sqrt(void){ + + + + double result; + + double a = 25; + + + + + + result = sqrt(25); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/includes/test_sqrt.c b/build/test/preprocess/includes/test_sqrt.c new file mode 100644 index 0000000..f2efae7 --- /dev/null +++ b/build/test/preprocess/includes/test_sqrt.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_factorial.pass b/build/test/results/test_factorial.pass index 05c31d3..b8fed6d 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.004361564002465457 +:time: 0.006785353005398065 diff --git a/build/test/results/test_log.pass b/build/test/results/test_log.pass index dbc8bdc..e671b6e 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.0030175010033417493 +:time: 0.006155624985694885 diff --git a/build/test/results/test_mod.pass b/build/test/results/test_mod.pass index 5a1e2e8..1a37ad5 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.0026945919962599874 +:time: 0.006076960009522736 diff --git a/build/test/results/test_pow.pass b/build/test/results/test_pow.pass index c0d42b3..38c87d4 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.0063727759988978505 +:time: 0.006162547011626884 diff --git a/build/test/results/test_sqrt.pass b/build/test/results/test_sqrt.pass new file mode 100644 index 0000000..241978f --- /dev/null +++ b/build/test/results/test_sqrt.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Calculator + :file: test_sqrt.c +:successes: +- :test: test_sqrt + :line: 13 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0060438819928094745 diff --git a/build/test/runners/test_sqrt_runner.c b/build/test/runners/test_sqrt_runner.c new file mode 100644 index 0000000..54b130d --- /dev/null +++ b/build/test/runners/test_sqrt_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_sqrt(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_sqrt.c"); + run_test(test_sqrt, "test_sqrt", 13); + + return UnityEnd(); +} diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 27984a6..55a8841 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -14,6 +14,9 @@ double combination(int n, int r); double pow(double num1, double num2); int mod(int num1,int num2); double log(num1); +double sqrt(num1); + + int calculator() { int choice; double num1, num2, result; @@ -93,7 +96,7 @@ double log(num1); case 8: return pow(num1, num2); case 9: - return 0;// sqrt(num1); + return 0; sqrt(num1); case 10: return num1 * num1; case 11: @@ -166,3 +169,7 @@ double log(double num1){ double result = num1; return result; } +double sqrt(double num1){ + double result = num1; + return result; +} diff --git a/src/main/c/Calculator/calculator.h b/src/main/c/Calculator/calculator.h index d86c05d..8c16e13 100644 --- a/src/main/c/Calculator/calculator.h +++ b/src/main/c/Calculator/calculator.h @@ -6,5 +6,6 @@ double pow(double num1, double num2); double factorial(double num); int mod(int num1, int num2); double log(double num1); +double sqrt(double num1); #endif diff --git a/test/Calculator/test_sqrt.c b/test/Calculator/test_sqrt.c new file mode 100644 index 0000000..f89126c --- /dev/null +++ b/test/Calculator/test_sqrt.c @@ -0,0 +1,25 @@ +#ifdef TEST +#include "unity.h" +#include "calculator.h" + + +void setUp(void){ + //Wenn Funktion Vorraussetzungen braucht +} +void tearDown(void){ +} + + +void test_sqrt(void){ + /* arrange */ + double result; + double a = 25; + + /* act */ + result = sqrt(25); + + /* assert */ + TEST_ASSERT_EQUAL_INT(5, result);// sqrt(25) = 5 +} + +#endif // TEST