Browse Source

Schachfeld füllen, Luis Hahn

remotes/origin/Läufer-fertig,-Hendrik-Voß
Luis Hahn 11 months ago
parent
commit
895c81cecd
  1. 42
      build/test/cache/test_schach.c
  2. BIN
      build/test/out/c/schach.o
  3. BIN
      build/test/out/c/test_schach.o
  4. BIN
      build/test/out/c/test_schach_runner.o
  5. BIN
      build/test/out/test_schach.out
  6. 42
      build/test/preprocess/files/test_schach.c
  7. 12
      build/test/results/test_schach.pass
  8. 4
      build/test/runners/test_schach_runner.c
  9. 24
      src/schach.c
  10. 16
      test/test_schach.c

42
build/test/cache/test_schach.c

@ -46,13 +46,13 @@ void test_print_Schachfeld(void){
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[0][7])), (
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[5][0])), (
((void *)0) ((void *)0)
), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR); ), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR);
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[1][0])), (
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[4][3])), (
((void *)0) ((void *)0)
@ -62,6 +62,42 @@ void test_print_Schachfeld(void){
void test_print_Schachfeld_Turm(void){
char expected = 'T';
int x = 8;
int y = 8;
char** Spielfeld = create_Schachfeld(x, y);
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[0][0])), (
((void *)0)
), (UNITY_UINT)(40), UNITY_DISPLAY_STYLE_CHAR);
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[0][7])), (
((void *)0)
), (UNITY_UINT)(41), UNITY_DISPLAY_STYLE_CHAR);
}
void test_read_input(void) { void test_read_input(void) {
@ -116,7 +152,7 @@ void test_read_input(void) {
((void *)0) ((void *)0)
), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(63), UNITY_DISPLAY_STYLE_INT);

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

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

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

BIN
build/test/out/test_schach.out

42
build/test/preprocess/files/test_schach.c

@ -46,13 +46,13 @@ void test_print_Schachfeld(void){
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[0][7])), (
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[5][0])), (
((void *)0) ((void *)0)
), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR); ), (UNITY_UINT)(26), UNITY_DISPLAY_STYLE_CHAR);
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[1][0])), (
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[4][3])), (
((void *)0) ((void *)0)
@ -62,6 +62,42 @@ void test_print_Schachfeld(void){
void test_print_Schachfeld_Turm(void){
char expected = 'T';
int x = 8;
int y = 8;
char** Spielfeld = create_Schachfeld(x, y);
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[0][0])), (
((void *)0)
), (UNITY_UINT)(40), UNITY_DISPLAY_STYLE_CHAR);
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((expected)), (UNITY_INT)(UNITY_INT8 )((Spielfeld[0][7])), (
((void *)0)
), (UNITY_UINT)(41), UNITY_DISPLAY_STYLE_CHAR);
}
void test_read_input(void) { void test_read_input(void) {
@ -116,7 +152,7 @@ void test_read_input(void) {
((void *)0) ((void *)0)
), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT);
), (UNITY_UINT)(63), UNITY_DISPLAY_STYLE_INT);

12
build/test/results/test_schach.pass

@ -7,16 +7,20 @@
:line: 16 :line: 16
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_read_input
- :test: test_print_Schachfeld_Turm
:line: 30 :line: 30
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_read_input
:line: 44
:message: ''
:unity_test_time: 0
:failures: [] :failures: []
:ignores: [] :ignores: []
:counts: :counts:
:total: 2
:passed: 2
:total: 3
:passed: 3
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 1.9844588999985717
:time: 0.14233430003514513

4
build/test/runners/test_schach_runner.c

@ -11,6 +11,7 @@ char* GlobalOrderError;
extern void setUp(void); extern void setUp(void);
extern void tearDown(void); extern void tearDown(void);
extern void test_print_Schachfeld(void); extern void test_print_Schachfeld(void);
extern void test_print_Schachfeld_Turm(void);
extern void test_read_input(void); extern void test_read_input(void);
@ -77,7 +78,8 @@ int main(void)
{ {
UnityBegin("test_schach.c"); UnityBegin("test_schach.c");
run_test(test_print_Schachfeld, "test_print_Schachfeld", 16); run_test(test_print_Schachfeld, "test_print_Schachfeld", 16);
run_test(test_read_input, "test_read_input", 30);
run_test(test_print_Schachfeld_Turm, "test_print_Schachfeld_Turm", 30);
run_test(test_read_input, "test_read_input", 44);
return UnityEnd(); return UnityEnd();
} }

24
src/schach.c

@ -20,6 +20,7 @@
Programmablauf: Programmablauf:
1.Spielfeld in der create_Schachfeld erstellen 1.Spielfeld in der create_Schachfeld erstellen
1.1 Schachfeld füllen
2.Spielfeld anzeigen mit print_Schachfeld 2.Spielfeld anzeigen mit print_Schachfeld
3.Eingabe mit choose_Figur 3.Eingabe mit choose_Figur
3.1 erst x dann y 3.1 erst x dann y
@ -42,6 +43,8 @@ int checkmate(){
return 0; return 0;
} }
int read_input(){ int read_input(){
int koordinate = 0; int koordinate = 0;
@ -53,7 +56,7 @@ int read_input(){
} }
else{ else{
read_input();
} }
@ -97,6 +100,25 @@ char** create_Schachfeld(int x, int y) {
} }
} }
} }
Spielfeld[0][0] = 'T'; //Turm Weiß
Spielfeld[0][1] = 'P'; //Pferd Weiß
Spielfeld[0][2] = 'L'; //Laufer Weiß
Spielfeld[0][3] = 'D'; //Dame Weiß
Spielfeld[0][4] = 'K'; //König Weiß
Spielfeld[0][5] = 'L';
Spielfeld[0][6] = 'P';
Spielfeld[0][7] = 'T';
Spielfeld[7][0] = 't'; //Turm Schwarz
Spielfeld[7][1] = 'p';
Spielfeld[7][2] = 'l';
Spielfeld[7][3] = 'd';
Spielfeld[7][4] = 'k';
Spielfeld[7][5] = 'l';
Spielfeld[7][6] = 'p';
Spielfeld[7][7] = 't';
return Spielfeld; return Spielfeld;
} }

16
test/test_schach.c

@ -23,8 +23,22 @@ void test_print_Schachfeld(void){
char** Spielfeld = create_Schachfeld(x, y); char** Spielfeld = create_Schachfeld(x, y);
/* assert */ /* assert */
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[5][0]);
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[4][3]);
}
void test_print_Schachfeld_Turm(void){
/* arrange */
char expected = 'T';
int x = 8;
int y = 8;
/* act */
char** Spielfeld = create_Schachfeld(x, y);
/* assert */
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[0][0]);
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[0][7]); TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[0][7]);
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[1][0]);
} }
void test_read_input(void) { void test_read_input(void) {

Loading…
Cancel
Save