Browse Source

Merge branch 'Daniel' into 'main'

Daniel

See merge request fdai7745/duellist-spielesammlung-projekt!15
remotes/origin/Areeb
fdai7745 11 months ago
parent
commit
ae979e7add
  1. 360
      build/test/cache/test_duellist_spielesammlung_projekt.c
  2. BIN
      build/test/out/c/test_duellist_spielesammlung_projekt.o
  3. BIN
      build/test/out/c/test_duellist_spielesammlung_projekt_runner.o
  4. BIN
      build/test/out/test_duellist_spielesammlung_projekt.out
  5. 360
      build/test/preprocess/files/test_duellist_spielesammlung_projekt.c
  6. 46
      build/test/results/test_duellist_spielesammlung_projekt.pass
  7. 20
      build/test/runners/test_duellist_spielesammlung_projekt_runner.c
  8. 136
      src/test/test_duellist_spielesammlung_projekt.c

360
build/test/cache/test_duellist_spielesammlung_projekt.c

@ -507,3 +507,363 @@ void test_FieldEmpty_returns_false_for_nonempty_field(void) {
), (UNITY_UINT)(225), UNITY_DISPLAY_STYLE_INT); ), (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);
}

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

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

BIN
build/test/out/test_duellist_spielesammlung_projekt.out

360
build/test/preprocess/files/test_duellist_spielesammlung_projekt.c

@ -507,3 +507,363 @@ void test_FieldEmpty_returns_false_for_nonempty_field(void) {
), (UNITY_UINT)(225), UNITY_DISPLAY_STYLE_INT); ), (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);
}

46
build/test/results/test_duellist_spielesammlung_projekt.pass

@ -67,12 +67,52 @@
:line: 215 :line: 215
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_calculate_mines_HeightWidthOne
:line: 228
:message: ''
:unity_test_time: 0
- :test: test_calculate_mines_WidthOne
:line: 242
:message: ''
:unity_test_time: 0
- :test: test_calculate_mines_NormalCase
:line: 256
:message: ''
:unity_test_time: 0
- :test: test_end_check_AllUncovered_NoMines
:line: 270
:message: ''
:unity_test_time: 0
- :test: test_create_minefield_ValidDimensions
:line: 289
:message: ''
:unity_test_time: 0
- :test: test_calculate_mines_HeightOne
:line: 314
:message: ''
:unity_test_time: 0
- :test: test_create_minefield_NegativeDimensions
:line: 328
:message: ''
:unity_test_time: 0
- :test: test_calculate_mines_HeightZero
:line: 342
:message: ''
:unity_test_time: 0
- :test: test_calculate_mines_HeightWidthNumber
:line: 356
:message: ''
:unity_test_time: 0
- :test: test_calculate_mines_HeightWidthAgan
:line: 370
:message: ''
:unity_test_time: 0
:failures: [] :failures: []
:ignores: [] :ignores: []
:counts: :counts:
:total: 16
:passed: 16
:total: 26
:passed: 26
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.01351129999989098
:time: 0.0499390999998468

20
build/test/runners/test_duellist_spielesammlung_projekt_runner.c

