diff --git a/And b/And new file mode 100644 index 0000000..e69de29 diff --git a/Shell b/Shell new file mode 100644 index 0000000..e69de29 diff --git a/build/release/dependencies/force_build b/build/release/dependencies/force_build new file mode 100644 index 0000000..e69de29 diff --git a/build/release/dependencies/top.d b/build/release/dependencies/top.d new file mode 100644 index 0000000..02e77a3 --- /dev/null +++ b/build/release/dependencies/top.d @@ -0,0 +1 @@ +build/release/out/c/top.o: src/main/c/Quiz/top.c diff --git a/build/release/out/c/top.o b/build/release/out/c/top.o new file mode 100644 index 0000000..2c44dbf Binary files /dev/null and b/build/release/out/c/top.o differ diff --git a/build/test/cache/defines_dependency.yml b/build/test/cache/defines_dependency.yml index 6dae52a..d0eaec9 100644 --- a/build/test/cache/defines_dependency.yml +++ b/build/test/cache/defines_dependency.yml @@ -1,6 +1,9 @@ --- src/main/c/Template/game100.c: - TEST +<<<<<<< HEAD +src/main/c/Calculator/calculator.c: +======= src/main/c/Snake/snake_start.c: - TEST src/main/c/Snake/get_character.c: @@ -10,4 +13,5 @@ src/main/c/Minesweeper/minesweeper_start.c: src/main/c/GameTic_Tac_Toe/tictactoe.c: - TEST src/main/c/Pong/pong.c: +>>>>>>> 2acead7a056f156a3c7129d740f7d5585fbc805f - TEST diff --git a/build/test/cache/input.yml b/build/test/cache/input.yml index 1bace5f..97834b0 100644 --- a/build/test/cache/input.yml +++ b/build/test/cache/input.yml @@ -77,10 +77,10 @@ :testfail: ".fail" :dependencies: ".d" :unity: - :vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor" + :vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor" :defines: [] :cmock: - :vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor" + :vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor" :defines: [] :includes: [] :mock_prefix: mock_ @@ -99,7 +99,7 @@ :verbosity: 3 :unity_helper: false :cexception: - :vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor" + :vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor" :defines: [] :test_runner: :includes: [] @@ -257,13 +257,13 @@ :arguments: [] :plugins: :load_paths: - - "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins" + - "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins" :enabled: - stdout_pretty_tests_report - module_generator :display_raw_test_results: false - :stdout_pretty_tests_report_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report" - :module_generator_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins/module_generator" + :stdout_pretty_tests_report_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report" + :module_generator_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator" :gcov: :reports: - HtmlDetailed diff --git a/build/test/cache/test_add.c b/build/test/cache/test_add.c new file mode 100644 index 0000000..fe4db9b --- /dev/null +++ b/build/test/cache/test_add.c @@ -0,0 +1,79 @@ +#include "build/temp/../../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_pow_N_N(void){ + + + + double result; + + double b = 3; + + double a = 3; + + + + + + result = pow(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_pow_Z_N(void){ + + + + double result; + + double b = 3; + + double a = -3; + + + + + + result = pow(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/cache/test_factorial.c b/build/test/cache/test_factorial.c new file mode 100644 index 0000000..debbcbf --- /dev/null +++ b/build/test/cache/test_factorial.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_factorial_4(void){ + + + + double result; + + double a = 4; + + + + + + result = factorial(a); + + + + + + UnityAssertEqualNumber((UNITY_INT)((24)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/cache/test_pow.c b/build/test/cache/test_pow.c new file mode 100644 index 0000000..fe4db9b --- /dev/null +++ b/build/test/cache/test_pow.c @@ -0,0 +1,79 @@ +#include "build/temp/../../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_pow_N_N(void){ + + + + double result; + + double b = 3; + + double a = 3; + + + + + + result = pow(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_pow_Z_N(void){ + + + + double result; + + double b = 3; + + double a = -3; + + + + + + result = pow(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/cache/test_template.c b/build/test/cache/test_template.c index d967090..0380b7b 100644 --- a/build/test/cache/test_template.c +++ b/build/test/cache/test_template.c @@ -1,5 +1,5 @@ #include "src/main/c/Template/game100.h" -#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" diff --git a/build/test/dependencies/calculator.d b/build/test/dependencies/calculator.d new file mode 100644 index 0000000..65603fc --- /dev/null +++ b/build/test/dependencies/calculator.d @@ -0,0 +1 @@ +build/test/out/c/calculator.o: src/main/c/Calculator/calculator.c diff --git a/build/test/dependencies/force_build b/build/test/dependencies/force_build new file mode 100644 index 0000000..e69de29 diff --git a/build/test/dependencies/test_add.d b/build/test/dependencies/test_add.d new file mode 100644 index 0000000..2d698f4 --- /dev/null +++ b/build/test/dependencies/test_add.d @@ -0,0 +1,4 @@ +build/test/out/c/test_add.o: test/Calculator/test_add.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 \ + test/Calculator/../../src/main/c/Calculator/calculator.h diff --git a/build/test/dependencies/test_add_runner.d b/build/test/dependencies/test_add_runner.d new file mode 100644 index 0000000..e3f0886 --- /dev/null +++ b/build/test/dependencies/test_add_runner.d @@ -0,0 +1,3 @@ +build/test/out/c/test_add_runner.o: build/test/runners/test_add_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/dependencies/test_factorial.d b/build/test/dependencies/test_factorial.d new file mode 100644 index 0000000..11420b1 --- /dev/null +++ b/build/test/dependencies/test_factorial.d @@ -0,0 +1,4 @@ +build/test/out/c/test_factorial.o: test/Calculator/test_factorial.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_factorial_runner.d b/build/test/dependencies/test_factorial_runner.d new file mode 100644 index 0000000..961d380 --- /dev/null +++ b/build/test/dependencies/test_factorial_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_factorial_runner.o: \ + build/test/runners/test_factorial_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/dependencies/test_pow.d b/build/test/dependencies/test_pow.d new file mode 100644 index 0000000..d76ecae --- /dev/null +++ b/build/test/dependencies/test_pow.d @@ -0,0 +1,4 @@ +build/test/out/c/test_pow.o: test/Calculator/test_pow.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 \ + test/Calculator/../../src/main/c/Calculator/calculator.h diff --git a/build/test/dependencies/test_pow_runner.d b/build/test/dependencies/test_pow_runner.d new file mode 100644 index 0000000..d2634ed --- /dev/null +++ b/build/test/dependencies/test_pow_runner.d @@ -0,0 +1,3 @@ +build/test/out/c/test_pow_runner.o: build/test/runners/test_pow_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/dependencies/test_template_runner.d b/build/test/dependencies/test_template_runner.d index c4140c0..8073f33 100644 --- a/build/test/dependencies/test_template_runner.d +++ b/build/test/dependencies/test_template_runner.d @@ -1,4 +1,4 @@ build/test/out/c/test_template_runner.o: \ build/test/runners/test_template_runner.c \ - /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ - /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h + /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 new file mode 100644 index 0000000..b3aa454 Binary files /dev/null and b/build/test/out/c/calculator.o differ diff --git a/build/test/out/c/test_add.o b/build/test/out/c/test_add.o new file mode 100644 index 0000000..463b836 Binary files /dev/null and b/build/test/out/c/test_add.o differ diff --git a/build/test/out/c/test_add_runner.o b/build/test/out/c/test_add_runner.o new file mode 100644 index 0000000..2d20162 Binary files /dev/null and b/build/test/out/c/test_add_runner.o differ diff --git a/build/test/out/c/test_factorial.o b/build/test/out/c/test_factorial.o new file mode 100644 index 0000000..ebb50e0 Binary files /dev/null and b/build/test/out/c/test_factorial.o differ diff --git a/build/test/out/c/test_factorial_runner.o b/build/test/out/c/test_factorial_runner.o new file mode 100644 index 0000000..121ea18 Binary files /dev/null and b/build/test/out/c/test_factorial_runner.o differ diff --git a/build/test/out/c/test_pow.o b/build/test/out/c/test_pow.o new file mode 100644 index 0000000..1a52535 Binary files /dev/null and b/build/test/out/c/test_pow.o differ diff --git a/build/test/out/c/test_pow_runner.o b/build/test/out/c/test_pow_runner.o new file mode 100644 index 0000000..7fec983 Binary files /dev/null and b/build/test/out/c/test_pow_runner.o differ diff --git a/build/test/out/c/test_template_runner.o b/build/test/out/c/test_template_runner.o index 2442d60..3c6beb1 100644 Binary files a/build/test/out/c/test_template_runner.o and b/build/test/out/c/test_template_runner.o differ diff --git a/build/test/out/test_add.out b/build/test/out/test_add.out new file mode 100755 index 0000000..f62e043 Binary files /dev/null and b/build/test/out/test_add.out differ diff --git a/build/test/out/test_factorial.out b/build/test/out/test_factorial.out new file mode 100755 index 0000000..b7a6cec Binary files /dev/null and b/build/test/out/test_factorial.out differ diff --git a/build/test/out/test_pow.out b/build/test/out/test_pow.out new file mode 100755 index 0000000..1572d74 Binary files /dev/null and b/build/test/out/test_pow.out differ diff --git a/build/test/out/test_template.out b/build/test/out/test_template.out index 8156bef..69915c0 100755 Binary files a/build/test/out/test_template.out and b/build/test/out/test_template.out differ diff --git a/build/test/preprocess/files/test_add.c b/build/test/preprocess/files/test_add.c new file mode 100644 index 0000000..fe4db9b --- /dev/null +++ b/build/test/preprocess/files/test_add.c @@ -0,0 +1,79 @@ +#include "build/temp/../../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_pow_N_N(void){ + + + + double result; + + double b = 3; + + double a = 3; + + + + + + result = pow(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_pow_Z_N(void){ + + + + double result; + + double b = 3; + + double a = -3; + + + + + + result = pow(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/files/test_factorial.c b/build/test/preprocess/files/test_factorial.c new file mode 100644 index 0000000..debbcbf --- /dev/null +++ b/build/test/preprocess/files/test_factorial.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_factorial_4(void){ + + + + double result; + + double a = 4; + + + + + + result = factorial(a); + + + + + + UnityAssertEqualNumber((UNITY_INT)((24)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/files/test_pow.c b/build/test/preprocess/files/test_pow.c new file mode 100644 index 0000000..fe4db9b --- /dev/null +++ b/build/test/preprocess/files/test_pow.c @@ -0,0 +1,79 @@ +#include "build/temp/../../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_pow_N_N(void){ + + + + double result; + + double b = 3; + + double a = 3; + + + + + + result = pow(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_pow_Z_N(void){ + + + + double result; + + double b = 3; + + double a = -3; + + + + + + result = pow(a, b); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/files/test_template.c b/build/test/preprocess/files/test_template.c index d967090..0380b7b 100644 --- a/build/test/preprocess/files/test_template.c +++ b/build/test/preprocess/files/test_template.c @@ -1,5 +1,5 @@ #include "src/main/c/Template/game100.h" -#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" diff --git a/build/test/preprocess/includes/test_add.c b/build/test/preprocess/includes/test_add.c new file mode 100644 index 0000000..26256f2 --- /dev/null +++ b/build/test/preprocess/includes/test_add.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- build/temp/../../src/main/c/Calculator/calculator.h diff --git a/build/test/preprocess/includes/test_factorial.c b/build/test/preprocess/includes/test_factorial.c new file mode 100644 index 0000000..f2efae7 --- /dev/null +++ b/build/test/preprocess/includes/test_factorial.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/preprocess/includes/test_pow.c b/build/test/preprocess/includes/test_pow.c new file mode 100644 index 0000000..26256f2 --- /dev/null +++ b/build/test/preprocess/includes/test_pow.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- build/temp/../../src/main/c/Calculator/calculator.h diff --git a/build/test/preprocess/includes/test_template.c b/build/test/preprocess/includes/test_template.c index 2f39e86..e60bf2a 100644 --- a/build/test/preprocess/includes/test_template.c +++ b/build/test/preprocess/includes/test_template.c @@ -1,3 +1,3 @@ --- -- "/var/lib/gems/2.7.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.h" - src/main/c/Template/game100.h diff --git a/build/test/results/test_add.pass b/build/test/results/test_add.pass new file mode 100644 index 0000000..4deef9a --- /dev/null +++ b/build/test/results/test_add.pass @@ -0,0 +1,22 @@ +--- +:source: + :path: test/Calculator + :file: test_add.c +:successes: +- :test: test_pow_N_N + :line: 13 + :message: '' + :unity_test_time: 0 +- :test: test_pow_Z_N + :line: 26 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 2 + :passed: 2 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.007150935009121895 diff --git a/build/test/results/test_factorial.pass b/build/test/results/test_factorial.pass new file mode 100644 index 0000000..ede2338 --- /dev/null +++ b/build/test/results/test_factorial.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Calculator + :file: test_factorial.c +:successes: +- :test: test_factorial_4 + :line: 13 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0060175769904162735 diff --git a/build/test/results/test_pow.pass b/build/test/results/test_pow.pass new file mode 100644 index 0000000..d103a0d --- /dev/null +++ b/build/test/results/test_pow.pass @@ -0,0 +1,22 @@ +--- +:source: + :path: test/Calculator + :file: test_pow.c +:successes: +- :test: test_pow_N_N + :line: 13 + :message: '' + :unity_test_time: 0 +- :test: test_pow_Z_N + :line: 26 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 2 + :passed: 2 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0062921050121076405 diff --git a/build/test/results/test_template.pass b/build/test/results/test_template.pass index 44f5caa..296b3f1 100644 --- a/build/test/results/test_template.pass +++ b/build/test/results/test_template.pass @@ -19,4 +19,8 @@ :failed: 0 :ignored: 0 :stdout: [] +<<<<<<< HEAD +:time: 0.002953332004835829 +======= :time: 0.001957057000254281 +>>>>>>> 2acead7a056f156a3c7129d740f7d5585fbc805f diff --git a/build/test/runners/test_add_runner.c b/build/test/runners/test_add_runner.c new file mode 100644 index 0000000..6897488 --- /dev/null +++ b/build/test/runners/test_add_runner.c @@ -0,0 +1,83 @@ +/* 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_pow_N_N(void); +extern void test_pow_Z_N(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_add.c"); + run_test(test_pow_N_N, "test_pow_N_N", 13); + run_test(test_pow_Z_N, "test_pow_Z_N", 26); + + return UnityEnd(); +} diff --git a/build/test/runners/test_factorial_runner.c b/build/test/runners/test_factorial_runner.c new file mode 100644 index 0000000..3e02547 --- /dev/null +++ b/build/test/runners/test_factorial_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_factorial_4(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_factorial.c"); + run_test(test_factorial_4, "test_factorial_4", 13); + + return UnityEnd(); +} diff --git a/build/test/runners/test_pow_runner.c b/build/test/runners/test_pow_runner.c new file mode 100644 index 0000000..83a9119 --- /dev/null +++ b/build/test/runners/test_pow_runner.c @@ -0,0 +1,83 @@ +/* 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_pow_N_N(void); +extern void test_pow_Z_N(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_pow.c"); + run_test(test_pow_N_N, "test_pow_N_N", 13); + run_test(test_pow_Z_N, "test_pow_Z_N", 26); + + return UnityEnd(); +} diff --git a/src/main/c/Calculator/calculator.c b/src/main/c/Calculator/calculator.c new file mode 100644 index 0000000..95d3980 --- /dev/null +++ b/src/main/c/Calculator/calculator.c @@ -0,0 +1,158 @@ +#include +#define M_PI 3.14159265358979323 + + + // Function prototypes +void displayMenu(); +double performOperation(int choice, double num1, double num2); +double getDoubleInput(const char *message); +int getIntInput(const char *message); +double factorial(double num); +double permutation(int n, int r); +double combination(int n, int r); +double pow(double num1, double num2); + + int calculator() { + int choice; + double num1, num2, result; + + + do { + displayMenu(); + printf("Enter your choice: "); + scanf("%d", &choice); + if (choice >= 1 && choice <= 19) { + if (choice >= 9 && choice <= 17) { + num1 = getDoubleInput("Enter a number: "); + } else if (choice >= 1 && choice <= 8) { + printf("Enter two numbers: "); + scanf("%lf %lf", &num1, &num2); + } else if (choice == 18 || choice == 19) { + int n = getIntInput("Enter n: "); + int r = getIntInput("Enter r: "); + num1 = n; + num2 = r; + } + if (choice != 4 || (choice == 4 && num2 != 0)) { + result = performOperation(choice, num1, num2); + printf("Result: %.2lf\n", result); + } else { + printf("Error: Division by zero\n"); + } + } else if (choice != 20) { + printf("Invalid choice\n"); + } + } + + while (choice != 20); + + return 0; + } + // Function definitions + void displayMenu() { + printf("\nAdvaced Calculator\n"); + printf("1. Add\n"); + printf("2. Subtract\n"); + printf("3. Multiply\n"); + printf("4. Divide\n"); + printf("5. Exponentiation\n"); + printf("6. Modulus\n"); + printf("7. Logarithm\n"); + printf("8. Potential\n"); + printf("9. Square Root\n"); + printf("10. Square\n"); + printf("11. Cube\n"); + printf("12. Cube Root\n"); + printf("13. Factorial\n"); + printf("14. Power\n"); + printf("15. Sine\n"); + printf("16. Cosine\n"); + printf("17. Tangent\n"); + printf("18. Permutation\n"); + printf("19. Combination\n"); + printf("20. Exit\n"); + } + double performOperation(int choice, double num1, double num2) { + switch (choice) { + case 1: + return num1 + num2; + case 2: + return num1 - num2; + case 3: + return num1 * num2; + case 4: + return num1 / num2; + case 5: + return pow(num1, num2); + case 6: + return 0;// fmod(num1, num2); + case 7: + return 0;// log(num1); + case 8: + return pow(num1, num2); + case 9: + return 0;// sqrt(num1); + case 10: + return num1 * num1; + case 11: + return num1 * num1 * num1; + case 12: + return 0;// cbrt(num1); + case 13: + return factorial(num1); + case 14: + return pow(num1, num2); + case 15: + return 0;// sin(num1 * M_PI / 180.0); + case 16: + return 0;// cos(num1 * M_PI / 180.0); + case 17: + return 0;// tan(num1 * M_PI / 180.0); + + case 18: + return permutation((int)num1, (int)num2); + case 19: + return combination((int)num1, (int)num2); + default: + return 0.0; + } +} +double getDoubleInput(const char *message) { + double input; + printf("%s", message); + scanf("%lf", &input); + return input; +} +double factorial(double num) { + if (num == 0) { + return 1; + } else { + return num * factorial(num - 1); + } +} +double permutation(int n, int r) { + double result = 1; + for (int i = 0; i < r; i++) { + result *= (n - i); + } + return result; +} + +double combination(int n, int r) { + return permutation(n, r) / factorial(r); +} + +int getIntInput(const char *message) { + int input; + printf("%s", message); + scanf("%d", &input); + return input; +} + +double pow(double num1, double num2){ + double product = 1; + for(int i = 0; i < num2; i++){ + product *= num1; + } + return product; +} diff --git a/src/main/c/Calculator/calculator.exe b/src/main/c/Calculator/calculator.exe new file mode 100644 index 0000000..4ea5db5 Binary files /dev/null and b/src/main/c/Calculator/calculator.exe differ diff --git a/src/main/c/Calculator/calculator.h b/src/main/c/Calculator/calculator.h new file mode 100644 index 0000000..8d0213a --- /dev/null +++ b/src/main/c/Calculator/calculator.h @@ -0,0 +1,8 @@ +#ifndef CALCULATOR_H +#define CALCULATOR_H + +int calculator(); +double pow(double num1, double num2); +double factorial(double num); + +#endif diff --git a/src/main/c/Quiz/Quiz_2.c b/src/main/c/Quiz/Quiz_2.c new file mode 100644 index 0000000..0777a51 --- /dev/null +++ b/src/main/c/Quiz/Quiz_2.c @@ -0,0 +1,29 @@ +#include + +int quiz_2() +{ + int secretNumber=5; + int guess; + int guessCount = 0; + int guessLimit = 3; + int outOfGuesses =0; + + while (guess != secretNumber && outOfGuesses == 0) + { + if(guessCount < guessLimit) + { + printf("Enter a number: "); + scanf("%d",&guess); + guessCount++; + } else { + outOfGuesses = 1; + } + } + if (outOfGuesses == 1) + { + printf("Out of guesses"); + }else { + printf("You Win!"); + } + return 0; +} \ No newline at end of file diff --git a/src/main/c/Quiz/Quiz_2.h b/src/main/c/Quiz/Quiz_2.h new file mode 100644 index 0000000..b8a73d3 --- /dev/null +++ b/src/main/c/Quiz/Quiz_2.h @@ -0,0 +1,6 @@ +#ifndef QUIZ_2_H +#define QUIZ_2_H + +void quiz_2(); + +#endif //QUIZ_2_H diff --git a/src/main/c/Quiz/top.c b/src/main/c/Quiz/top.c new file mode 100644 index 0000000..a66ac28 --- /dev/null +++ b/src/main/c/Quiz/top.c @@ -0,0 +1,57 @@ +#include +#include +#include + +// Struktur für eine Frage im Quiz +struct Frage { + char text[100]; + char antwort1[50]; + char antwort2[50]; + char antwort3[50]; + int korrekteAntwort; +}; + +// Funktion, um eine Frage zu erstellen +struct Frage erstelleFrage(char *text, char *antwort1, char *antwort2, char *antwort3, int korrekteAntwort) { + struct Frage frage; + strcpy(frage.text, text); + strcpy(frage.antwort1, antwort1); + strcpy(frage.antwort2, antwort2); + strcpy(frage.antwort3, antwort3); + frage.korrekteAntwort = korrekteAntwort; + return frage; +} + +// Funktion, um eine Frage anzuzeigen und die Antwort des Benutzers zu überprüfen +int zeigeFrage(struct Frage frage) { + printf("%s\n", frage.text); + printf("1. %s\n", frage.antwort1); + printf("2. %s\n", frage.antwort2); + printf("3. %s\n", frage.antwort3); + + int benutzerAntwort; + printf("Deine Antwort (1, 2 oder 3): "); + scanf("%d", &benutzerAntwort); + + return (benutzerAntwort == frage.korrekteAntwort); +} + +int quiz() { + struct Frage fragen[3]; + fragen[0] = erstelleFrage("Was ist die Hauptstadt von Frankreich?", "Berlin", "Paris", "London", 2); + fragen[1] = erstelleFrage("Welches ist das groesste Saeugetier?", "Elefant", "Wal", "Giraffe", 2); + fragen[2] = erstelleFrage("Wer hat die Relativitaetstheorie entwickelt?", "Isaac Newton", "Albert Einstein", "Galileo Galilei", 2); + fragen[3] = erstelleFrage("Wer ist bundeskanzler?", "", "Thomas Mueller", "Olaf scholz", 2); + // Quiz starten + int punktzahl = 0; + int i; + for (i = 0; i < 4; i++) { + punktzahl +=zeigeFrage(fragen[i]); + + } + // Ergebnis anzeigen + printf("Deine Punktzahl: %d / %d\n", punktzahl, i); + + return 0; +} + diff --git a/src/main/c/Quiz/top.h b/src/main/c/Quiz/top.h new file mode 100644 index 0000000..291481a --- /dev/null +++ b/src/main/c/Quiz/top.h @@ -0,0 +1,7 @@ +#ifndef TOP_H +#define TOP_H + + +struct Frage erstelleFrage(char *text, char *antwort1, char *antwort2, char *antwort3, int korrekteAntwort); + +#endif //TOP_H diff --git a/src/main/c/main.c b/src/main/c/main.c index f501e07..b4f8192 100644 --- a/src/main/c/main.c +++ b/src/main/c/main.c @@ -2,7 +2,7 @@ #include #include - +#include "Quiz/top.h" #include "GameTic_Tac_Toe/tictactoe.h" #include "Snake/snake_start.h" #include "Minesweeper/minesweeper_start.h" @@ -23,7 +23,8 @@ int main(){ printf("\t2.Pong starten\n"); printf("\t3.Snake starten\n"); printf("\t4.tic_tac_toe starten\n"); - printf("\t5.battleship starten\n") + printf("\t5.battleship starten\n"); + printf("\t6.Quiz starten\n"); printf("\t7.Minesweeper starten\n"); printf("\t10.Exit\n"); @@ -46,6 +47,9 @@ int main(){ case 5: start_battleship(); break; + case 6: + quiz(); + break; case 7: minesweeper_start(); break; diff --git a/team.md b/team.md index 101d21f..035121d 100644 --- a/team.md +++ b/team.md @@ -4,4 +4,5 @@ - Ariana Ginju, fdai7775 - fdai7775, fdai7775 - Saba Fazlali, fdai7875 +- Ulriche Nguefack, fdai7899 - Nina Gärtner, fdai7729 diff --git a/test/Calculator/test_factorial.c b/test/Calculator/test_factorial.c new file mode 100644 index 0000000..28814dc --- /dev/null +++ b/test/Calculator/test_factorial.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_factorial_4(void){ + /* arrange */ + double result; + double a = 4; + + /* act */ + result = factorial(a); + + /* assert */ + TEST_ASSERT_EQUAL_INT(24, result);//1 * 2 * 3 * 4 = 24 +} + +#endif diff --git a/test/Calculator/test_pow.c b/test/Calculator/test_pow.c new file mode 100644 index 0000000..e6d3a56 --- /dev/null +++ b/test/Calculator/test_pow.c @@ -0,0 +1,40 @@ +#ifdef TEST +#include "unity.h" +#include "../../src/main/c/Calculator/calculator.h" + + +void setUp(void){ + //Wenn Funktion Vorraussetzungen braucht +} +void tearDown(void){ +} + + +void test_pow_N_N(void){ + /* arrange */ + double result; + double b = 3; + double a = 3; + + /* act */ + result = pow(a, b); + + /* assert */ + TEST_ASSERT_EQUAL_INT(27, result);//3 * 3 * 3 = 27 +} + +void test_pow_Z_N(void){ + /* arrange */ + double result; + double b = 3; + double a = -3; + + /* act */ + result = pow(a, b); + + /* assert */ + TEST_ASSERT_EQUAL_INT(-27, result);//3 * 3 * 3 = 27 +} + + +#endif // TEST