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.

91 lines
1.6 KiB

#ifdef TEST
#include "unity.h"
#include "schach.h"
#include "string.h"
void setUp(void)
{
}
void tearDown(void)
{
}
void test_print_Schachfeld(void){
/* arrange */
char expected = 'S';
int x = 8;
int y = 8;
/* act */
char** Spielfeld = create_Schachfeld(x, y);
/* assert */
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[5][0]);
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[4][3]);
}
void test_print_Schachfeld_Turm_weiss(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]);
}
void test_print_Schachfeld_dame_schwarz(void){
/* arrange */
char expected = 'd';
int x = 8;
int y = 8;
/* act */
char** Spielfeld = create_Schachfeld(x, y);
/* assert */
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[7][3]);
//TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[0][7]);
}
void test_read_input(void) {
/* arrange */
const char *input = "8\n";
int result = 0;
int expected = 7;
FILE *original_stdin = freopen(NULL, "r", stdin);
FILE *tempInput = fopen("temp_input.txt", "w");
fputs(input, tempInput);
fclose(tempInput);
tempInput = freopen("temp_input.txt", "r", stdin);
/* act */
result = read_input();
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
/* Clean up */
fclose(tempInput);
freopen("/dev/tty", "r", stdin);
freopen(NULL, "r", stdin);
}
#endif // TEST