diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..08d9005 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc build active file", + "command": "/usr/bin/gcc", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/build/artifacts/release/project.out b/build/artifacts/release/project.out index 7e9f672..2b21304 100755 Binary files a/build/artifacts/release/project.out and b/build/artifacts/release/project.out differ diff --git a/build/release/dependencies/get_character.d b/build/release/dependencies/get_character.d new file mode 100644 index 0000000..ba996cf --- /dev/null +++ b/build/release/dependencies/get_character.d @@ -0,0 +1 @@ +build/release/out/c/get_character.o: src/main/c/Snake/get_character.c diff --git a/build/release/dependencies/main.d b/build/release/dependencies/main.d index 4dccf23..d6a73f0 100644 --- a/build/release/dependencies/main.d +++ b/build/release/dependencies/main.d @@ -1,2 +1,3 @@ build/release/out/c/main.o: src/main/c/main.c \ - src/main/c/Template/game100.h + src/main/c/Snake/snake_start.h \ + src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/release/dependencies/minesweeper_start.d b/build/release/dependencies/minesweeper_start.d new file mode 100644 index 0000000..67807f6 --- /dev/null +++ b/build/release/dependencies/minesweeper_start.d @@ -0,0 +1,3 @@ +build/release/out/c/minesweeper_start.o: \ + src/main/c/Minesweeper/minesweeper_start.c \ + src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/release/dependencies/snake_start.d b/build/release/dependencies/snake_start.d new file mode 100644 index 0000000..974ab7a --- /dev/null +++ b/build/release/dependencies/snake_start.d @@ -0,0 +1,2 @@ +build/release/out/c/snake_start.o: src/main/c/Snake/snake_start.c \ + src/main/c/Snake/snake_start.h src/main/c/Snake/get_character.h diff --git a/build/release/dependencies/tictactoe.d b/build/release/dependencies/tictactoe.d new file mode 100644 index 0000000..3bd3806 --- /dev/null +++ b/build/release/dependencies/tictactoe.d @@ -0,0 +1 @@ +build/release/out/c/tictactoe.o: src/main/c/GameTic_Tac_Toe/tictactoe.c diff --git a/build/release/out/c/get_character.o b/build/release/out/c/get_character.o new file mode 100644 index 0000000..570722e Binary files /dev/null and b/build/release/out/c/get_character.o differ diff --git a/build/release/out/c/main.o b/build/release/out/c/main.o index b7d6436..517a416 100644 Binary files a/build/release/out/c/main.o and b/build/release/out/c/main.o differ diff --git a/build/release/out/c/minesweeper_start.o b/build/release/out/c/minesweeper_start.o new file mode 100644 index 0000000..0218308 Binary files /dev/null and b/build/release/out/c/minesweeper_start.o differ diff --git a/build/release/out/c/snake_start.o b/build/release/out/c/snake_start.o new file mode 100644 index 0000000..de4954f Binary files /dev/null and b/build/release/out/c/snake_start.o differ diff --git a/build/release/out/c/tictactoe.o b/build/release/out/c/tictactoe.o new file mode 100644 index 0000000..a10f2f1 Binary files /dev/null and b/build/release/out/c/tictactoe.o differ diff --git a/build/release/project.out b/build/release/project.out index 7e9f672..2b21304 100755 Binary files a/build/release/project.out and b/build/release/project.out differ diff --git a/build/test/cache/defines_dependency.yml b/build/test/cache/defines_dependency.yml index b227090..717335e 100644 --- a/build/test/cache/defines_dependency.yml +++ b/build/test/cache/defines_dependency.yml @@ -1,3 +1,11 @@ --- src/main/c/Template/game100.c: - TEST +src/main/c/Snake/snake_start.c: +- TEST +src/main/c/Snake/get_character.c: +- TEST +src/main/c/Minesweeper/minesweeper_start.c: +- TEST +src/main/c/GameTic_Tac_Toe/tictactoe.c: +- TEST diff --git a/build/test/cache/test_bomb_in_array.c b/build/test/cache/test_bomb_in_array.c new file mode 100644 index 0000000..14de752 --- /dev/null +++ b/build/test/cache/test_bomb_in_array.c @@ -0,0 +1,79 @@ +#include "build/temp/../../src/main/c/Minesweeper/minesweeper_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_bomb_in_array(void){ + + + + + + _Bool + + result; + + int array[] = {5, 9, 42, 6, 87, 95, 202, 13, 45 ,78}; + + int bomb = 42; + + int length = 10; + + + + + + result = array_contains_value(array, bomb, length); + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(22)));}} while(0); + +} + + + + + +void test_bomb_not_in_array(void){ + + + + + + _Bool + + result; + + int array[] = {5, 9, 42, 6, 87, 95, 202, 13, 45 ,78}; + + int bomb = 0; + + int length = 10; + + + + + + result = array_contains_value(array, bomb, length); + + + + + + do {if (!(result)) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(37)));}} while(0); + +} diff --git a/build/test/cache/test_collision.c b/build/test/cache/test_collision.c new file mode 100644 index 0000000..a159403 --- /dev/null +++ b/build/test/cache/test_collision.c @@ -0,0 +1,102 @@ +#include "src/main/c/Snake/get_character.h" +#include "src/main/c/Snake/snake_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_self_collision(void){ + + + + + + _Bool + + result; + + Snake snake = {1, 5, {6 + 16 * 6, 6 + 16 * 7, 7 + 16 * 7, 7 + 16 * 6, 6 + 16 * 6}}; + + + + + + result = check_if_dead(&snake); + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(21)));}} while(0); + +} + + + + + +void test_no_collision(void){ + + + + + + _Bool + + result; + + Snake snake = initialize_snake(); + + + + + + result = check_if_dead(&snake); + + + + + + do {if (!(result)) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(34)));}} while(0); + +} + + + + + +void test_wall_collision(void){ + + + + + + _Bool + + result; + + Snake snake = {-1, 4, {0 + 16 * 6, 1 + 16 * 6, 2 + 16 * 6, 3 + 16 * 6}}; + + + + + + result = check_if_dead(&snake); + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(47)));}} while(0); + +} diff --git a/build/test/cache/test_is_Valid_tile.c b/build/test/cache/test_is_Valid_tile.c new file mode 100644 index 0000000..6ad87c9 --- /dev/null +++ b/build/test/cache/test_is_Valid_tile.c @@ -0,0 +1,205 @@ +#include "build/temp/../../src/main/c/Minesweeper/minesweeper_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_detect_not_valid_tile_left(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0; + + int direction = 1; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(21), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_not_valid_tile_up(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0; + + int direction = 3; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(35), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_valid_tile_right(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0; + + int direction = 5; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_valid_tile_down(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0; + + int direction = 4; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0 + board.width)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(63), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_not_valid_tile_right(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = board.width * board.height - 1; + + int direction = 5; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(77), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_not_valid_tile_down(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = board.width * board.height - 1; + + int direction = 4; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(91), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/cache/test_moving_snake.c b/build/test/cache/test_moving_snake.c new file mode 100644 index 0000000..b305c52 --- /dev/null +++ b/build/test/cache/test_moving_snake.c @@ -0,0 +1,142 @@ +#include "build/temp/../../src/main/c/Snake/get_character.h" +#include "build/temp/../../src/main/c/Snake/snake_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_moving_right(void){ + + + + + + _Bool + + result; + + Snake snake = {1, 3, {8 + 16 * 6, 7 + 16 * 6, 6 + 16 * 6}}; + + Snake expected = {1, 3, {9 + 16 * 6, 8 + 16 * 6, 7 + 16 * 6}}; + + + + + + move_snake(&snake); + + result = memcmp(&snake, &expected, sizeof(Snake)) == 0; + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0); + +} + + + +void test_moving_down(void){ + + + + + + _Bool + + result; + + Snake snake = {16, 3, {8 + 16 * 6, 7 + 16 * 6, 6 + 16 * 6}}; + + Snake expected = {16, 3, {8 + 16 * 7, 8 + 16 * 6, 7 + 16 * 6}}; + + + + + + move_snake(&snake); + + result = memcmp(&snake, &expected, sizeof(Snake)) == 0; + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(38)));}} while(0); + +} + + + +void test_moving_left(void){ + + + + + + _Bool + + result; + + Snake snake = {-1, 3, {8 + 16 * 6, 7 + 16 * 6, 6 + 16 * 6}}; + + Snake expected = {-1, 3, {7 + 16 * 6, 8 + 16 * 6, 7 + 16 * 6}}; + + + + + + move_snake(&snake); + + result = memcmp(&snake, &expected, sizeof(Snake)) == 0; + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(52)));}} while(0); + +} + + + +void test_moving_up(void){ + + + + + + _Bool + + result; + + Snake snake = {-16, 3, {8 + 16 * 6, 7 + 16 * 6, 6 + 16 * 6}}; + + Snake expected = {-16, 3, {8 + 16 * 5, 8 + 16 * 6, 7 + 16 * 6}}; + + + + + + move_snake(&snake); + + result = memcmp(&snake, &expected, sizeof(Snake)) == 0; + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(66)));}} while(0); + +} diff --git a/build/test/cache/test_number_of_bombs.c b/build/test/cache/test_number_of_bombs.c new file mode 100644 index 0000000..9b1981f --- /dev/null +++ b/build/test/cache/test_number_of_bombs.c @@ -0,0 +1,205 @@ +#include "build/temp/../../src/main/c/Minesweeper/minesweeper_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_no_bombs_placed_around_tile(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0 + board.width * 1; + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(21), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_searching_for_bombs_on_correct_tiles(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0 + board.width * 1; + + board.bombs[0] = 0 + board.width * 3; + + board.bombs[1] = 2 + board.width * 1; + + board.bombs[2] = board.width - 1 + board.width * 1; + + board.bombs[3] = 0 + board.width * (board.height - 1); + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(38), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_2_bombs_around_tile(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0 + board.width * 1; + + board.bombs[0] = 0 + board.width * 2; + + board.bombs[1] = 1 + board.width * 1; + + board.bombs[2] = board.width - 1 + board.width * 1; + + board.bombs[3] = 0 + board.width * (board.height - 1); + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(55), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_5_bombs_around_tile(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 1 + board.width * 0; + + board.bombs[0] = 0 + board.width * 0; + + board.bombs[1] = 2 + board.width * 0; + + board.bombs[2] = 0 + board.width * 1; + + board.bombs[3] = 1 + board.width * 1; + + board.bombs[4] = 2 + board.width * 1; + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(73), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_8_bombs_around_tile(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 7 + board.width * 7; + + board.bombs[0] = 6 + board.width * 6; + + board.bombs[1] = 7 + board.width * 6; + + board.bombs[2] = 8 + board.width * 6; + + board.bombs[3] = 6 + board.width * 7; + + board.bombs[4] = 8 + board.width * 7; + + board.bombs[5] = 6 + board.width * 8; + + board.bombs[6] = 7 + board.width * 8; + + board.bombs[7] = 8 + board.width * 8; + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((8)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(94), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/cache/test_part_of_snake.c b/build/test/cache/test_part_of_snake.c new file mode 100644 index 0000000..b488cb0 --- /dev/null +++ b/build/test/cache/test_part_of_snake.c @@ -0,0 +1,102 @@ +#include "build/temp/../../src/main/c/Snake/get_character.h" +#include "build/temp/../../src/main/c/Snake/snake_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_find_head(void){ + + + + int result; + + Snake snake = initialize_snake(); + + + + + + result = part_of_snake(&snake, 8 * 16 + 8); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(20), UNITY_DISPLAY_STYLE_INT); + +} + + + + + +void test_get_correct_index(void){ + + + + int result; + + Snake snake = initialize_snake(); + + + + + + result = part_of_snake(&snake, 8 * 16 + 6); + + + + + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(33), UNITY_DISPLAY_STYLE_INT); + +} + + + + + +void test_snake_not_on_tile(void){ + + + + int result; + + Snake snake = initialize_snake(); + + + + + + result = part_of_snake(&snake, 6 * 16 + 6); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(46), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/cache/test_tictactoe.c b/build/test/cache/test_tictactoe.c new file mode 100644 index 0000000..7971f22 --- /dev/null +++ b/build/test/cache/test_tictactoe.c @@ -0,0 +1,105 @@ +#include "src/main/c/GameTic_Tac_Toe/tictactoe.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + + + +void setUp(void){ + + + +} + +void tearDown(void){ + +} + + + + + +void test_if_not_identical(void){ + + + + char result; + + char a = 'a', b = 'b', c = 'c'; + + + + result = checkLine(a, b, c); + + + + + + UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((' ')), (UNITY_INT)(UNITY_INT8 )((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_CHAR); + +} + + + + + +void test_if_identical(void){ + + + + char result; + + char a = 'a', b = 'a', c = 'a'; + + + + result = checkLine(a, b, c); + + + + + + UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((a)), (UNITY_INT)(UNITY_INT8 )((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(34), UNITY_DISPLAY_STYLE_CHAR); + +} + + + +void test_checkLine_horizontalerGewinner(void) { + + + + char result; + + char a = 'X', b = 'X', c = 'X'; + + + + + + result = checkLine(a, b, c); + + + + + + UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('X')), (UNITY_INT)(UNITY_INT8 )((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(46), UNITY_DISPLAY_STYLE_CHAR); + +} + +} diff --git a/build/test/dependencies/get_character.d b/build/test/dependencies/get_character.d new file mode 100644 index 0000000..8f17ec7 --- /dev/null +++ b/build/test/dependencies/get_character.d @@ -0,0 +1 @@ +build/test/out/c/get_character.o: src/main/c/Snake/get_character.c diff --git a/build/test/dependencies/minesweeper_start.d b/build/test/dependencies/minesweeper_start.d new file mode 100644 index 0000000..fd6546c --- /dev/null +++ b/build/test/dependencies/minesweeper_start.d @@ -0,0 +1,3 @@ +build/test/out/c/minesweeper_start.o: \ + src/main/c/Minesweeper/minesweeper_start.c \ + src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/test/dependencies/snake_start.d b/build/test/dependencies/snake_start.d new file mode 100644 index 0000000..6c435ce --- /dev/null +++ b/build/test/dependencies/snake_start.d @@ -0,0 +1,2 @@ +build/test/out/c/snake_start.o: src/main/c/Snake/snake_start.c \ + src/main/c/Snake/snake_start.h src/main/c/Snake/get_character.h diff --git a/build/test/dependencies/test_bomb_in_array.d b/build/test/dependencies/test_bomb_in_array.d new file mode 100644 index 0000000..994afc1 --- /dev/null +++ b/build/test/dependencies/test_bomb_in_array.d @@ -0,0 +1,5 @@ +build/test/out/c/test_bomb_in_array.o: \ + test/Minesweeper/test_bomb_in_array.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + test/Minesweeper/../../src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/test/dependencies/test_bomb_in_array_runner.d b/build/test/dependencies/test_bomb_in_array_runner.d new file mode 100644 index 0000000..53b6683 --- /dev/null +++ b/build/test/dependencies/test_bomb_in_array_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_bomb_in_array_runner.o: \ + build/test/runners/test_bomb_in_array_runner.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/test_collision.d b/build/test/dependencies/test_collision.d new file mode 100644 index 0000000..ad5e8d5 --- /dev/null +++ b/build/test/dependencies/test_collision.d @@ -0,0 +1,4 @@ +build/test/out/c/test_collision.o: test/Snake/test_collision.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + src/main/c/Snake/snake_start.h src/main/c/Snake/get_character.h diff --git a/build/test/dependencies/test_collision_runner.d b/build/test/dependencies/test_collision_runner.d new file mode 100644 index 0000000..279686d --- /dev/null +++ b/build/test/dependencies/test_collision_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_collision_runner.o: \ + build/test/runners/test_collision_runner.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/test_is_Valid_tile.d b/build/test/dependencies/test_is_Valid_tile.d new file mode 100644 index 0000000..3c1a8bf --- /dev/null +++ b/build/test/dependencies/test_is_Valid_tile.d @@ -0,0 +1,5 @@ +build/test/out/c/test_is_Valid_tile.o: \ + test/Minesweeper/test_is_Valid_tile.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + test/Minesweeper/../../src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/test/dependencies/test_is_Valid_tile_runner.d b/build/test/dependencies/test_is_Valid_tile_runner.d new file mode 100644 index 0000000..fbecf92 --- /dev/null +++ b/build/test/dependencies/test_is_Valid_tile_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_is_Valid_tile_runner.o: \ + build/test/runners/test_is_Valid_tile_runner.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/test_moving_snake.d b/build/test/dependencies/test_moving_snake.d new file mode 100644 index 0000000..0b892ff --- /dev/null +++ b/build/test/dependencies/test_moving_snake.d @@ -0,0 +1,5 @@ +build/test/out/c/test_moving_snake.o: test/Snake/test_moving_snake.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + test/Snake/../../src/main/c/Snake/snake_start.h \ + test/Snake/../../src/main/c/Snake/get_character.h diff --git a/build/test/dependencies/test_moving_snake_runner.d b/build/test/dependencies/test_moving_snake_runner.d new file mode 100644 index 0000000..ce8f9f0 --- /dev/null +++ b/build/test/dependencies/test_moving_snake_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_moving_snake_runner.o: \ + build/test/runners/test_moving_snake_runner.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/test_number_of_bombs.d b/build/test/dependencies/test_number_of_bombs.d new file mode 100644 index 0000000..f46f914 --- /dev/null +++ b/build/test/dependencies/test_number_of_bombs.d @@ -0,0 +1,5 @@ +build/test/out/c/test_number_of_bombs.o: \ + test/Minesweeper/test_number_of_bombs.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + test/Minesweeper/../../src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/test/dependencies/test_number_of_bombs_runner.d b/build/test/dependencies/test_number_of_bombs_runner.d new file mode 100644 index 0000000..d910d9b --- /dev/null +++ b/build/test/dependencies/test_number_of_bombs_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_number_of_bombs_runner.o: \ + build/test/runners/test_number_of_bombs_runner.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/test_part_of_snake.d b/build/test/dependencies/test_part_of_snake.d new file mode 100644 index 0000000..6dec8fd --- /dev/null +++ b/build/test/dependencies/test_part_of_snake.d @@ -0,0 +1,5 @@ +build/test/out/c/test_part_of_snake.o: test/Snake/test_part_of_snake.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + test/Snake/../../src/main/c/Snake/snake_start.h \ + test/Snake/../../src/main/c/Snake/get_character.h diff --git a/build/test/dependencies/test_part_of_snake_runner.d b/build/test/dependencies/test_part_of_snake_runner.d new file mode 100644 index 0000000..3f37e86 --- /dev/null +++ b/build/test/dependencies/test_part_of_snake_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_part_of_snake_runner.o: \ + build/test/runners/test_part_of_snake_runner.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/test_tictactoe.d b/build/test/dependencies/test_tictactoe.d new file mode 100644 index 0000000..9b5c05c --- /dev/null +++ b/build/test/dependencies/test_tictactoe.d @@ -0,0 +1,4 @@ +build/test/out/c/test_tictactoe.o: test/test_tictactoe.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + src/main/c/GameTic_Tac_Toe/tictactoe.h diff --git a/build/test/dependencies/test_tictactoe_runner.d b/build/test/dependencies/test_tictactoe_runner.d new file mode 100644 index 0000000..fa84889 --- /dev/null +++ b/build/test/dependencies/test_tictactoe_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_tictactoe_runner.o: \ + build/test/runners/test_tictactoe_runner.c \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/out/c/get_character.o b/build/test/out/c/get_character.o new file mode 100644 index 0000000..1b8ddf9 Binary files /dev/null and b/build/test/out/c/get_character.o differ diff --git a/build/test/out/c/minesweeper_start.o b/build/test/out/c/minesweeper_start.o new file mode 100644 index 0000000..90e6d3f Binary files /dev/null and b/build/test/out/c/minesweeper_start.o differ diff --git a/build/test/out/c/snake_start.o b/build/test/out/c/snake_start.o new file mode 100644 index 0000000..cba1813 Binary files /dev/null and b/build/test/out/c/snake_start.o differ diff --git a/build/test/out/c/test_bomb_in_array.o b/build/test/out/c/test_bomb_in_array.o new file mode 100644 index 0000000..651d6c6 Binary files /dev/null and b/build/test/out/c/test_bomb_in_array.o differ diff --git a/build/test/out/c/test_bomb_in_array_runner.o b/build/test/out/c/test_bomb_in_array_runner.o new file mode 100644 index 0000000..1d1a534 Binary files /dev/null and b/build/test/out/c/test_bomb_in_array_runner.o differ diff --git a/build/test/out/c/test_collision.o b/build/test/out/c/test_collision.o new file mode 100644 index 0000000..542f42a Binary files /dev/null and b/build/test/out/c/test_collision.o differ diff --git a/build/test/out/c/test_collision_runner.o b/build/test/out/c/test_collision_runner.o new file mode 100644 index 0000000..56e133c Binary files /dev/null and b/build/test/out/c/test_collision_runner.o differ diff --git a/build/test/out/c/test_is_Valid_tile.o b/build/test/out/c/test_is_Valid_tile.o new file mode 100644 index 0000000..aeddeac Binary files /dev/null and b/build/test/out/c/test_is_Valid_tile.o differ diff --git a/build/test/out/c/test_is_Valid_tile_runner.o b/build/test/out/c/test_is_Valid_tile_runner.o new file mode 100644 index 0000000..f1c95db Binary files /dev/null and b/build/test/out/c/test_is_Valid_tile_runner.o differ diff --git a/build/test/out/c/test_moving_snake.o b/build/test/out/c/test_moving_snake.o new file mode 100644 index 0000000..829d7f1 Binary files /dev/null and b/build/test/out/c/test_moving_snake.o differ diff --git a/build/test/out/c/test_moving_snake_runner.o b/build/test/out/c/test_moving_snake_runner.o new file mode 100644 index 0000000..06ec999 Binary files /dev/null and b/build/test/out/c/test_moving_snake_runner.o differ diff --git a/build/test/out/c/test_number_of_bombs.o b/build/test/out/c/test_number_of_bombs.o new file mode 100644 index 0000000..1d66c5f Binary files /dev/null and b/build/test/out/c/test_number_of_bombs.o differ diff --git a/build/test/out/c/test_number_of_bombs_runner.o b/build/test/out/c/test_number_of_bombs_runner.o new file mode 100644 index 0000000..d3a3c43 Binary files /dev/null and b/build/test/out/c/test_number_of_bombs_runner.o differ diff --git a/build/test/out/c/test_part_of_snake.o b/build/test/out/c/test_part_of_snake.o new file mode 100644 index 0000000..934775c Binary files /dev/null and b/build/test/out/c/test_part_of_snake.o differ diff --git a/build/test/out/c/test_part_of_snake_runner.o b/build/test/out/c/test_part_of_snake_runner.o new file mode 100644 index 0000000..021fd43 Binary files /dev/null and b/build/test/out/c/test_part_of_snake_runner.o differ diff --git a/build/test/out/c/test_tictactoe_runner.o b/build/test/out/c/test_tictactoe_runner.o new file mode 100644 index 0000000..104bf35 Binary files /dev/null and b/build/test/out/c/test_tictactoe_runner.o differ diff --git a/build/test/out/test_bomb_in_array.out b/build/test/out/test_bomb_in_array.out new file mode 100755 index 0000000..a8ba57a Binary files /dev/null and b/build/test/out/test_bomb_in_array.out differ diff --git a/build/test/out/test_collision.out b/build/test/out/test_collision.out new file mode 100755 index 0000000..022a79c Binary files /dev/null and b/build/test/out/test_collision.out differ diff --git a/build/test/out/test_is_Valid_tile.out b/build/test/out/test_is_Valid_tile.out new file mode 100755 index 0000000..38aa278 Binary files /dev/null and b/build/test/out/test_is_Valid_tile.out differ diff --git a/build/test/out/test_moving_snake.out b/build/test/out/test_moving_snake.out new file mode 100755 index 0000000..e3f2dcf Binary files /dev/null and b/build/test/out/test_moving_snake.out differ diff --git a/build/test/out/test_number_of_bombs.out b/build/test/out/test_number_of_bombs.out new file mode 100755 index 0000000..44d20d7 Binary files /dev/null and b/build/test/out/test_number_of_bombs.out differ diff --git a/build/test/out/test_part_of_snake.out b/build/test/out/test_part_of_snake.out new file mode 100755 index 0000000..87a8574 Binary files /dev/null and b/build/test/out/test_part_of_snake.out differ diff --git a/build/test/preprocess/files/test_bomb_in_array.c b/build/test/preprocess/files/test_bomb_in_array.c new file mode 100644 index 0000000..14de752 --- /dev/null +++ b/build/test/preprocess/files/test_bomb_in_array.c @@ -0,0 +1,79 @@ +#include "build/temp/../../src/main/c/Minesweeper/minesweeper_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_bomb_in_array(void){ + + + + + + _Bool + + result; + + int array[] = {5, 9, 42, 6, 87, 95, 202, 13, 45 ,78}; + + int bomb = 42; + + int length = 10; + + + + + + result = array_contains_value(array, bomb, length); + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(22)));}} while(0); + +} + + + + + +void test_bomb_not_in_array(void){ + + + + + + _Bool + + result; + + int array[] = {5, 9, 42, 6, 87, 95, 202, 13, 45 ,78}; + + int bomb = 0; + + int length = 10; + + + + + + result = array_contains_value(array, bomb, length); + + + + + + do {if (!(result)) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(37)));}} while(0); + +} diff --git a/build/test/preprocess/files/test_collision.c b/build/test/preprocess/files/test_collision.c new file mode 100644 index 0000000..a159403 --- /dev/null +++ b/build/test/preprocess/files/test_collision.c @@ -0,0 +1,102 @@ +#include "src/main/c/Snake/get_character.h" +#include "src/main/c/Snake/snake_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_self_collision(void){ + + + + + + _Bool + + result; + + Snake snake = {1, 5, {6 + 16 * 6, 6 + 16 * 7, 7 + 16 * 7, 7 + 16 * 6, 6 + 16 * 6}}; + + + + + + result = check_if_dead(&snake); + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(21)));}} while(0); + +} + + + + + +void test_no_collision(void){ + + + + + + _Bool + + result; + + Snake snake = initialize_snake(); + + + + + + result = check_if_dead(&snake); + + + + + + do {if (!(result)) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(34)));}} while(0); + +} + + + + + +void test_wall_collision(void){ + + + + + + _Bool + + result; + + Snake snake = {-1, 4, {0 + 16 * 6, 1 + 16 * 6, 2 + 16 * 6, 3 + 16 * 6}}; + + + + + + result = check_if_dead(&snake); + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(47)));}} while(0); + +} diff --git a/build/test/preprocess/files/test_is_Valid_tile.c b/build/test/preprocess/files/test_is_Valid_tile.c new file mode 100644 index 0000000..6ad87c9 --- /dev/null +++ b/build/test/preprocess/files/test_is_Valid_tile.c @@ -0,0 +1,205 @@ +#include "build/temp/../../src/main/c/Minesweeper/minesweeper_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_detect_not_valid_tile_left(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0; + + int direction = 1; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(21), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_not_valid_tile_up(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0; + + int direction = 3; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(35), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_valid_tile_right(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0; + + int direction = 5; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_valid_tile_down(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0; + + int direction = 4; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0 + board.width)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(63), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_not_valid_tile_right(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = board.width * board.height - 1; + + int direction = 5; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(77), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_not_valid_tile_down(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = board.width * board.height - 1; + + int direction = 4; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(91), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/files/test_moving_snake.c b/build/test/preprocess/files/test_moving_snake.c new file mode 100644 index 0000000..b305c52 --- /dev/null +++ b/build/test/preprocess/files/test_moving_snake.c @@ -0,0 +1,142 @@ +#include "build/temp/../../src/main/c/Snake/get_character.h" +#include "build/temp/../../src/main/c/Snake/snake_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_moving_right(void){ + + + + + + _Bool + + result; + + Snake snake = {1, 3, {8 + 16 * 6, 7 + 16 * 6, 6 + 16 * 6}}; + + Snake expected = {1, 3, {9 + 16 * 6, 8 + 16 * 6, 7 + 16 * 6}}; + + + + + + move_snake(&snake); + + result = memcmp(&snake, &expected, sizeof(Snake)) == 0; + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(24)));}} while(0); + +} + + + +void test_moving_down(void){ + + + + + + _Bool + + result; + + Snake snake = {16, 3, {8 + 16 * 6, 7 + 16 * 6, 6 + 16 * 6}}; + + Snake expected = {16, 3, {8 + 16 * 7, 8 + 16 * 6, 7 + 16 * 6}}; + + + + + + move_snake(&snake); + + result = memcmp(&snake, &expected, sizeof(Snake)) == 0; + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(38)));}} while(0); + +} + + + +void test_moving_left(void){ + + + + + + _Bool + + result; + + Snake snake = {-1, 3, {8 + 16 * 6, 7 + 16 * 6, 6 + 16 * 6}}; + + Snake expected = {-1, 3, {7 + 16 * 6, 8 + 16 * 6, 7 + 16 * 6}}; + + + + + + move_snake(&snake); + + result = memcmp(&snake, &expected, sizeof(Snake)) == 0; + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(52)));}} while(0); + +} + + + +void test_moving_up(void){ + + + + + + _Bool + + result; + + Snake snake = {-16, 3, {8 + 16 * 6, 7 + 16 * 6, 6 + 16 * 6}}; + + Snake expected = {-16, 3, {8 + 16 * 5, 8 + 16 * 6, 7 + 16 * 6}}; + + + + + + move_snake(&snake); + + result = memcmp(&snake, &expected, sizeof(Snake)) == 0; + + + + + + do {if ((result)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(66)));}} while(0); + +} diff --git a/build/test/preprocess/files/test_number_of_bombs.c b/build/test/preprocess/files/test_number_of_bombs.c new file mode 100644 index 0000000..9b1981f --- /dev/null +++ b/build/test/preprocess/files/test_number_of_bombs.c @@ -0,0 +1,205 @@ +#include "build/temp/../../src/main/c/Minesweeper/minesweeper_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_no_bombs_placed_around_tile(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0 + board.width * 1; + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(21), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_searching_for_bombs_on_correct_tiles(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0 + board.width * 1; + + board.bombs[0] = 0 + board.width * 3; + + board.bombs[1] = 2 + board.width * 1; + + board.bombs[2] = board.width - 1 + board.width * 1; + + board.bombs[3] = 0 + board.width * (board.height - 1); + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(38), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_2_bombs_around_tile(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 0 + board.width * 1; + + board.bombs[0] = 0 + board.width * 2; + + board.bombs[1] = 1 + board.width * 1; + + board.bombs[2] = board.width - 1 + board.width * 1; + + board.bombs[3] = 0 + board.width * (board.height - 1); + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(55), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_5_bombs_around_tile(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 1 + board.width * 0; + + board.bombs[0] = 0 + board.width * 0; + + board.bombs[1] = 2 + board.width * 0; + + board.bombs[2] = 0 + board.width * 1; + + board.bombs[3] = 1 + board.width * 1; + + board.bombs[4] = 2 + board.width * 1; + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(73), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_8_bombs_around_tile(void){ + + + + int result; + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = 7 + board.width * 7; + + board.bombs[0] = 6 + board.width * 6; + + board.bombs[1] = 7 + board.width * 6; + + board.bombs[2] = 8 + board.width * 6; + + board.bombs[3] = 6 + board.width * 7; + + board.bombs[4] = 8 + board.width * 7; + + board.bombs[5] = 6 + board.width * 8; + + board.bombs[6] = 7 + board.width * 8; + + board.bombs[7] = 8 + board.width * 8; + + + + + + result = number_of_bombs(&board, tile); + + + + + + UnityAssertEqualNumber((UNITY_INT)((8)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(94), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/files/test_part_of_snake.c b/build/test/preprocess/files/test_part_of_snake.c new file mode 100644 index 0000000..b488cb0 --- /dev/null +++ b/build/test/preprocess/files/test_part_of_snake.c @@ -0,0 +1,102 @@ +#include "build/temp/../../src/main/c/Snake/get_character.h" +#include "build/temp/../../src/main/c/Snake/snake_start.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + +void setUp(void){} + +void tearDown(void){} + + + + + +void test_find_head(void){ + + + + int result; + + Snake snake = initialize_snake(); + + + + + + result = part_of_snake(&snake, 8 * 16 + 8); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(20), UNITY_DISPLAY_STYLE_INT); + +} + + + + + +void test_get_correct_index(void){ + + + + int result; + + Snake snake = initialize_snake(); + + + + + + result = part_of_snake(&snake, 8 * 16 + 6); + + + + + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(33), UNITY_DISPLAY_STYLE_INT); + +} + + + + + +void test_snake_not_on_tile(void){ + + + + int result; + + Snake snake = initialize_snake(); + + + + + + result = part_of_snake(&snake, 6 * 16 + 6); + + + + + + UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(46), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/files/test_tictactoe.c b/build/test/preprocess/files/test_tictactoe.c new file mode 100644 index 0000000..7971f22 --- /dev/null +++ b/build/test/preprocess/files/test_tictactoe.c @@ -0,0 +1,105 @@ +#include "src/main/c/GameTic_Tac_Toe/tictactoe.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + + + +void setUp(void){ + + + +} + +void tearDown(void){ + +} + + + + + +void test_if_not_identical(void){ + + + + char result; + + char a = 'a', b = 'b', c = 'c'; + + + + result = checkLine(a, b, c); + + + + + + UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((' ')), (UNITY_INT)(UNITY_INT8 )((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_CHAR); + +} + + + + + +void test_if_identical(void){ + + + + char result; + + char a = 'a', b = 'a', c = 'a'; + + + + result = checkLine(a, b, c); + + + + + + UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )((a)), (UNITY_INT)(UNITY_INT8 )((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(34), UNITY_DISPLAY_STYLE_CHAR); + +} + + + +void test_checkLine_horizontalerGewinner(void) { + + + + char result; + + char a = 'X', b = 'X', c = 'X'; + + + + + + result = checkLine(a, b, c); + + + + + + UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(('X')), (UNITY_INT)(UNITY_INT8 )((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(46), UNITY_DISPLAY_STYLE_CHAR); + +} + +} diff --git a/build/test/preprocess/includes/test_bomb_in_array.c b/build/test/preprocess/includes/test_bomb_in_array.c new file mode 100644 index 0000000..5630e0a --- /dev/null +++ b/build/test/preprocess/includes/test_bomb_in_array.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- build/temp/../../src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/test/preprocess/includes/test_collision.c b/build/test/preprocess/includes/test_collision.c new file mode 100644 index 0000000..a508f7d --- /dev/null +++ b/build/test/preprocess/includes/test_collision.c @@ -0,0 +1,4 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/Snake/snake_start.h +- src/main/c/Snake/get_character.h diff --git a/build/test/preprocess/includes/test_is_Valid_tile.c b/build/test/preprocess/includes/test_is_Valid_tile.c new file mode 100644 index 0000000..5630e0a --- /dev/null +++ b/build/test/preprocess/includes/test_is_Valid_tile.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- build/temp/../../src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/test/preprocess/includes/test_moving_snake.c b/build/test/preprocess/includes/test_moving_snake.c new file mode 100644 index 0000000..879a735 --- /dev/null +++ b/build/test/preprocess/includes/test_moving_snake.c @@ -0,0 +1,4 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- build/temp/../../src/main/c/Snake/snake_start.h +- build/temp/../../src/main/c/Snake/get_character.h diff --git a/build/test/preprocess/includes/test_number_of_bombs.c b/build/test/preprocess/includes/test_number_of_bombs.c new file mode 100644 index 0000000..5630e0a --- /dev/null +++ b/build/test/preprocess/includes/test_number_of_bombs.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- build/temp/../../src/main/c/Minesweeper/minesweeper_start.h diff --git a/build/test/preprocess/includes/test_part_of_snake.c b/build/test/preprocess/includes/test_part_of_snake.c new file mode 100644 index 0000000..879a735 --- /dev/null +++ b/build/test/preprocess/includes/test_part_of_snake.c @@ -0,0 +1,4 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- build/temp/../../src/main/c/Snake/snake_start.h +- build/temp/../../src/main/c/Snake/get_character.h diff --git a/build/test/preprocess/includes/test_tictactoe.c b/build/test/preprocess/includes/test_tictactoe.c new file mode 100644 index 0000000..f398b3c --- /dev/null +++ b/build/test/preprocess/includes/test_tictactoe.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/GameTic_Tac_Toe/tictactoe.h diff --git a/build/test/results/test_bomb_in_array.pass b/build/test/results/test_bomb_in_array.pass new file mode 100644 index 0000000..9327716 --- /dev/null +++ b/build/test/results/test_bomb_in_array.pass @@ -0,0 +1,22 @@ +--- +:source: + :path: test/Minesweeper + :file: test_bomb_in_array.c +:successes: +- :test: test_bomb_in_array + :line: 11 + :message: '' + :unity_test_time: 0 +- :test: test_bomb_not_in_array + :line: 26 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 2 + :passed: 2 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.00173795400041854 diff --git a/build/test/results/test_collision.pass b/build/test/results/test_collision.pass new file mode 100644 index 0000000..ca7129a --- /dev/null +++ b/build/test/results/test_collision.pass @@ -0,0 +1,26 @@ +--- +:source: + :path: test/Snake + :file: test_collision.c +:successes: +- :test: test_self_collision + :line: 12 + :message: '' + :unity_test_time: 0 +- :test: test_no_collision + :line: 25 + :message: '' + :unity_test_time: 0 +- :test: test_wall_collision + :line: 38 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 3 + :passed: 3 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0023196109978016466 diff --git a/build/test/results/test_is_Valid_tile.pass b/build/test/results/test_is_Valid_tile.pass new file mode 100644 index 0000000..dea454b --- /dev/null +++ b/build/test/results/test_is_Valid_tile.pass @@ -0,0 +1,38 @@ +--- +:source: + :path: test/Minesweeper + :file: test_is_Valid_tile.c +:successes: +- :test: test_detect_not_valid_tile_left + :line: 10 + :message: '' + :unity_test_time: 0 +- :test: test_detect_not_valid_tile_up + :line: 24 + :message: '' + :unity_test_time: 0 +- :test: test_detect_valid_tile_right + :line: 38 + :message: '' + :unity_test_time: 0 +- :test: test_detect_valid_tile_down + :line: 52 + :message: '' + :unity_test_time: 0 +- :test: test_detect_not_valid_tile_right + :line: 66 + :message: '' + :unity_test_time: 0 +- :test: test_detect_not_valid_tile_down + :line: 80 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 6 + :passed: 6 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.002173025997763034 diff --git a/build/test/results/test_moving_snake.pass b/build/test/results/test_moving_snake.pass new file mode 100644 index 0000000..2da558d --- /dev/null +++ b/build/test/results/test_moving_snake.pass @@ -0,0 +1,30 @@ +--- +:source: + :path: test/Snake + :file: test_moving_snake.c +:successes: +- :test: test_moving_right + :line: 13 + :message: '' + :unity_test_time: 0 +- :test: test_moving_down + :line: 27 + :message: '' + :unity_test_time: 0 +- :test: test_moving_left + :line: 41 + :message: '' + :unity_test_time: 0 +- :test: test_moving_up + :line: 55 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 4 + :passed: 4 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0014848970022285357 diff --git a/build/test/results/test_number_of_bombs.pass b/build/test/results/test_number_of_bombs.pass new file mode 100644 index 0000000..2f16863 --- /dev/null +++ b/build/test/results/test_number_of_bombs.pass @@ -0,0 +1,34 @@ +--- +:source: + :path: test/Minesweeper + :file: test_number_of_bombs.c +:successes: +- :test: test_no_bombs_placed_around_tile + :line: 11 + :message: '' + :unity_test_time: 0 +- :test: test_searching_for_bombs_on_correct_tiles + :line: 24 + :message: '' + :unity_test_time: 0 +- :test: test_2_bombs_around_tile + :line: 41 + :message: '' + :unity_test_time: 0 +- :test: test_5_bombs_around_tile + :line: 58 + :message: '' + :unity_test_time: 0 +- :test: test_8_bombs_around_tile + :line: 76 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 5 + :passed: 5 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0023246400014613755 diff --git a/build/test/results/test_part_of_snake.pass b/build/test/results/test_part_of_snake.pass new file mode 100644 index 0000000..dd4d43d --- /dev/null +++ b/build/test/results/test_part_of_snake.pass @@ -0,0 +1,26 @@ +--- +:source: + :path: test/Snake + :file: test_part_of_snake.c +:successes: +- :test: test_find_head + :line: 11 + :message: '' + :unity_test_time: 0 +- :test: test_get_correct_index + :line: 24 + :message: '' + :unity_test_time: 0 +- :test: test_snake_not_on_tile + :line: 37 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 3 + :passed: 3 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0021876099999644794 diff --git a/build/test/results/test_template.pass b/build/test/results/test_template.pass index ac2a353..1e7a02f 100644 --- a/build/test/results/test_template.pass +++ b/build/test/results/test_template.pass @@ -19,4 +19,4 @@ :failed: 0 :ignored: 0 :stdout: [] -:time: 0.002492974977940321 +:time: 0.002167227001336869 diff --git a/build/test/runners/test_bomb_in_array_runner.c b/build/test/runners/test_bomb_in_array_runner.c new file mode 100644 index 0000000..b3dbc90 --- /dev/null +++ b/build/test/runners/test_bomb_in_array_runner.c @@ -0,0 +1,83 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_bomb_in_array(void); +extern void test_bomb_not_in_array(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + CMock_Verify(); +} + +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_bomb_in_array.c"); + run_test(test_bomb_in_array, "test_bomb_in_array", 11); + run_test(test_bomb_not_in_array, "test_bomb_not_in_array", 26); + + return UnityEnd(); +} diff --git a/build/test/runners/test_collision_runner.c b/build/test/runners/test_collision_runner.c new file mode 100644 index 0000000..d726b30 --- /dev/null +++ b/build/test/runners/test_collision_runner.c @@ -0,0 +1,85 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_self_collision(void); +extern void test_no_collision(void); +extern void test_wall_collision(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + CMock_Verify(); +} + +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_collision.c"); + run_test(test_self_collision, "test_self_collision", 12); + run_test(test_no_collision, "test_no_collision", 25); + run_test(test_wall_collision, "test_wall_collision", 38); + + return UnityEnd(); +} diff --git a/build/test/runners/test_is_Valid_tile_runner.c b/build/test/runners/test_is_Valid_tile_runner.c new file mode 100644 index 0000000..13f3de7 --- /dev/null +++ b/build/test/runners/test_is_Valid_tile_runner.c @@ -0,0 +1,91 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_detect_not_valid_tile_left(void); +extern void test_detect_not_valid_tile_up(void); +extern void test_detect_valid_tile_right(void); +extern void test_detect_valid_tile_down(void); +extern void test_detect_not_valid_tile_right(void); +extern void test_detect_not_valid_tile_down(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + CMock_Verify(); +} + +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_is_Valid_tile.c"); + run_test(test_detect_not_valid_tile_left, "test_detect_not_valid_tile_left", 10); + run_test(test_detect_not_valid_tile_up, "test_detect_not_valid_tile_up", 24); + run_test(test_detect_valid_tile_right, "test_detect_valid_tile_right", 38); + run_test(test_detect_valid_tile_down, "test_detect_valid_tile_down", 52); + run_test(test_detect_not_valid_tile_right, "test_detect_not_valid_tile_right", 66); + run_test(test_detect_not_valid_tile_down, "test_detect_not_valid_tile_down", 80); + + return UnityEnd(); +} diff --git a/build/test/runners/test_moving_snake_runner.c b/build/test/runners/test_moving_snake_runner.c new file mode 100644 index 0000000..8f786fb --- /dev/null +++ b/build/test/runners/test_moving_snake_runner.c @@ -0,0 +1,87 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_moving_right(void); +extern void test_moving_down(void); +extern void test_moving_left(void); +extern void test_moving_up(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + CMock_Verify(); +} + +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_moving_snake.c"); + run_test(test_moving_right, "test_moving_right", 13); + run_test(test_moving_down, "test_moving_down", 27); + run_test(test_moving_left, "test_moving_left", 41); + run_test(test_moving_up, "test_moving_up", 55); + + return UnityEnd(); +} diff --git a/build/test/runners/test_number_of_bombs_runner.c b/build/test/runners/test_number_of_bombs_runner.c new file mode 100644 index 0000000..e6e4376 --- /dev/null +++ b/build/test/runners/test_number_of_bombs_runner.c @@ -0,0 +1,89 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_no_bombs_placed_around_tile(void); +extern void test_searching_for_bombs_on_correct_tiles(void); +extern void test_2_bombs_around_tile(void); +extern void test_5_bombs_around_tile(void); +extern void test_8_bombs_around_tile(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + CMock_Verify(); +} + +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_number_of_bombs.c"); + run_test(test_no_bombs_placed_around_tile, "test_no_bombs_placed_around_tile", 11); + run_test(test_searching_for_bombs_on_correct_tiles, "test_searching_for_bombs_on_correct_tiles", 24); + run_test(test_2_bombs_around_tile, "test_2_bombs_around_tile", 41); + run_test(test_5_bombs_around_tile, "test_5_bombs_around_tile", 58); + run_test(test_8_bombs_around_tile, "test_8_bombs_around_tile", 76); + + return UnityEnd(); +} diff --git a/build/test/runners/test_part_of_snake_runner.c b/build/test/runners/test_part_of_snake_runner.c new file mode 100644 index 0000000..0f7e680 --- /dev/null +++ b/build/test/runners/test_part_of_snake_runner.c @@ -0,0 +1,85 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_find_head(void); +extern void test_get_correct_index(void); +extern void test_snake_not_on_tile(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + CMock_Verify(); +} + +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_part_of_snake.c"); + run_test(test_find_head, "test_find_head", 11); + run_test(test_get_correct_index, "test_get_correct_index", 24); + run_test(test_snake_not_on_tile, "test_snake_not_on_tile", 37); + + return UnityEnd(); +} diff --git a/build/test/runners/test_tictactoe_runner.c b/build/test/runners/test_tictactoe_runner.c new file mode 100644 index 0000000..0cbfabd --- /dev/null +++ b/build/test/runners/test_tictactoe_runner.c @@ -0,0 +1,85 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ + +/*=======Automagically Detected Files To Include=====*/ +#include "unity.h" + +int GlobalExpectCount; +int GlobalVerifyOrder; +char* GlobalOrderError; + +/*=======External Functions This Runner Calls=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void test_if_not_identical(void); +extern void test_if_identical(void); +extern void test_checkLine_horizontalerGewinner(void); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Test Reset Options=====*/ +void resetTest(void); +void resetTest(void) +{ + tearDown(); + CMock_Verify(); + CMock_Destroy(); + CMock_Init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + CMock_Verify(); +} + +/*=======Test Runner Used To Run Each Test=====*/ +static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + CMock_Init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + CMock_Verify(); + } + CMock_Destroy(); + UNITY_EXEC_TIME_STOP(); + UnityConcludeTest(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_tictactoe.c"); + run_test(test_if_not_identical, "test_if_not_identical", 14); + run_test(test_if_identical, "test_if_identical", 26); + run_test(test_checkLine_horizontalerGewinner, "test_checkLine_horizontalerGewinner", 37); + + return UnityEnd(); +} diff --git a/test/Minesweeper/test_is_Valid_tile.c b/test/Minesweeper/test_is_Valid_tile.c index 503146d..058be3b 100644 --- a/test/Minesweeper/test_is_Valid_tile.c +++ b/test/Minesweeper/test_is_Valid_tile.c @@ -7,7 +7,7 @@ void setUp(void){} void tearDown(void){} -void test_detect_not_valid_tile(void){ +void test_detect_not_valid_tile_left(void){ /* arrange */ Minesweeper_Board board = initialize_minesweeper(); int tile = 0; @@ -21,6 +21,20 @@ void test_detect_not_valid_tile(void){ TEST_ASSERT_EQUAL_INT(-1, result);//not valid tile } +void test_detect_not_valid_tile_up(void){ + /* arrange */ + Minesweeper_Board board = initialize_minesweeper(); + int tile = 0; + int direction = 3; + int result; + + /* act */ + result = is_Valid_tile(&board, tile, direction); + + /* assert */ + TEST_ASSERT_EQUAL_INT(-1, result);//not valid tile +} + void test_detect_valid_tile_right(void){ /* arrange */ Minesweeper_Board board = initialize_minesweeper(); @@ -49,4 +63,32 @@ void test_detect_valid_tile_down(void){ TEST_ASSERT_EQUAL_INT(0 + board.width, result);//not valid tile } +void test_detect_not_valid_tile_right(void){ + /* arrange */ + Minesweeper_Board board = initialize_minesweeper(); + int tile = board.width * board.height - 1; + int direction = 5; + int result; + + /* act */ + result = is_Valid_tile(&board, tile, direction); + + /* assert */ + TEST_ASSERT_EQUAL_INT(-1, result);//not valid tile +} + +void test_detect_not_valid_tile_down(void){ + /* arrange */ + Minesweeper_Board board = initialize_minesweeper(); + int tile = board.width * board.height - 1; + int direction = 4; + int result; + + /* act */ + result = is_Valid_tile(&board, tile, direction); + + /* assert */ + TEST_ASSERT_EQUAL_INT(-1, result);//not valid tile +} + #endif // TEST \ No newline at end of file