diff --git a/build/test/cache/test_floor.c b/build/test/cache/test_floor.c new file mode 100644 index 0000000..3c3b6e9 --- /dev/null +++ b/build/test/cache/test_floor.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_floor(void){ + + + + double result; + + double num1 = 7.12; + + + + + + result = floor(num1); + + + + + + UnityAssertEqualNumber((UNITY_INT)((7)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT); + + } diff --git a/build/test/dependencies/test_floor.d b/build/test/dependencies/test_floor.d new file mode 100644 index 0000000..527d3df --- /dev/null +++ b/build/test/dependencies/test_floor.d @@ -0,0 +1,4 @@ +build/test/out/c/test_floor.o: test/Calculator/test_floor.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_floor_runner.d b/build/test/dependencies/test_floor_runner.d new file mode 100644 index 0000000..8f9feeb --- /dev/null +++ b/build/test/dependencies/test_floor_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_floor_runner.o: \ + build/test/runners/test_floor_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 09d576e..969d601 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_floor.o b/build/test/out/c/test_floor.o new file mode 100644 index 0000000..8a82abd Binary files /dev/null and b/build/test/out/c/test_floor.o differ diff --git a/build/test/out/c/test_floor_runner.o b/build/test/out/c/test_floor_runner.o new file mode 100644 index 0000000..e509946 Binary files /dev/null and b/build/test/out/c/test_floor_runner.o differ diff --git a/build/test/out/test_cbrt.out b/build/test/out/test_cbrt.out index fbd0b0f..ccad744 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 5eeb363..0d50de2 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 3de8cac..927b7b5 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 7d815b7..0792c8b 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 c6ce908..746dba3 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 new file mode 100755 index 0000000..d4c118d Binary files /dev/null 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 03e1bb1..7d458b3 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 992a86e..0a228ea 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 77f31bc..b4cbf33 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_sin.out b/build/test/out/test_sin.out index d2ad1e5..79fe62e 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 48f9445..01297ae 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 6ecef9f..40585ad 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_floor.c b/build/test/preprocess/files/test_floor.c new file mode 100644 index 0000000..3c3b6e9 --- /dev/null +++ b/build/test/preprocess/files/test_floor.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_floor(void){ + + + + double result; + + double num1 = 7.12; + + + + + + result = floor(num1); + + + + + + UnityAssertEqualNumber((UNITY_INT)((7)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT); + + } diff --git a/build/test/preprocess/includes/test_floor.c b/build/test/preprocess/includes/test_floor.c new file mode 100644 index 0000000..f2efae7 --- /dev/null +++ b/build/test/preprocess/includes/test_floor.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 883ae89..7ddd2e2 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.0018099159933626652 +:time: 0.0006380429840646684 diff --git a/build/test/results/test_cbrt.pass b/build/test/results/test_cbrt.pass index 1b12f22..ad2fbeb 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.003295011993031949 +:time: 0.00398757797665894 diff --git a/build/test/results/test_ceil.pass b/build/test/results/test_ceil.pass index 777c78b..93a1388 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.0024341249954886734 +:time: 0.0025626359856687486 diff --git a/build/test/results/test_divide.pass b/build/test/results/test_divide.pass index 0152d06..e1b2839 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.0008051539771258831 +:time: 0.0024843739811331034 diff --git a/build/test/results/test_exp.pass b/build/test/results/test_exp.pass index e440ddf..30803a2 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.0007799550076015294 +:time: 0.006211458996403962 diff --git a/build/test/results/test_factorial.pass b/build/test/results/test_factorial.pass index 2eab401..12f9774 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.0007686699973419309 +:time: 0.002500028000213206 diff --git a/build/test/results/test_floor.pass b/build/test/results/test_floor.pass new file mode 100644 index 0000000..63b398c --- /dev/null +++ b/build/test/results/test_floor.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Calculator + :file: test_floor.c +:successes: +- :test: test_floor + :line: 13 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.006380289007211104 diff --git a/build/test/results/test_log.pass b/build/test/results/test_log.pass index a79724f..5aecf82 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.0007523740059696138 +:time: 0.006268427998293191 diff --git a/build/test/results/test_mod.pass b/build/test/results/test_mod.pass index ee37bf5..a4b4557 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.0007482499931938946 +:time: 0.0073656839958857745 diff --git a/build/test/results/test_multiply.pass b/build/test/results/test_multiply.pass index 31c798f..cfbea19 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.0014812659937888384 +:time: 0.00431214299169369 diff --git a/build/test/results/test_pow.pass b/build/test/results/test_pow.pass index 4298c88..ce070f9 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.0008077819948084652 +:time: 0.006361996987834573 diff --git a/build/test/results/test_sin.pass b/build/test/results/test_sin.pass index 87b1819..cbd60c4 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.0007749740034341812 +:time: 0.005958255002042279 diff --git a/build/test/results/test_sqrt.pass b/build/test/results/test_sqrt.pass index 03bf298..fe427fb 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.0007332070090342313 +:time: 0.006205737998243421 diff --git a/build/test/results/test_subtract.pass b/build/test/results/test_subtract.pass index b0101cc..8264682 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.0008089379989542067 +:time: 0.00599369901465252 diff --git a/build/test/runners/test_floor_runner.c b/build/test/runners/test_floor_runner.c new file mode 100644 index 0000000..81436c8 --- /dev/null +++ b/build/test/runners/test_floor_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_floor(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_floor.c"); + run_test(test_floor, "test_floor", 13); + + return UnityEnd(); +} diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c index 39a7999..8c9fd42 100644 --- a/src/main/c/Calculator/calculator.c +++ b/src/main/c/Calculator/calculator.c @@ -22,7 +22,7 @@ int add (int num1, int num2); int subtract(int num1, int num2); double exp(double num1); double ceil(double num1); - +double floor(double num1); int calculator() { int choice; @@ -84,6 +84,7 @@ double ceil(double num1); printf("19. Combination\n"); printf("20. Ceil\n"); printf("21. Exponent\n"); + printf("22. Floor\n"); // printf("21. Exit\n"); } @@ -132,6 +133,8 @@ double ceil(double num1); return 0; ceil(num1); case 21: return 0; exp(num1); + case 22: + return 0; floor(num1); default: return 0.0; } @@ -215,3 +218,8 @@ double ceil(double num1){ double result = num1; return result; } +double floor(double num1) +{ + double result = num1; + return result = num1; +} diff --git a/src/main/c/Calculator/calculator.h b/src/main/c/Calculator/calculator.h index 9ce5ddb..ade5e7c 100644 --- a/src/main/c/Calculator/calculator.h +++ b/src/main/c/Calculator/calculator.h @@ -14,4 +14,5 @@ int add(int num1 ,int num2); int subtract(int num1, int num2); double exp(double num1); double ceil(double num1); +double floor(double num1); #endif diff --git a/test/Calculator/test_floor.c b/test/Calculator/test_floor.c new file mode 100644 index 0000000..17704c6 --- /dev/null +++ b/test/Calculator/test_floor.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_floor(void){ + /* arrange */ + double result; + double num1 = 7.12; + + /* act */ + result = floor(num1); + + /* assert */ + TEST_ASSERT_EQUAL_INT(7, result);// floor(7.12) = 7 + } + + #endif // TEST