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.
60 lines
994 B
60 lines
994 B
#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[0][7]);
|
|
TEST_ASSERT_EQUAL_CHAR(expected,Spielfeld[1][0]);
|
|
}
|
|
|
|
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
|
|
|