diff --git a/build/test/cache/test_round.c b/build/test/cache/test_round.c new file mode 100644 index 0000000..918ee70 --- /dev/null +++ b/build/test/cache/test_round.c @@ -0,0 +1,49 @@ +#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_round(void){ + + + + double num1= 3.7; + + double result; + + double rounding = round(num1); + + + + + + result = rounding; + + + + + + UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); + + } diff --git a/build/test/dependencies/test_round.d b/build/test/dependencies/test_round.d new file mode 100644 index 0000000..de6cec9 --- /dev/null +++ b/build/test/dependencies/test_round.d @@ -0,0 +1,4 @@ +build/test/out/c/test_round.o: test/Calculator/test_round.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_round_runner.d b/build/test/dependencies/test_round_runner.d new file mode 100644 index 0000000..0cf862c --- /dev/null +++ b/build/test/dependencies/test_round_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_round_runner.o: \ + build/test/runners/test_round_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 969d601..be9b9a8 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_round.o b/build/test/out/c/test_round.o new file mode 100644 index 0000000..4295102 Binary files /dev/null and b/build/test/out/c/test_round.o differ diff --git a/build/test/out/c/test_round_runner.o b/build/test/out/c/test_round_runner.o new file mode 100644 index 0000000..3b79980 Binary files /dev/null and b/build/test/out/c/test_round_runner.o differ diff --git a/build/test/out/test_cbrt.out b/build/test/out/test_cbrt.out index ccad744..ad28e87 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_ceil.out b/build/test/out/test_ceil.out index 0d50de2..e47daf0 100755 Binary files a/build/test/out/test_ceil.out and b/build/test/out/test_ceil.out differ diff --git a/build/test/out/test_divide.out b/build/test/out/test_divide.out index 927b7b5..462bfbf 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_exp.out b/build/test/out/test_exp.out index 0792c8b..8406481 100755 Binary files a/build/test/out/test_exp.out and b/build/test/out/test_exp.out differ diff --git a/build/test/out/test_factorial.out b/build/test/out/test_factorial.out index 746dba3..7d57a03 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_floor.out b/build/test/out/test_floor.out index d4c118d..acce596 100755 Binary files a/build/test/out/test_floor.out and b/build/test/out/test_floor.out differ diff --git a/build/test/out/test_log.out b/build/test/out/test_log.out index 7d458b3..01f689b 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 0a228ea..3a38aea 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 b4cbf33..ae4d474 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_round.out b/build/test/out/test_round.out new file mode 100755 index 0000000..1f1b5aa Binary files /dev/null and b/build/test/out/test_round.out differ diff --git a/build/test/out/test_sin.out b/build/test/out/test_sin.out index 79fe62e..73ca3f4 100755 Binary files a/build/test/out/test_sin.out and b/build/test/out/test_sin.out differ diff --git a/build/test/out/test_sqrt.out b/build/test/out/test_sqrt.out index 01297ae..2318ec0 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 index 40585ad..f9de162 100755 Binary files a/build/test/out/test_subtract.out and b/build/test/out/test_subtract.out differ diff --git a/build/test/preprocess/files/test_round.c b/build/test/preprocess/files/test_round.c new file mode 100644 index 0000000..918ee70 --- /dev/null +++ b/build/test/preprocess/files/test_round.c @@ -0,0 +1,49 @@ +#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_round(void){ + + + + double num1= 3.7; + + double result; + + double rounding = round(num1); + + + + + + result = rounding; + + + + + + UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); + + } diff --git a/build/test/preprocess/includes/test_round.c b/build/test/preprocess/includes/test_round.c new file mode 100644 index 0000000..f2efae7 --- /dev/null +++ b/build/test/preprocess/includes/test_round.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 74dd55f..6e78b13 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.0006727389991283417 +:time: 0.0006854459934402257 diff --git a/build/test/results/test_cbrt.pass b/build/test/results/test_cbrt.pass index adc2dcd..ae1ebef 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.0007822210027370602 +:time: 0.0007552689930889755 diff --git a/build/test/results/test_ceil.pass b/build/test/results/test_ceil.pass index 5df0363..216afcb 100644 --- a/build/test/results/test_ceil.pass +++ b/build/test/results/test_ceil.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0008119580161292106 +:time: 0.000791327009210363 diff --git a/build/test/results/test_divide.pass b/build/test/results/test_divide.pass index 42d050f..fd44823 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.0007850099937058985 +:time: 0.0007838979945518076 diff --git a/build/test/results/test_exp.pass b/build/test/results/test_exp.pass index 3ded7e7..fdf3867 100644 --- a/build/test/results/test_exp.pass +++ b/build/test/results/test_exp.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0007849170069675893 +:time: 0.0007327220228035003 diff --git a/build/test/results/test_factorial.pass b/build/test/results/test_factorial.pass index 491fa0e..15ad9e6 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.0008006019925232977 +:time: 0.0007816760044079274 diff --git a/build/test/results/test_floor.pass b/build/test/results/test_floor.pass index 65724d1..2313cc8 100644 --- a/build/test/results/test_floor.pass +++ b/build/test/results/test_floor.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0008028629817999899 +:time: 0.000812580983620137 diff --git a/build/test/results/test_log.pass b/build/test/results/test_log.pass index c62a469..73dcd04 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.0008077079837676138 +:time: 0.0007323859899770468 diff --git a/build/test/results/test_mod.pass b/build/test/results/test_mod.pass index 7d46b17..2353f3e 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.0007552629976999015 +:time: 0.0007842250051908195 diff --git a/build/test/results/test_multiply.pass b/build/test/results/test_multiply.pass index aa88c57..634f109 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.0006735950009897351 +:time: 0.0007811810064595193 diff --git a/build/test/results/test_pow.pass b/build/test/results/test_pow.pass index aeb709f..48c8c2e 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.0007900650089140981 +:time: 0.0008296039886772633 diff --git a/build/test/results/test_round.pass b/build/test/results/test_round.pass new file mode 100644 index 0000000..e594301 --- /dev/null +++ b/build/test/results/test_round.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Calculator + :file: test_round.c +:successes: +- :test: test_round + :line: 13 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.003075557993724942 diff --git a/build/test/results/test_sin.pass b/build/test/results/test_sin.pass index ea69a8c..d11e16c 100644 --- a/build/test/results/test_sin.pass +++ b/build/test/results/test_sin.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0007269970083143562 +:time: 0.0007345140038523823 diff --git a/build/test/results/test_sqrt.pass b/build/test/results/test_sqrt.pass index 8c219ea..f392172 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.0009588460088707507 +:time: 0.000786467018770054 diff --git a/build/test/results/test_subtract.pass b/build/test/results/test_subtract.pass index 4229a47..6bf58d8 100644 --- a/build/test/results/test_subtract.pass +++ b/build/test/results/test_subtract.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.0007894229784142226 +:time: 0.0007993110048118979 diff --git a/build/test/runners/test_round_runner.c b/build/test/runners/test_round_runner.c new file mode 100644 index 0000000..fa9b37e --- /dev/null +++ b/build/test/runners/test_round_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_round(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_round.c"); + run_test(test_round, "test_round", 13); + + return UnityEnd(); +} diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 8c9fd42..158e404 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -23,6 +23,7 @@ int subtract(int num1, int num2); double exp(double num1); double ceil(double num1); double floor(double num1); +double round(double num1); int calculator() { int choice; @@ -85,6 +86,7 @@ double floor(double num1); printf("20. Ceil\n"); printf("21. Exponent\n"); printf("22. Floor\n"); + printf("23. Round\n"); // printf("21. Exit\n"); } @@ -135,6 +137,8 @@ double floor(double num1); return 0; exp(num1); case 22: return 0; floor(num1); + case 23: + return 0; round(num1); default: return 0.0; } @@ -223,3 +227,7 @@ double floor(double num1) double result = num1; return result = num1; } +double round(double num1){ + double result = num1; + return result; +} diff --git a/src/main/c/Calculator/calculator.h b/src/main/c/Calculator/calculator.h index ade5e7c..5f84cda 100644 --- a/src/main/c/Calculator/calculator.h +++ b/src/main/c/Calculator/calculator.h @@ -15,4 +15,5 @@ int subtract(int num1, int num2); double exp(double num1); double ceil(double num1); double floor(double num1); +double round(double num1); #endif diff --git a/test/Calculator/test_round.c b/test/Calculator/test_round.c new file mode 100644 index 0000000..568185e --- /dev/null +++ b/test/Calculator/test_round.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_round(void){ + /* arrange */ + double num1= 3.7; + double result; + double rounding = round(num1); + + /* act */ + result = rounding; + + /* assert */ + TEST_ASSERT_EQUAL_INT(3, result);// round(3.7) = 4 + } + #endif // TEST