Browse Source

'istzugerlaubt()' Bedingungen ergänzt, Hendrik Voß

remotes/origin/Läufer-fertig,-Hendrik-Voß
Hendrik Voß 11 months ago
parent
commit
415376bc4e
  1. 5
      build/artifacts/test/report.xml
  2. 40
      build/test/cache/test_Moving.c
  3. BIN
      build/test/out/c/Moving.o
  4. BIN
      build/test/out/c/test_Moving.o
  5. BIN
      build/test/out/c/test_Moving_runner.o
  6. BIN
      build/test/out/test_Moving.out
  7. 40
      build/test/preprocess/files/test_Moving.c
  8. 2
      build/test/results/test_Input.pass
  9. 10
      build/test/results/test_Moving.pass
  10. 2
      build/test/results/test_Schachbrett.pass
  11. 2
      build/test/runners/test_Moving_runner.c
  12. 15
      src/Moving.c
  13. 21
      test/test_Moving.c

5
build/artifacts/test/report.xml

@ -9,12 +9,15 @@
<Name>test/test_Moving.c::test_Bauern_bewegen</Name>
</Test>
<Test id="3">
<Name>test/test_Moving.c::test_istzugerlaubt</Name>
</Test>
<Test id="4">
<Name>test/test_Schachbrett.c::test_Schachbrett_erstellen</Name>
</Test>
</SuccessfulTests>
<IgnoredTests/>
<Statistics>
<Tests>3</Tests>
<Tests>4</Tests>
<Ignores>0</Ignores>
<FailuresTotal>0</FailuresTotal>
<Errors>0</Errors>

40
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);
}

BIN
build/test/out/c/Moving.o

BIN
build/test/out/c/test_Moving.o

BIN
build/test/out/c/test_Moving_runner.o

BIN
build/test/out/test_Moving.out

40
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);
}

2
build/test/results/test_Input.pass

@ -16,4 +16,4 @@
:ignored: 0
:stdout:
- "-> "
:time: 0.05769519996829331
:time: 0.05088280001655221

10
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

2
build/test/results/test_Schachbrett.pass

@ -15,4 +15,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.0358981000026688
:time: 0.06260069995187223

2
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();
}

15
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,

21
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
Loading…
Cancel
Save