|
|
@ -507,3 +507,363 @@ void test_FieldEmpty_returns_false_for_nonempty_field(void) { |
|
|
|
), (UNITY_UINT)(225), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_calculate_mines_HeightWidthOne(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = 1; |
|
|
|
|
|
|
|
int width = 1; |
|
|
|
|
|
|
|
int expected = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = calculate_mines(height, width); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(239), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_calculate_mines_WidthOne(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = 5; |
|
|
|
|
|
|
|
int width = 1; |
|
|
|
|
|
|
|
int expected = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = calculate_mines(height, width); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(253), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_calculate_mines_NormalCase(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = 5; |
|
|
|
|
|
|
|
int width = 5; |
|
|
|
|
|
|
|
int expected = 6; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = calculate_mines(height, width); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(267), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_end_check_AllUncovered_NoMines(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char* minefield[] = { "000", |
|
|
|
|
|
|
|
"000", |
|
|
|
|
|
|
|
"000" }; |
|
|
|
|
|
|
|
char* mines[] = { "000", |
|
|
|
|
|
|
|
"000", |
|
|
|
|
|
|
|
"000" }; |
|
|
|
|
|
|
|
int height = 3; |
|
|
|
|
|
|
|
int width = 3; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = end_check(minefield, mines, height, width); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(286), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_create_minefield_ValidDimensions(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = 3; |
|
|
|
|
|
|
|
int width = 4; |
|
|
|
|
|
|
|
char within = '0'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char** result = create_minefield(height, width, within); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do {if ((((result)) != |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
)) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(300))));}} while(0); |
|
|
|
|
|
|
|
for (int i = 0; i < height; i++) { |
|
|
|
|
|
|
|
do {if ((((result[i])) != |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
)) {} else {UnityFail( (((" Expected Non-NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(302))));}} while(0); |
|
|
|
|
|
|
|
for (int j = 0; j < width; j++) { |
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((within)), (UNITY_INT)(UNITY_INT8 )((result[i][j])), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(304), UNITY_DISPLAY_STYLE_CHAR); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < height; i++) { |
|
|
|
|
|
|
|
free(result[i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
free(result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_calculate_mines_HeightOne(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = 1; |
|
|
|
|
|
|
|
int width = 5; |
|
|
|
|
|
|
|
int expected = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = calculate_mines(height, width); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(325), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_create_minefield_NegativeDimensions(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = -3; |
|
|
|
|
|
|
|
int width = 4; |
|
|
|
|
|
|
|
char within = '0'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char** result = create_minefield(height, width, within); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do {if ((((result)) == |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
)) {} else {UnityFail( (((" Expected NULL"))), (UNITY_UINT)((UNITY_UINT)((UNITY_UINT)(339))));}} while(0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_calculate_mines_HeightZero(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = 0; |
|
|
|
|
|
|
|
int width = 0; |
|
|
|
|
|
|
|
int expected = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = calculate_mines(height, width); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(353), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_calculate_mines_HeightWidthNumber(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = 4; |
|
|
|
|
|
|
|
int width = 6; |
|
|
|
|
|
|
|
int expected = 6; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = calculate_mines(height, width); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(367), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test_calculate_mines_HeightWidthAgan(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int height = 6; |
|
|
|
|
|
|
|
int width = 6; |
|
|
|
|
|
|
|
int expected = 9; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = calculate_mines(height, width); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), ( |
|
|
|
|
|
|
|
((void *)0) |
|
|
|
|
|
|
|
), (UNITY_UINT)(381), UNITY_DISPLAY_STYLE_INT); |
|
|
|
|
|
|
|
} |