@ -26,6 +26,16 @@ extern void test_BoardFull_returns_true_when_board_is_full(void);
extern void test_CurrentPlayer_returns_correct_player(void); extern void test_CurrentPlayer_returns_correct_player(void);
extern void test_FieldEmpty_returns_true_for_empty_field(void); extern void test_FieldEmpty_returns_true_for_empty_field(void);
extern void test_FieldEmpty_returns_false_for_nonempty_field(void); extern void test_FieldEmpty_returns_false_for_nonempty_field(void);
extern void test_calculate_mines_HeightWidthOne(void);
extern void test_calculate_mines_WidthOne(void);
extern void test_calculate_mines_NormalCase(void);
extern void test_end_check_AllUncovered_NoMines(void);
extern void test_create_minefield_ValidDimensions(void);
extern void test_calculate_mines_HeightOne(void);
extern void test_create_minefield_NegativeDimensions(void);
extern void test_calculate_mines_HeightZero(void);
extern void test_calculate_mines_HeightWidthNumber(void);
extern void test_calculate_mines_HeightWidthAgan(void);
/*=======Mock Management=====*/ /*=======Mock Management=====*/
@ -106,6 +116,16 @@ int main(void)
run_test(test_CurrentPlayer_returns_correct_player, "test_CurrentPlayer_returns_correct_player", 189); run_test(test_CurrentPlayer_returns_correct_player, "test_CurrentPlayer_returns_correct_player", 189);
run_test(test_FieldEmpty_returns_true_for_empty_field, "test_FieldEmpty_returns_true_for_empty_field", 202); run_test(test_FieldEmpty_returns_true_for_empty_field, "test_FieldEmpty_returns_true_for_empty_field", 202);
run_test(test_FieldEmpty_returns_false_for_nonempty_field, "test_FieldEmpty_returns_false_for_nonempty_field", 215); run_test(test_FieldEmpty_returns_false_for_nonempty_field, "test_FieldEmpty_returns_false_for_nonempty_field", 215);
run_test(test_calculate_mines_HeightWidthOne, "test_calculate_mines_HeightWidthOne", 228);
run_test(test_calculate_mines_WidthOne, "test_calculate_mines_WidthOne", 242);
run_test(test_calculate_mines_NormalCase, "test_calculate_mines_NormalCase", 256);
run_test(test_end_check_AllUncovered_NoMines, "test_end_check_AllUncovered_NoMines", 270);
run_test(test_create_minefield_ValidDimensions, "test_create_minefield_ValidDimensions", 289);
run_test(test_calculate_mines_HeightOne, "test_calculate_mines_HeightOne", 314);
run_test(test_create_minefield_NegativeDimensions, "test_create_minefield_NegativeDimensions", 328);
run_test(test_calculate_mines_HeightZero, "test_calculate_mines_HeightZero", 342);
run_test(test_calculate_mines_HeightWidthNumber, "test_calculate_mines_HeightWidthNumber", 356);
run_test(test_calculate_mines_HeightWidthAgan, "test_calculate_mines_HeightWidthAgan", 370);
return UnityEnd(); return UnityEnd();
} }

136
src/test/test_duellist_spielesammlung_projekt.c

@ -225,30 +225,160 @@ void test_FieldEmpty_returns_false_for_nonempty_field(void) {
TEST_ASSERT_EQUAL(0, result); TEST_ASSERT_EQUAL(0, result);
} }
#endif // TEST
void test_calculate_mines_HeightWidthOne(void)
{
/* arrange */
int height = 1;
int width = 1;
int expected = 0;
/* act */
int result = calculate_mines(height, width);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
}
void test_calculate_mines_WidthOne(void)
{
/* arrange */
int height = 5;
int width = 1;
int expected = 0;
/* act */
int result = calculate_mines(height, width);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
}
void test_calculate_mines_NormalCase(void)
{
/* arrange */
int height = 5;
int width = 5;
int expected = 6;
/* act */
int result = calculate_mines(height, width);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
}
void test_end_check_AllUncovered_NoMines(void)
{
/* arrange */
char* minefield[] = { "000",
"000",
"000" };
char* mines[] = { "000",
"000",
"000" };
int height = 3;
int width = 3;
/* act */
int result = end_check(minefield, mines, height, width);
/* assert */
TEST_ASSERT_EQUAL_INT(1, result);
}
void test_create_minefield_ValidDimensions(void)
{
/* arrange */
int height = 3;
int width = 4;
char within = '0';
/* act */
char** result = create_minefield(height, width, within);
/* assert */
TEST_ASSERT_NOT_NULL(result);
for (int i = 0; i < height; i++) {
TEST_ASSERT_NOT_NULL(result[i]);
for (int j = 0; j < width; j++) {
TEST_ASSERT_EQUAL_CHAR(within, result[i][j]);
}
}
// Free allocated memory
for (int i = 0; i < height; i++) {
free(result[i]);
}
free(result);
}
void test_calculate_mines_HeightOne(void)
{
/* arrange */
int height = 1;
int width = 5;
int expected = 0;
/* act */
int result = calculate_mines(height, width);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
}
void test_create_minefield_NegativeDimensions(void)
{
/* arrange */
int height = -3;
int width = 4;
char within = '0';
/* act */
char** result = create_minefield(height, width, within);
/* assert */
TEST_ASSERT_NULL(result);
}
void test_calculate_mines_HeightZero(void)
{
/* arrange */
int height = 0;
int width = 0;
int expected = 0;
/* act */
int result = calculate_mines(height, width);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
}
void test_calculate_mines_HeightWidthNumber(void)
{
/* arrange */
int height = 4;
int width = 6;
int expected = 6;
/* act */
int result = calculate_mines(height, width);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
}
void test_calculate_mines_HeightWidthAgan(void)
{
/* arrange */
int height = 6;
int width = 6;
int expected = 9;
/* act */
int result = calculate_mines(height, width);
/* assert */
TEST_ASSERT_EQUAL_INT(expected, result);
}
#endif // TEST
Loading…
Cancel
Save