You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
938 B
44 lines
938 B
#ifdef TEST
|
|
#include "unity.h"
|
|
#include "Schachbrett.h"
|
|
#include "Spieler.h"
|
|
#include "Misc.h"
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <assert.h>
|
|
|
|
void test_king_alive() {
|
|
char** brett = malloc(8 * sizeof(char*));
|
|
for(int i = 0; i < 8; i++) {
|
|
brett[i] = malloc(8 * sizeof(char));
|
|
for(int j = 0; j < 8; j++) {
|
|
brett[i][j] = '.';
|
|
}
|
|
}
|
|
|
|
// Beide Könige sind auf dem Brett
|
|
brett[0][0] = 'K';
|
|
brett[7][7] = 'k';
|
|
assert(king_alive(brett) == true);
|
|
// Nur der weiße König auf dem Brett
|
|
brett[7][7] = '.';
|
|
assert(king_alive(brett) == false);
|
|
|
|
// Nur schwarzer König auf dem Brett
|
|
brett[0][0] = '.';
|
|
brett[7][7] = 'k';
|
|
assert(king_alive(brett) == false);
|
|
|
|
// Kein König
|
|
brett[7][7] = '.';
|
|
assert(king_alive(brett) == false);
|
|
|
|
for(int i = 0; i < 8; i++) {
|
|
free(brett[i]);
|
|
}
|
|
free(brett);
|
|
}
|
|
|
|
|
|
|
|
#endif // TEST MISC
|