diff --git a/build/artifacts/test/report.xml b/build/artifacts/test/report.xml
index b2e0187..71d31d9 100644
--- a/build/artifacts/test/report.xml
+++ b/build/artifacts/test/report.xml
@@ -9,12 +9,15 @@
test/test_Moving.c::test_Bauern_bewegen
+ test/test_Moving.c::test_istzugerlaubt
+
+
test/test_Schachbrett.c::test_Schachbrett_erstellen
- 3
+ 4
0
0
0
diff --git a/build/test/cache/test_Moving.c b/build/test/cache/test_Moving.c
index ae57173..ceaf7bf 100644
--- a/build/test/cache/test_Moving.c
+++ b/build/test/cache/test_Moving.c
@@ -76,4 +76,44 @@ void test_Bauern_bewegen(void) {
free(brett);
+}
+
+
+
+void test_istzugerlaubt(void){
+
+ char** brett = Schachbrett_erstellen();
+
+ int startX = 1;
+
+ int startY = 1;
+
+ int endX = 1;
+
+ int endY = 1;
+
+ Player player = PLAYER_WHITE;
+
+
+
+
+
+
+
+ do {if (!(istzugerlaubt(brett,startX,startY,endX,endY,player))) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(48)));}} while(0);
+
+ for (int i = 0; i < 8; i++) {
+
+ free(brett[i]);
+
+ }
+
+ free(brett);
+
+
+
+
+
+
+
}
diff --git a/build/test/out/c/Moving.o b/build/test/out/c/Moving.o
index 8db122b..9389f4c 100644
Binary files a/build/test/out/c/Moving.o and b/build/test/out/c/Moving.o differ
diff --git a/build/test/out/c/test_Moving.o b/build/test/out/c/test_Moving.o
index 19686d2..c94846c 100644
Binary files a/build/test/out/c/test_Moving.o and b/build/test/out/c/test_Moving.o differ
diff --git a/build/test/out/c/test_Moving_runner.o b/build/test/out/c/test_Moving_runner.o
index f7fd8bf..22412ac 100644
Binary files a/build/test/out/c/test_Moving_runner.o and b/build/test/out/c/test_Moving_runner.o differ
diff --git a/build/test/out/test_Moving.out b/build/test/out/test_Moving.out
index f5f2993..791709c 100644
Binary files a/build/test/out/test_Moving.out and b/build/test/out/test_Moving.out differ
diff --git a/build/test/preprocess/files/test_Moving.c b/build/test/preprocess/files/test_Moving.c
index ae57173..ceaf7bf 100644
--- a/build/test/preprocess/files/test_Moving.c
+++ b/build/test/preprocess/files/test_Moving.c
@@ -76,4 +76,44 @@ void test_Bauern_bewegen(void) {
free(brett);
+}
+
+
+
+void test_istzugerlaubt(void){
+
+ char** brett = Schachbrett_erstellen();
+
+ int startX = 1;
+
+ int startY = 1;
+
+ int endX = 1;
+
+ int endY = 1;
+
+ Player player = PLAYER_WHITE;
+
+
+
+
+
+
+
+ do {if (!(istzugerlaubt(brett,startX,startY,endX,endY,player))) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(48)));}} while(0);
+
+ for (int i = 0; i < 8; i++) {
+
+ free(brett[i]);
+
+ }
+
+ free(brett);
+
+
+
+
+
+
+
}
diff --git a/build/test/results/test_Input.pass b/build/test/results/test_Input.pass
index 67b1946..47ee855 100644
--- a/build/test/results/test_Input.pass
+++ b/build/test/results/test_Input.pass
@@ -16,4 +16,4 @@
:ignored: 0
:stdout:
- "-> "
-:time: 0.05769519996829331
+:time: 0.05088280001655221
diff --git a/build/test/results/test_Moving.pass b/build/test/results/test_Moving.pass
index 6ccba66..8363988 100644
--- a/build/test/results/test_Moving.pass
+++ b/build/test/results/test_Moving.pass
@@ -7,11 +7,15 @@
:line: 13
:message: ''
:unity_test_time: 0
+- :test: test_istzugerlaubt
+ :line: 38
+ :message: ''
+ :unity_test_time: 0
:failures: []
:ignores: []
:counts:
- :total: 1
- :passed: 1
+ :total: 2
+ :passed: 2
:failed: 0
:ignored: 0
:stdout:
@@ -23,4 +27,4 @@
- " "
- " p p p p p p p p "
- " r n b q k b n r "
-:time: 0.06610940000973642
+:time: 1.7912093000486493
diff --git a/build/test/results/test_Schachbrett.pass b/build/test/results/test_Schachbrett.pass
index 1217230..f6ef795 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.0358981000026688
+:time: 0.06260069995187223
diff --git a/build/test/runners/test_Moving_runner.c b/build/test/runners/test_Moving_runner.c
index 16910fb..674f490 100644
--- a/build/test/runners/test_Moving_runner.c
+++ b/build/test/runners/test_Moving_runner.c
@@ -11,6 +11,7 @@ char* GlobalOrderError;
extern void setUp(void);
extern void tearDown(void);
extern void test_Bauern_bewegen(void);
+extern void test_istzugerlaubt(void);
/*=======Mock Management=====*/
@@ -76,6 +77,7 @@ int main(void)
{
UnityBegin("test_Moving.c");
run_test(test_Bauern_bewegen, "test_Bauern_bewegen", 13);
+ run_test(test_istzugerlaubt, "test_istzugerlaubt", 38);
return UnityEnd();
}
diff --git a/src/Moving.c b/src/Moving.c
index a3efd61..731e59b 100644
--- a/src/Moving.c
+++ b/src/Moving.c
@@ -4,6 +4,21 @@
#include "spieler.h"
bool istzugerlaubt(char** Brett, int startX, int startY, int endX, int endY, Player player) {
+
+ if ((endX > 8 || endY > 8) || (endX < 0 || endY < 0)){
+ return false;
+ }
+ if (player == PLAYER_WHITE &&
+ (Brett[endY][endX] == 'R' || Brett[endY][endX] == 'N' || Brett[endY][endX] == 'Q' ||
+ Brett[endY][endX] == 'B' || Brett[endY][endX] == 'K' || Brett[endY][endX] == 'P')){
+ return false;
+ }
+ if (player == PLAYER_BLACK &&
+ (Brett[endY][endX] == 'r' || Brett[endY][endX] == 'n' || Brett[endY][endX] == 'q' ||
+ Brett[endY][endX] == 'b' || Brett[endY][endX] == 'k' || Brett[endY][endX] == 'p')){
+ return false;
+ }
+
/* Regeln hierhin
z.B. schauen ob der zug auch innerhalb vom spielbrett ist,
schauen ob auf dem zielfeld keine eigene Figur steht,
diff --git a/test/test_Moving.c b/test/test_Moving.c
index d5dfc60..62042f8 100644
--- a/test/test_Moving.c
+++ b/test/test_Moving.c
@@ -34,4 +34,25 @@ void test_Bauern_bewegen(void) {
}
free(brett);
}
+
+void test_istzugerlaubt(void){
+ char** brett = Schachbrett_erstellen();
+ int startX = 1;
+ int startY = 1;
+ int endX = 1;
+ int endY = 1;
+ Player player = PLAYER_WHITE;
+
+ //istzugerlaubt(brett,startX,startY,endX,endY,player);
+
+ TEST_ASSERT_FALSE(istzugerlaubt(brett,startX,startY,endX,endY,player));
+ for (int i = 0; i < 8; i++) {
+ free(brett[i]);
+ }
+ free(brett);
+
+
+
+}
+
#endif // TEST