diff --git a/.vscode/settings.json b/.vscode/settings.json index d7c26cd..73973d9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,60 @@ { "C_Cpp.dimInactiveRegions": false, - "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat" + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false } \ No newline at end of file diff --git a/build/artifacts/test/report.xml b/build/artifacts/test/report.xml index 16fbe75..a4b9029 100644 --- a/build/artifacts/test/report.xml +++ b/build/artifacts/test/report.xml @@ -6,27 +6,30 @@ test/test_Bauer.c::test_Bauer_X_Bewegung - test/test_Bauer.c::test_Bauer_Y_Bewegung + test/test_Bauer.c::test_Bauer_Schlag_Bewegung - test/test_Bauer.c::test_Bauer_Start_Bewegung + test/test_Bauer.c::test_Bauer_Y_Bewegung - test/test_Input.c::test_getUserInput + test/test_Bauer.c::test_Bauer_Start_Bewegung - test/test_Moving.c::test_Bauern_bewegen + test/test_Input.c::test_getUserInput - test/test_Moving.c::test_istzugerlaubt + test/test_Moving.c::test_Bauern_bewegen + test/test_Moving.c::test_istzugerlaubt + + test/test_Schachbrett.c::test_Schachbrett_erstellen - 7 + 8 0 0 0 diff --git a/build/test/cache/test_Bauer.c b/build/test/cache/test_Bauer.c index 0a83a79..370c05b 100644 --- a/build/test/cache/test_Bauer.c +++ b/build/test/cache/test_Bauer.c @@ -56,6 +56,62 @@ void test_Bauer_X_Bewegung(void) { + for (int i = 0; i < 8; i++) { + + free(brett[i]); + + } + + free(brett); + +} + + + +void test_Bauer_Schlag_Bewegung(void) { + + + + char** brett = Schachbrett_erstellen(); + + int startX = 6; + + int startY = 2; + + int endX = 5; + + int endY = 3; + + Player player = PLAYER_WHITE; + + + + + + do {if ((((brett)) != + + ((void *)0) + + )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(46))));}} while(0); + + + + brett[startY][startX] = 'P'; + + brett[endY][endX] = 'p'; + + + + print_Schachfeld(brett,8,8); + + + + do {if (!(istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(53)));}} while(0); + + + + + for (int i = 0; i < 8; i++) { free(brett[i]); @@ -94,13 +150,13 @@ void test_Bauer_Y_Bewegung(void) { ((void *)0) - )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(47))));}} while(0); + )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(73))));}} while(0); - do {if ((istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(50)));}} while(0); + do {if ((istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(76)));}} while(0); @@ -142,13 +198,13 @@ void test_Bauer_Start_Bewegung(void) { ((void *)0) - )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(69))));}} while(0); + )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(95))));}} while(0); - do {if ((istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(72)));}} while(0); + do {if ((istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(98)));}} while(0); diff --git a/build/test/out/c/Bauer.o b/build/test/out/c/Bauer.o index 086ac98..5efc50b 100644 Binary files a/build/test/out/c/Bauer.o and b/build/test/out/c/Bauer.o differ diff --git a/build/test/out/c/test_Bauer.o b/build/test/out/c/test_Bauer.o index 6f980a0..49cef52 100644 Binary files a/build/test/out/c/test_Bauer.o and b/build/test/out/c/test_Bauer.o differ diff --git a/build/test/out/c/test_Bauer_runner.o b/build/test/out/c/test_Bauer_runner.o index 75a6533..0b00d2c 100644 Binary files a/build/test/out/c/test_Bauer_runner.o and b/build/test/out/c/test_Bauer_runner.o differ diff --git a/build/test/out/test_Bauer.out b/build/test/out/test_Bauer.out index 89bd190..ebeca7d 100644 Binary files a/build/test/out/test_Bauer.out and b/build/test/out/test_Bauer.out differ diff --git a/build/test/preprocess/files/test_Bauer.c b/build/test/preprocess/files/test_Bauer.c index 0a83a79..370c05b 100644 --- a/build/test/preprocess/files/test_Bauer.c +++ b/build/test/preprocess/files/test_Bauer.c @@ -56,6 +56,62 @@ void test_Bauer_X_Bewegung(void) { + for (int i = 0; i < 8; i++) { + + free(brett[i]); + + } + + free(brett); + +} + + + +void test_Bauer_Schlag_Bewegung(void) { + + + + char** brett = Schachbrett_erstellen(); + + int startX = 6; + + int startY = 2; + + int endX = 5; + + int endY = 3; + + Player player = PLAYER_WHITE; + + + + + + do {if ((((brett)) != + + ((void *)0) + + )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(46))));}} while(0); + + + + brett[startY][startX] = 'P'; + + brett[endY][endX] = 'p'; + + + + print_Schachfeld(brett,8,8); + + + + do {if (!(istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(53)));}} while(0); + + + + + for (int i = 0; i < 8; i++) { free(brett[i]); @@ -94,13 +150,13 @@ void test_Bauer_Y_Bewegung(void) { ((void *)0) - )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(47))));}} while(0); + )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(73))));}} while(0); - do {if ((istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(50)));}} while(0); + do {if ((istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(76)));}} while(0); @@ -142,13 +198,13 @@ void test_Bauer_Start_Bewegung(void) { ((void *)0) - )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(69))));}} while(0); + )) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(95))));}} while(0); - do {if ((istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(72)));}} while(0); + do {if ((istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(98)));}} while(0); diff --git a/build/test/results/test_Bauer.pass b/build/test/results/test_Bauer.pass index 17e6903..cd18e6d 100644 --- a/build/test/results/test_Bauer.pass +++ b/build/test/results/test_Bauer.pass @@ -7,20 +7,32 @@ :line: 14 :message: '' :unity_test_time: 0 +- :test: test_Bauer_Schlag_Bewegung + :line: 36 + :message: '' + :unity_test_time: 0 - :test: test_Bauer_Y_Bewegung - :line: 37 + :line: 63 :message: '' :unity_test_time: 0 - :test: test_Bauer_Start_Bewegung - :line: 59 + :line: 85 :message: '' :unity_test_time: 0 :failures: [] :ignores: [] :counts: - :total: 3 - :passed: 3 + :total: 4 + :passed: 4 :failed: 0 :ignored: 0 -:stdout: [] -:time: 1.2243709999602288 +:stdout: +- " R N B Q K B N R " +- " P P P P P P P P " +- " P " +- " p " +- " " +- " " +- " p p p p p p p p " +- " r n b q k b n r " +:time: 0.10874160006642342 diff --git a/build/test/results/test_Input.pass b/build/test/results/test_Input.pass index e05cdc5..791a663 100644 --- a/build/test/results/test_Input.pass +++ b/build/test/results/test_Input.pass @@ -16,4 +16,4 @@ :ignored: 0 :stdout: - "-> " -:time: 0.05332690000068396 +:time: 0.025090100010856986 diff --git a/build/test/results/test_Moving.pass b/build/test/results/test_Moving.pass index 2038a96..188aa47 100644 --- a/build/test/results/test_Moving.pass +++ b/build/test/results/test_Moving.pass @@ -27,4 +27,4 @@ - " " - " p p p p p p p p " - " r n b q k b n r " -:time: 1.424722700030543 +:time: 0.03258749993983656 diff --git a/build/test/results/test_Schachbrett.pass b/build/test/results/test_Schachbrett.pass index 5fa9bce..1f4516c 100644 --- a/build/test/results/test_Schachbrett.pass +++ b/build/test/results/test_Schachbrett.pass @@ -15,4 +15,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.06810659996699542 +:time: 0.03429610002785921 diff --git a/build/test/runners/test_Bauer_runner.c b/build/test/runners/test_Bauer_runner.c index 814e7e6..ec2e660 100644 --- a/build/test/runners/test_Bauer_runner.c +++ b/build/test/runners/test_Bauer_runner.c @@ -11,6 +11,7 @@ char* GlobalOrderError; extern void setUp(void); extern void tearDown(void); extern void test_Bauer_X_Bewegung(void); +extern void test_Bauer_Schlag_Bewegung(void); extern void test_Bauer_Y_Bewegung(void); extern void test_Bauer_Start_Bewegung(void); @@ -78,8 +79,9 @@ int main(void) { UnityBegin("test_Bauer.c"); run_test(test_Bauer_X_Bewegung, "test_Bauer_X_Bewegung", 14); - run_test(test_Bauer_Y_Bewegung, "test_Bauer_Y_Bewegung", 37); - run_test(test_Bauer_Start_Bewegung, "test_Bauer_Start_Bewegung", 59); + run_test(test_Bauer_Schlag_Bewegung, "test_Bauer_Schlag_Bewegung", 36); + run_test(test_Bauer_Y_Bewegung, "test_Bauer_Y_Bewegung", 63); + run_test(test_Bauer_Start_Bewegung, "test_Bauer_Start_Bewegung", 85); return UnityEnd(); } diff --git a/src/Bauer.c b/src/Bauer.c index 09a9698..78d288c 100644 --- a/src/Bauer.c +++ b/src/Bauer.c @@ -10,6 +10,13 @@ bool istzugerlaubt_Bauer(char** Brett, int startX, int startY, int endX, int end //Wichtig extra Funktion EN Passaut //Wichtig Bauernumwandlung +if((startY + 1 == endY) && ((startX + 1 == endX) ||(startX - 1 == endY)) && ((Brett[endY][endX] == 'p') || (Brett[endY][endX] == 'n') || (Brett[endY][endX] == 'b') || +(Brett[endY][endX] == 'q') || (Brett[endY][endX] == 'r'))) +{ + return true; +} + + if(startX != endX){ return false; } diff --git a/test/test_Bauer.c b/test/test_Bauer.c index f0fb146..7d061e6 100644 --- a/test/test_Bauer.c +++ b/test/test_Bauer.c @@ -33,6 +33,32 @@ void test_Bauer_X_Bewegung(void) { free(brett); } +void test_Bauer_Schlag_Bewegung(void) { + + char** brett = Schachbrett_erstellen(); + int startX = 6; + int startY = 2; + int endX = 5; + int endY = 3; + Player player = PLAYER_WHITE; + + + TEST_ASSERT_NOT_NULL(brett); + + brett[startY][startX] = 'P'; + brett[endY][endX] = 'p'; + + print_Schachfeld(brett,8,8); + + TEST_ASSERT_FALSE(istzugerlaubt_Bauer( brett, startX, startY, endX, endY, player)); + + + for (int i = 0; i < 8; i++) { + free(brett[i]); + } + free(brett); +} + void test_Bauer_Y_Bewegung(void) {