diff --git a/build/test/cache/input.yml b/build/test/cache/input.yml index bd75b60..eefbd61 100644 --- a/build/test/cache/input.yml +++ b/build/test/cache/input.yml @@ -77,10 +77,10 @@ :testfail: ".fail" :dependencies: ".d" :unity: - :vendor_path: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor + :vendor_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor :defines: [] :cmock: - :vendor_path: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor + :vendor_path: C:/Ruby30-x64/lib/ruby/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: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor + :vendor_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor :defines: [] :test_runner: :includes: [] @@ -223,13 +223,13 @@ :arguments: [] :plugins: :load_paths: - - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins + - C:/Ruby30-x64/lib/ruby/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: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report - :module_generator_path: C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator + :stdout_pretty_tests_report_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report + :module_generator_path: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator :gcov: :reports: - HtmlDetailed diff --git a/build/test/cache/test_schach.c b/build/test/cache/test_schach.c index 4a8462d..daa4e97 100644 --- a/build/test/cache/test_schach.c +++ b/build/test/cache/test_schach.c @@ -1,5 +1,7 @@ #include "src/schach.h" -#include "C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + @@ -48,12 +50,98 @@ void test_print_Schachfeld(void){ ((void *)0) - ), (UNITY_UINT)(25), UNITY_DISPLAY_STYLE_CHAR); + ), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR); UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[1][0])), ( ((void *)0) - ), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR); + ), (UNITY_UINT)(27), UNITY_DISPLAY_STYLE_CHAR); + +} + + + +void test_read_input(void) { + + + + const char *input = "8\n"; + + int result = 0; + + int expected = 7; + + + + FILE *original_stdin = freopen( + + ((void *)0) + + , "r", + + (__acrt_iob_func(0)) + + ); + + + + + + FILE *tempInput = fopen("temp_input.txt", "w"); + + fputs(input, tempInput); + + fclose(tempInput); + + + + tempInput = freopen("temp_input.txt", "r", + + (__acrt_iob_func(0)) + + ); + + + + + + result = read_input(); + + + + + + UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT); + + + + + + fclose(tempInput); + + freopen("/dev/tty", "r", + + (__acrt_iob_func(0)) + + ); + + + + + + freopen( + + ((void *)0) + + , "r", + + (__acrt_iob_func(0)) + + ); } diff --git a/build/test/dependencies/cmock.d b/build/test/dependencies/cmock.d index a9317fd..bdf4cc9 100644 --- a/build/test/dependencies/cmock.d +++ b/build/test/dependencies/cmock.d @@ -1,6 +1,6 @@ build/test/out/c/cmock.o: \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h 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_schach.d b/build/test/dependencies/test_schach.d index fcec89b..3ac337a 100644 --- a/build/test/dependencies/test_schach.d +++ b/build/test/dependencies/test_schach.d @@ -1,4 +1,4 @@ build/test/out/c/test_schach.o: test/test_schach.c \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ src/schach.h diff --git a/build/test/dependencies/test_schach_runner.d b/build/test/dependencies/test_schach_runner.d index 4b8c6f3..50c9dad 100644 --- a/build/test/dependencies/test_schach_runner.d +++ b/build/test/dependencies/test_schach_runner.d @@ -1,4 +1,4 @@ build/test/out/c/test_schach_runner.o: \ build/test/runners/test_schach_runner.c \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/unity.d b/build/test/dependencies/unity.d index 25fa920..0baf56c 100644 --- a/build/test/dependencies/unity.d +++ b/build/test/dependencies/unity.d @@ -1,4 +1,4 @@ build/test/out/c/unity.o: \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.c \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ - C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.c \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/out/c/cmock.o b/build/test/out/c/cmock.o index f147b87..b1d3bb2 100644 Binary files a/build/test/out/c/cmock.o and b/build/test/out/c/cmock.o differ diff --git a/build/test/out/c/schach.o b/build/test/out/c/schach.o index 5c3adb3..94a1f10 100644 Binary files a/build/test/out/c/schach.o and b/build/test/out/c/schach.o differ diff --git a/build/test/out/c/test_schach.o b/build/test/out/c/test_schach.o index fcd49e4..0cf527d 100644 Binary files a/build/test/out/c/test_schach.o and b/build/test/out/c/test_schach.o differ diff --git a/build/test/out/c/test_schach_runner.o b/build/test/out/c/test_schach_runner.o index 96c8e2e..f76f87c 100644 Binary files a/build/test/out/c/test_schach_runner.o and b/build/test/out/c/test_schach_runner.o differ diff --git a/build/test/out/c/unity.o b/build/test/out/c/unity.o index cd084ef..6b77b10 100644 Binary files a/build/test/out/c/unity.o and b/build/test/out/c/unity.o differ diff --git a/build/test/out/test_schach.out b/build/test/out/test_schach.out index 5a8c580..f66bc9a 100644 Binary files a/build/test/out/test_schach.out and b/build/test/out/test_schach.out differ diff --git a/build/test/preprocess/files/test_schach.c b/build/test/preprocess/files/test_schach.c index 4a8462d..daa4e97 100644 --- a/build/test/preprocess/files/test_schach.c +++ b/build/test/preprocess/files/test_schach.c @@ -1,5 +1,7 @@ #include "src/schach.h" -#include "C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + @@ -48,12 +50,98 @@ void test_print_Schachfeld(void){ ((void *)0) - ), (UNITY_UINT)(25), UNITY_DISPLAY_STYLE_CHAR); + ), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR); UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[1][0])), ( ((void *)0) - ), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR); + ), (UNITY_UINT)(27), UNITY_DISPLAY_STYLE_CHAR); + +} + + + +void test_read_input(void) { + + + + const char *input = "8\n"; + + int result = 0; + + int expected = 7; + + + + FILE *original_stdin = freopen( + + ((void *)0) + + , "r", + + (__acrt_iob_func(0)) + + ); + + + + + + FILE *tempInput = fopen("temp_input.txt", "w"); + + fputs(input, tempInput); + + fclose(tempInput); + + + + tempInput = freopen("temp_input.txt", "r", + + (__acrt_iob_func(0)) + + ); + + + + + + result = read_input(); + + + + + + UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT); + + + + + + fclose(tempInput); + + freopen("/dev/tty", "r", + + (__acrt_iob_func(0)) + + ); + + + + + + freopen( + + ((void *)0) + + , "r", + + (__acrt_iob_func(0)) + + ); } diff --git a/build/test/preprocess/includes/test_schach.c b/build/test/preprocess/includes/test_schach.c index 2b6bf90..c2933ab 100644 --- a/build/test/preprocess/includes/test_schach.c +++ b/build/test/preprocess/includes/test_schach.c @@ -1,3 +1,3 @@ --- -- C:/Ruby30/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h +- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h - src/schach.h diff --git a/build/test/results/test_schach.pass b/build/test/results/test_schach.pass index 5d21e1e..2061b09 100644 --- a/build/test/results/test_schach.pass +++ b/build/test/results/test_schach.pass @@ -4,15 +4,19 @@ :file: test_schach.c :successes: - :test: test_print_Schachfeld - :line: 15 + :line: 16 + :message: '' + :unity_test_time: 0 +- :test: test_read_input + :line: 30 :message: '' :unity_test_time: 0 :failures: [] :ignores: [] :counts: - :total: 1 - :passed: 1 + :total: 2 + :passed: 2 :failed: 0 :ignored: 0 :stdout: [] -:time: 0.13277340000058757 +:time: 0.06211079999047797 diff --git a/build/test/runners/test_schach_runner.c b/build/test/runners/test_schach_runner.c index 7f30dfb..a6f58a7 100644 --- a/build/test/runners/test_schach_runner.c +++ b/build/test/runners/test_schach_runner.c @@ -11,6 +11,7 @@ char* GlobalOrderError; extern void setUp(void); extern void tearDown(void); extern void test_print_Schachfeld(void); +extern void test_read_input(void); /*=======Mock Management=====*/ @@ -75,7 +76,8 @@ static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE l int main(void) { UnityBegin("test_schach.c"); - run_test(test_print_Schachfeld, "test_print_Schachfeld", 15); + run_test(test_print_Schachfeld, "test_print_Schachfeld", 16); + run_test(test_read_input, "test_read_input", 30); return UnityEnd(); } diff --git a/src/schach.c b/src/schach.c index 4370698..47adeca 100644 --- a/src/schach.c +++ b/src/schach.c @@ -36,6 +36,37 @@ 8.Schritt 2-8 wird Wiederholt */ +int read_input(){ + + int koordinate = 0; + + scanf("%d", &koordinate); + + if(koordinate < 9){ + return koordinate - 1; + } + else{ + + + + } + +} + +void choose_Figur(){ + + int x,y; + + printf("X-Koordinaten der Figur der bewegt werden soll eingeben:\n"); + + + x = read_input(); + + printf("X-Koordinaten der Figur der bewegt werden soll eingeben:\n"); + + y = read_input(); + +} void print_Schachfeld(char** Spielfeld, int x, int y) { for (int i = 0; i < x; i++) { @@ -70,7 +101,6 @@ void free_Schachfeld(char** Spielfeld, int x) { free(Spielfeld); } - /* int main() { int x = 8; @@ -83,5 +113,4 @@ int main() { return 0; } - -*/ \ No newline at end of file +*/ diff --git a/src/schach.h b/src/schach.h index 3f6fb6e..7b83d22 100644 --- a/src/schach.h +++ b/src/schach.h @@ -5,4 +5,9 @@ void print_Schachfeld(char** , int , int ); char** create_Schachfeld(int , int ); void free_Schachfeld(char** , int ); -#endif \ No newline at end of file +int read_input(); +void choose_Figur(); + + + +#endif diff --git a/temp_input.txt b/temp_input.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/temp_input.txt @@ -0,0 +1 @@ +8 diff --git a/test/test_schach.c b/test/test_schach.c index 35a1190..5e3489e 100644 --- a/test/test_schach.c +++ b/test/test_schach.c @@ -4,6 +4,7 @@ #include "schach.h" +#include "string.h" void setUp(void) { } @@ -26,4 +27,34 @@ void test_print_Schachfeld(void){ TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[1][0]); } +void test_read_input(void) { + /* arrange */ + const char *input = "8\n"; + int result = 0; + int expected = 7; + + FILE *original_stdin = freopen(NULL, "r", stdin); + + + FILE *tempInput = fopen("temp_input.txt", "w"); + fputs(input, tempInput); + fclose(tempInput); + + tempInput = freopen("temp_input.txt", "r", stdin); + + /* act */ + result = read_input(); + + /* assert */ + TEST_ASSERT_EQUAL_INT(expected, result); + + /* Clean up */ + fclose(tempInput); + freopen("/dev/tty", "r", stdin); + + + freopen(NULL, "r", stdin); +} + #endif // TEST +