diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ef6068e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "files.associations": { + "*.embeddedhtml": "html", + "unistd.h": "c", + "fcntl.h": "c", + "stdio.h": "c", + "types.h": "c" + } +} \ No newline at end of file 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..cab5c66 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 src/main/c/Pong/pong.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/pong.d b/build/release/dependencies/pong.d new file mode 100644 index 0000000..4a40a82 --- /dev/null +++ b/build/release/dependencies/pong.d @@ -0,0 +1 @@ +build/release/out/c/pong.o: src/main/c/Pong/pong.c 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..17adbcd 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/pong.o b/build/release/out/c/pong.o new file mode 100644 index 0000000..6cbb7e4 Binary files /dev/null and b/build/release/out/c/pong.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..39f5d21 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 deleted file mode 100755 index 7e9f672..0000000 Binary files a/build/release/project.out and /dev/null differ diff --git a/build/test/cache/defines_dependency.yml b/build/test/cache/defines_dependency.yml index b227090..6dae52a 100644 --- a/build/test/cache/defines_dependency.yml +++ b/build/test/cache/defines_dependency.yml @@ -1,3 +1,13 @@ --- 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 +src/main/c/Pong/pong.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_checkCollision.c b/build/test/cache/test_checkCollision.c new file mode 100644 index 0000000..79e7083 --- /dev/null +++ b/build/test/cache/test_checkCollision.c @@ -0,0 +1,143 @@ +#include "src/main/c/Pong/pong.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + + + +typedef struct { + + int x; + + int y; + + int speedX; + + int speedY; + +} Ball; + + + +typedef struct { + + int x; + + int y; + + int width; + + int height; + +} Paddle; + + + +void setUp(void){ + + + +} + + + +void tearDown(void){ + +} + + + +void test_checkCollision(void){ + + Ball ball = {10, 10, 1, 1}; + + Paddle paddle = {50, 10, 5, 10}; + + + + + + ball.x = 0; + + int result1 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result1)), ( + + ((void *)0) + + ), (UNITY_UINT)(35), UNITY_DISPLAY_STYLE_INT); + + + + ball.x = 40 - 1; + + int result2 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result2)), ( + + ((void *)0) + + ), (UNITY_UINT)(39), UNITY_DISPLAY_STYLE_INT); + + + + + + ball.x = 5; + + ball.y = 0; + + int result3 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result3)), ( + + ((void *)0) + + ), (UNITY_UINT)(45), UNITY_DISPLAY_STYLE_INT); + + + + ball.y = 20 - 1; + + int result4 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result4)), ( + + ((void *)0) + + ), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT); + + + + + + ball.x = paddle.x - 1; + + ball.y = paddle.y + 1; + + int result5 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result5)), ( + + ((void *)0) + + ), (UNITY_UINT)(55), UNITY_DISPLAY_STYLE_INT); + + + + ball.x = paddle.x + 1; + + ball.y = paddle.y + 1; + + int result6 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result6)), ( + + ((void *)0) + + ), (UNITY_UINT)(60), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/cache/test_checkGameEnd.c b/build/test/cache/test_checkGameEnd.c new file mode 100644 index 0000000..3c0d662 --- /dev/null +++ b/build/test/cache/test_checkGameEnd.c @@ -0,0 +1,69 @@ +#include "src/main/c/Pong/pong.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_checkGameEnd(void){ + + + + int maxScore = 5; + + int score1 = 4, score2 = 2; + + + + + + int result = checkGameEnd(score1, score2, maxScore); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); + + + + + + score1 = 5; + + result = checkGameEnd(score1, score2, maxScore); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(28), UNITY_DISPLAY_STYLE_INT); + + + + + + + +} diff --git a/build/test/cache/test_clearScreen.c b/build/test/cache/test_clearScreen.c new file mode 100644 index 0000000..74ec6bf --- /dev/null +++ b/build/test/cache/test_clearScreen.c @@ -0,0 +1,73 @@ +#include "src/main/c/Pong/pong.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + + + + + +char screen[20][40 +1]; + + + +void setUp(void){ + + + +} + + + +void tearDown(void){ + +} + + + +void test_clearScreen(void){ + + + + int i, j; + + for (i = 0; i < 20; i++) { + + for (j = 0; j < 40; j++) { + + screen[i][j] = ' '; + + } + + screen[i][j] = '\0'; + + } + + + + + + clearScreen(); + + + + + + for (i = 0; i < 20; i++) { + + for (j = 0; j < 40; j++) { + + UnityAssertEqualNumber((UNITY_INT)((' ')), (UNITY_INT)((screen[i][j])), ( + + ((void *)0) + + ), (UNITY_UINT)(33), UNITY_DISPLAY_STYLE_INT); + + } + + } + +} 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..5911aa4 --- /dev/null +++ b/build/test/cache/test_is_Valid_tile.c @@ -0,0 +1,269 @@ +#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 = 2; + + 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_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)(49), 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)(63), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_valid_tile_left(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = board.width * board.height - 1; + + int direction = 2; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((board.width * board.height - 2)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(77), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_valid_tile_up(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = board.width * board.height - 1; + + int direction = 3; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((board.width * (board.height - 1) - 1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(91), 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)(105), 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)(119), 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_playerInputMovement.c b/build/test/cache/test_playerInputMovement.c new file mode 100644 index 0000000..d38ca76 --- /dev/null +++ b/build/test/cache/test_playerInputMovement.c @@ -0,0 +1,83 @@ +#include "src/main/c/Pong/pong.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + +typedef struct { + + int x; + + int y; + + int speedX; + + int speedY; + +} Paddle; + + + + + +void setUp(void){ + + + +} + + + +void tearDown(void){ + +} + + + +void test_playerInputMovement(void){ + + + + int paddlePositionY = 10; + + int userInput = -1; + + int expectedY = paddlePositionY - 1; + + + + processPlayerInput(&paddlePositionY, userInput); + + UnityAssertEqualNumber((UNITY_INT)((expectedY)), (UNITY_INT)((paddlePositionY)), ( + + ((void *)0) + + ), (UNITY_UINT)(27), UNITY_DISPLAY_STYLE_INT); + + + + + + userInput = 1; + + expectedY = paddlePositionY + 1; + + + + + + processPlayerInput(&paddlePositionY, userInput); + + UnityAssertEqualNumber((UNITY_INT)((expectedY)), (UNITY_INT)((paddlePositionY)), ( + + ((void *)0) + + ), (UNITY_UINT)(35), UNITY_DISPLAY_STYLE_INT); + + + + + + + +} diff --git a/build/test/cache/test_pong.c b/build/test/cache/test_pong.c new file mode 100644 index 0000000..7e1dfbf --- /dev/null +++ b/build/test/cache/test_pong.c @@ -0,0 +1,51 @@ +#include "src/main/c/Pong/pong.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_input_all_5(void){ + + + + int a = 4, b = 5; + + + + + + resetScore( &a, &b ); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((a)), ( + + ((void *)0) + + ), (UNITY_UINT)(21), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((b)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), 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..e69de29 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/pong.d b/build/test/dependencies/pong.d new file mode 100644 index 0000000..9bafeb3 --- /dev/null +++ b/build/test/dependencies/pong.d @@ -0,0 +1 @@ +build/test/out/c/pong.o: src/main/c/Pong/pong.c 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_checkCollision.d b/build/test/dependencies/test_checkCollision.d new file mode 100644 index 0000000..598f40e --- /dev/null +++ b/build/test/dependencies/test_checkCollision.d @@ -0,0 +1,4 @@ +build/test/out/c/test_checkCollision.o: test/Pong/test_checkCollision.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/Pong/pong.h diff --git a/build/test/dependencies/test_checkCollision_runner.d b/build/test/dependencies/test_checkCollision_runner.d new file mode 100644 index 0000000..8caa0f9 --- /dev/null +++ b/build/test/dependencies/test_checkCollision_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_checkCollision_runner.o: \ + build/test/runners/test_checkCollision_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_checkGameEnd.d b/build/test/dependencies/test_checkGameEnd.d new file mode 100644 index 0000000..0d4bf78 --- /dev/null +++ b/build/test/dependencies/test_checkGameEnd.d @@ -0,0 +1,4 @@ +build/test/out/c/test_checkGameEnd.o: test/Pong/test_checkGameEnd.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/Pong/pong.h diff --git a/build/test/dependencies/test_checkGameEnd_runner.d b/build/test/dependencies/test_checkGameEnd_runner.d new file mode 100644 index 0000000..74bebf4 --- /dev/null +++ b/build/test/dependencies/test_checkGameEnd_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_checkGameEnd_runner.o: \ + build/test/runners/test_checkGameEnd_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_clearScreen.d b/build/test/dependencies/test_clearScreen.d new file mode 100644 index 0000000..7f5431c --- /dev/null +++ b/build/test/dependencies/test_clearScreen.d @@ -0,0 +1,4 @@ +build/test/out/c/test_clearScreen.o: test/Pong/test_clearScreen.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/Pong/pong.h diff --git a/build/test/dependencies/test_clearScreen_runner.d b/build/test/dependencies/test_clearScreen_runner.d new file mode 100644 index 0000000..0f74b3c --- /dev/null +++ b/build/test/dependencies/test_clearScreen_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_clearScreen_runner.o: \ + build/test/runners/test_clearScreen_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_playerInputMovement.d b/build/test/dependencies/test_playerInputMovement.d new file mode 100644 index 0000000..a22d018 --- /dev/null +++ b/build/test/dependencies/test_playerInputMovement.d @@ -0,0 +1,5 @@ +build/test/out/c/test_playerInputMovement.o: \ + test/Pong/test_playerInputMovement.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/Pong/pong.h diff --git a/build/test/dependencies/test_playerInputMovement_runner.d b/build/test/dependencies/test_playerInputMovement_runner.d new file mode 100644 index 0000000..c2f9cb9 --- /dev/null +++ b/build/test/dependencies/test_playerInputMovement_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_playerInputMovement_runner.o: \ + build/test/runners/test_playerInputMovement_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_pong.d b/build/test/dependencies/test_pong.d new file mode 100644 index 0000000..de38849 --- /dev/null +++ b/build/test/dependencies/test_pong.d @@ -0,0 +1,4 @@ +build/test/out/c/test_pong.o: test/Pong/test_pong.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/Pong/pong.h diff --git a/build/test/dependencies/test_pong_runner.d b/build/test/dependencies/test_pong_runner.d new file mode 100644 index 0000000..ae30bd9 --- /dev/null +++ b/build/test/dependencies/test_pong_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_pong_runner.o: \ + build/test/runners/test_pong_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..f4ff40e --- /dev/null +++ b/build/test/dependencies/test_tictactoe.d @@ -0,0 +1 @@ +build/test/out/c/test_tictactoe.o: test/test_tictactoe.c 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..10c6f27 Binary files /dev/null and b/build/test/out/c/minesweeper_start.o differ diff --git a/build/test/out/c/pong.o b/build/test/out/c/pong.o new file mode 100644 index 0000000..7ed8663 Binary files /dev/null and b/build/test/out/c/pong.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_checkCollision.o b/build/test/out/c/test_checkCollision.o new file mode 100644 index 0000000..dd26e7b Binary files /dev/null and b/build/test/out/c/test_checkCollision.o differ diff --git a/build/test/out/c/test_checkCollision_runner.o b/build/test/out/c/test_checkCollision_runner.o new file mode 100644 index 0000000..747c52e Binary files /dev/null and b/build/test/out/c/test_checkCollision_runner.o differ diff --git a/build/test/out/c/test_checkGameEnd.o b/build/test/out/c/test_checkGameEnd.o new file mode 100644 index 0000000..1a23238 Binary files /dev/null and b/build/test/out/c/test_checkGameEnd.o differ diff --git a/build/test/out/c/test_checkGameEnd_runner.o b/build/test/out/c/test_checkGameEnd_runner.o new file mode 100644 index 0000000..caad412 Binary files /dev/null and b/build/test/out/c/test_checkGameEnd_runner.o differ diff --git a/build/test/out/c/test_clearScreen.o b/build/test/out/c/test_clearScreen.o new file mode 100644 index 0000000..53e83a8 Binary files /dev/null and b/build/test/out/c/test_clearScreen.o differ diff --git a/build/test/out/c/test_clearScreen_runner.o b/build/test/out/c/test_clearScreen_runner.o new file mode 100644 index 0000000..a4e758e Binary files /dev/null and b/build/test/out/c/test_clearScreen_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..ac4d5d3 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..84ab5b4 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_playerInputMovement.o b/build/test/out/c/test_playerInputMovement.o new file mode 100644 index 0000000..0c89b5e Binary files /dev/null and b/build/test/out/c/test_playerInputMovement.o differ diff --git a/build/test/out/c/test_playerInputMovement_runner.o b/build/test/out/c/test_playerInputMovement_runner.o new file mode 100644 index 0000000..870cc10 Binary files /dev/null and b/build/test/out/c/test_playerInputMovement_runner.o differ diff --git a/build/test/out/c/test_pong.o b/build/test/out/c/test_pong.o new file mode 100644 index 0000000..a6be32c Binary files /dev/null and b/build/test/out/c/test_pong.o differ diff --git a/build/test/out/c/test_pong_runner.o b/build/test/out/c/test_pong_runner.o new file mode 100644 index 0000000..77ffebf Binary files /dev/null and b/build/test/out/c/test_pong_runner.o differ diff --git a/build/test/out/c/test_tictactoe.o b/build/test/out/c/test_tictactoe.o new file mode 100644 index 0000000..a704cef Binary files /dev/null and b/build/test/out/c/test_tictactoe.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..eff4dfd 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..a2618c0 Binary files /dev/null and b/build/test/out/test_bomb_in_array.out differ diff --git a/build/test/out/test_checkCollision.out b/build/test/out/test_checkCollision.out new file mode 100755 index 0000000..4a9b6f9 Binary files /dev/null and b/build/test/out/test_checkCollision.out differ diff --git a/build/test/out/test_checkGameEnd.out b/build/test/out/test_checkGameEnd.out new file mode 100755 index 0000000..476ee5f Binary files /dev/null and b/build/test/out/test_checkGameEnd.out differ diff --git a/build/test/out/test_clearScreen.out b/build/test/out/test_clearScreen.out new file mode 100755 index 0000000..2429c48 Binary files /dev/null and b/build/test/out/test_clearScreen.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..4105934 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..7ae6181 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/out/test_playerInputMovement.out b/build/test/out/test_playerInputMovement.out new file mode 100755 index 0000000..3b9604e Binary files /dev/null and b/build/test/out/test_playerInputMovement.out differ diff --git a/build/test/out/test_pong.out b/build/test/out/test_pong.out new file mode 100755 index 0000000..a2c366e Binary files /dev/null and b/build/test/out/test_pong.out differ diff --git a/build/test/out/test_tictactoe.out b/build/test/out/test_tictactoe.out new file mode 100755 index 0000000..3718d07 Binary files /dev/null and b/build/test/out/test_tictactoe.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_checkCollision.c b/build/test/preprocess/files/test_checkCollision.c new file mode 100644 index 0000000..79e7083 --- /dev/null +++ b/build/test/preprocess/files/test_checkCollision.c @@ -0,0 +1,143 @@ +#include "src/main/c/Pong/pong.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + + + +typedef struct { + + int x; + + int y; + + int speedX; + + int speedY; + +} Ball; + + + +typedef struct { + + int x; + + int y; + + int width; + + int height; + +} Paddle; + + + +void setUp(void){ + + + +} + + + +void tearDown(void){ + +} + + + +void test_checkCollision(void){ + + Ball ball = {10, 10, 1, 1}; + + Paddle paddle = {50, 10, 5, 10}; + + + + + + ball.x = 0; + + int result1 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result1)), ( + + ((void *)0) + + ), (UNITY_UINT)(35), UNITY_DISPLAY_STYLE_INT); + + + + ball.x = 40 - 1; + + int result2 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result2)), ( + + ((void *)0) + + ), (UNITY_UINT)(39), UNITY_DISPLAY_STYLE_INT); + + + + + + ball.x = 5; + + ball.y = 0; + + int result3 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result3)), ( + + ((void *)0) + + ), (UNITY_UINT)(45), UNITY_DISPLAY_STYLE_INT); + + + + ball.y = 20 - 1; + + int result4 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result4)), ( + + ((void *)0) + + ), (UNITY_UINT)(49), UNITY_DISPLAY_STYLE_INT); + + + + + + ball.x = paddle.x - 1; + + ball.y = paddle.y + 1; + + int result5 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result5)), ( + + ((void *)0) + + ), (UNITY_UINT)(55), UNITY_DISPLAY_STYLE_INT); + + + + ball.x = paddle.x + 1; + + ball.y = paddle.y + 1; + + int result6 = checkCollision(ball, paddle.y, paddle.y); + + UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result6)), ( + + ((void *)0) + + ), (UNITY_UINT)(60), UNITY_DISPLAY_STYLE_INT); + +} diff --git a/build/test/preprocess/files/test_checkGameEnd.c b/build/test/preprocess/files/test_checkGameEnd.c new file mode 100644 index 0000000..3c0d662 --- /dev/null +++ b/build/test/preprocess/files/test_checkGameEnd.c @@ -0,0 +1,69 @@ +#include "src/main/c/Pong/pong.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_checkGameEnd(void){ + + + + int maxScore = 5; + + int score1 = 4, score2 = 2; + + + + + + int result = checkGameEnd(score1, score2, maxScore); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); + + + + + + score1 = 5; + + result = checkGameEnd(score1, score2, maxScore); + + UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(28), UNITY_DISPLAY_STYLE_INT); + + + + + + + +} diff --git a/build/test/preprocess/files/test_clearScreen.c b/build/test/preprocess/files/test_clearScreen.c new file mode 100644 index 0000000..74ec6bf --- /dev/null +++ b/build/test/preprocess/files/test_clearScreen.c @@ -0,0 +1,73 @@ +#include "src/main/c/Pong/pong.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + + + + + +char screen[20][40 +1]; + + + +void setUp(void){ + + + +} + + + +void tearDown(void){ + +} + + + +void test_clearScreen(void){ + + + + int i, j; + + for (i = 0; i < 20; i++) { + + for (j = 0; j < 40; j++) { + + screen[i][j] = ' '; + + } + + screen[i][j] = '\0'; + + } + + + + + + clearScreen(); + + + + + + for (i = 0; i < 20; i++) { + + for (j = 0; j < 40; j++) { + + UnityAssertEqualNumber((UNITY_INT)((' ')), (UNITY_INT)((screen[i][j])), ( + + ((void *)0) + + ), (UNITY_UINT)(33), UNITY_DISPLAY_STYLE_INT); + + } + + } + +} 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..5911aa4 --- /dev/null +++ b/build/test/preprocess/files/test_is_Valid_tile.c @@ -0,0 +1,269 @@ +#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 = 2; + + 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_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)(49), 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)(63), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_valid_tile_left(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = board.width * board.height - 1; + + int direction = 2; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((board.width * board.height - 2)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(77), UNITY_DISPLAY_STYLE_INT); + +} + + + +void test_detect_valid_tile_up(void){ + + + + Minesweeper_Board board = initialize_minesweeper(); + + int tile = board.width * board.height - 1; + + int direction = 3; + + int result; + + + + + + result = is_Valid_tile(&board, tile, direction); + + + + + + UnityAssertEqualNumber((UNITY_INT)((board.width * (board.height - 1) - 1)), (UNITY_INT)((result)), ( + + ((void *)0) + + ), (UNITY_UINT)(91), 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)(105), 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)(119), 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_playerInputMovement.c b/build/test/preprocess/files/test_playerInputMovement.c new file mode 100644 index 0000000..d38ca76 --- /dev/null +++ b/build/test/preprocess/files/test_playerInputMovement.c @@ -0,0 +1,83 @@ +#include "src/main/c/Pong/pong.h" +#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + +typedef struct { + + int x; + + int y; + + int speedX; + + int speedY; + +} Paddle; + + + + + +void setUp(void){ + + + +} + + + +void tearDown(void){ + +} + + + +void test_playerInputMovement(void){ + + + + int paddlePositionY = 10; + + int userInput = -1; + + int expectedY = paddlePositionY - 1; + + + + processPlayerInput(&paddlePositionY, userInput); + + UnityAssertEqualNumber((UNITY_INT)((expectedY)), (UNITY_INT)((paddlePositionY)), ( + + ((void *)0) + + ), (UNITY_UINT)(27), UNITY_DISPLAY_STYLE_INT); + + + + + + userInput = 1; + + expectedY = paddlePositionY + 1; + + + + + + processPlayerInput(&paddlePositionY, userInput); + + UnityAssertEqualNumber((UNITY_INT)((expectedY)), (UNITY_INT)((paddlePositionY)), ( + + ((void *)0) + + ), (UNITY_UINT)(35), UNITY_DISPLAY_STYLE_INT); + + + + + + + +} diff --git a/build/test/preprocess/files/test_pong.c b/build/test/preprocess/files/test_pong.c new file mode 100644 index 0000000..7e1dfbf --- /dev/null +++ b/build/test/preprocess/files/test_pong.c @@ -0,0 +1,51 @@ +#include "src/main/c/Pong/pong.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_input_all_5(void){ + + + + int a = 4, b = 5; + + + + + + resetScore( &a, &b ); + + + + + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((a)), ( + + ((void *)0) + + ), (UNITY_UINT)(21), UNITY_DISPLAY_STYLE_INT); + + UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((b)), ( + + ((void *)0) + + ), (UNITY_UINT)(22), 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..e69de29 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_checkCollision.c b/build/test/preprocess/includes/test_checkCollision.c new file mode 100644 index 0000000..2b3a590 --- /dev/null +++ b/build/test/preprocess/includes/test_checkCollision.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/Pong/pong.h diff --git a/build/test/preprocess/includes/test_checkGameEnd.c b/build/test/preprocess/includes/test_checkGameEnd.c new file mode 100644 index 0000000..2b3a590 --- /dev/null +++ b/build/test/preprocess/includes/test_checkGameEnd.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/Pong/pong.h diff --git a/build/test/preprocess/includes/test_clearScreen.c b/build/test/preprocess/includes/test_clearScreen.c new file mode 100644 index 0000000..2b3a590 --- /dev/null +++ b/build/test/preprocess/includes/test_clearScreen.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/Pong/pong.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_playerInputMovement.c b/build/test/preprocess/includes/test_playerInputMovement.c new file mode 100644 index 0000000..2b3a590 --- /dev/null +++ b/build/test/preprocess/includes/test_playerInputMovement.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/Pong/pong.h diff --git a/build/test/preprocess/includes/test_pong.c b/build/test/preprocess/includes/test_pong.c new file mode 100644 index 0000000..2b3a590 --- /dev/null +++ b/build/test/preprocess/includes/test_pong.c @@ -0,0 +1,3 @@ +--- +- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/main/c/Pong/pong.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..dcd024e --- /dev/null +++ b/build/test/preprocess/includes/test_tictactoe.c @@ -0,0 +1 @@ +--- [] 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..7c25b4d --- /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.001660895999521017 diff --git a/build/test/results/test_checkCollision.pass b/build/test/results/test_checkCollision.pass new file mode 100644 index 0000000..8d6367c --- /dev/null +++ b/build/test/results/test_checkCollision.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Pong + :file: test_checkCollision.c +:successes: +- :test: test_checkCollision + :line: 28 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0022849989982205443 diff --git a/build/test/results/test_checkGameEnd.pass b/build/test/results/test_checkGameEnd.pass new file mode 100644 index 0000000..9faf7ce --- /dev/null +++ b/build/test/results/test_checkGameEnd.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Pong + :file: test_checkGameEnd.c +:successes: +- :test: test_checkGameEnd + :line: 14 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0017912769981194288 diff --git a/build/test/results/test_clearScreen.pass b/build/test/results/test_clearScreen.pass new file mode 100644 index 0000000..6ce9220 --- /dev/null +++ b/build/test/results/test_clearScreen.pass @@ -0,0 +1,19 @@ +--- +:source: + :path: test/Pong + :file: test_clearScreen.c +:successes: +- :test: test_clearScreen + :line: 17 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: +- "\e[H\e[2J\e[3J" +:time: 0.003976027997850906 diff --git a/build/test/results/test_collision.pass b/build/test/results/test_collision.pass new file mode 100644 index 0000000..2fad159 --- /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.0017233269973075949 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..2d4eef4 --- /dev/null +++ b/build/test/results/test_is_Valid_tile.pass @@ -0,0 +1,46 @@ +--- +: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_not_valid_tile_right + :line: 38 + :message: '' + :unity_test_time: 0 +- :test: test_detect_not_valid_tile_down + :line: 52 + :message: '' + :unity_test_time: 0 +- :test: test_detect_valid_tile_left + :line: 66 + :message: '' + :unity_test_time: 0 +- :test: test_detect_valid_tile_up + :line: 80 + :message: '' + :unity_test_time: 0 +- :test: test_detect_valid_tile_right + :line: 94 + :message: '' + :unity_test_time: 0 +- :test: test_detect_valid_tile_down + :line: 108 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 8 + :passed: 8 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0016319420028594323 diff --git a/build/test/results/test_moving_snake.pass b/build/test/results/test_moving_snake.pass new file mode 100644 index 0000000..ca30b84 --- /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.0028836580022471026 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..2294956 --- /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.0025690569964353926 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..9226901 --- /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.002005319998716004 diff --git a/build/test/results/test_playerInputMovement.pass b/build/test/results/test_playerInputMovement.pass new file mode 100644 index 0000000..ba39949 --- /dev/null +++ b/build/test/results/test_playerInputMovement.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Pong + :file: test_playerInputMovement.c +:successes: +- :test: test_playerInputMovement + :line: 20 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0013923250007792376 diff --git a/build/test/results/test_pong.pass b/build/test/results/test_pong.pass new file mode 100644 index 0000000..baea06b --- /dev/null +++ b/build/test/results/test_pong.pass @@ -0,0 +1,18 @@ +--- +:source: + :path: test/Pong + :file: test_pong.c +:successes: +- :test: test_input_all_5 + :line: 13 + :message: '' + :unity_test_time: 0 +:failures: [] +:ignores: [] +:counts: + :total: 1 + :passed: 1 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0018394770013401285 diff --git a/build/test/results/test_template.pass b/build/test/results/test_template.pass index ac2a353..44f5caa 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.001957057000254281 diff --git a/build/test/results/test_tictactoe.pass b/build/test/results/test_tictactoe.pass new file mode 100644 index 0000000..010d758 --- /dev/null +++ b/build/test/results/test_tictactoe.pass @@ -0,0 +1,14 @@ +--- +:source: + :path: test + :file: test_tictactoe.c +:successes: [] +:failures: [] +:ignores: [] +:counts: + :total: 0 + :passed: 0 + :failed: 0 + :ignored: 0 +:stdout: [] +:time: 0.0019282139983261004 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_checkCollision_runner.c b/build/test/runners/test_checkCollision_runner.c new file mode 100644 index 0000000..0bed50f --- /dev/null +++ b/build/test/runners/test_checkCollision_runner.c @@ -0,0 +1,81 @@ +/* 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_checkCollision(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_checkCollision.c"); + run_test(test_checkCollision, "test_checkCollision", 28); + + return UnityEnd(); +} diff --git a/build/test/runners/test_checkGameEnd_runner.c b/build/test/runners/test_checkGameEnd_runner.c new file mode 100644 index 0000000..d83fa82 --- /dev/null +++ b/build/test/runners/test_checkGameEnd_runner.c @@ -0,0 +1,81 @@ +/* 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_checkGameEnd(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_checkGameEnd.c"); + run_test(test_checkGameEnd, "test_checkGameEnd", 14); + + return UnityEnd(); +} diff --git a/build/test/runners/test_clearScreen_runner.c b/build/test/runners/test_clearScreen_runner.c new file mode 100644 index 0000000..9c1799e --- /dev/null +++ b/build/test/runners/test_clearScreen_runner.c @@ -0,0 +1,81 @@ +/* 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_clearScreen(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_clearScreen.c"); + run_test(test_clearScreen, "test_clearScreen", 17); + + 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..25de69d --- /dev/null +++ b/build/test/runners/test_is_Valid_tile_runner.c @@ -0,0 +1,95 @@ +/* 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_not_valid_tile_right(void); +extern void test_detect_not_valid_tile_down(void); +extern void test_detect_valid_tile_left(void); +extern void test_detect_valid_tile_up(void); +extern void test_detect_valid_tile_right(void); +extern void test_detect_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_not_valid_tile_right, "test_detect_not_valid_tile_right", 38); + run_test(test_detect_not_valid_tile_down, "test_detect_not_valid_tile_down", 52); + run_test(test_detect_valid_tile_left, "test_detect_valid_tile_left", 66); + run_test(test_detect_valid_tile_up, "test_detect_valid_tile_up", 80); + run_test(test_detect_valid_tile_right, "test_detect_valid_tile_right", 94); + run_test(test_detect_valid_tile_down, "test_detect_valid_tile_down", 108); + + 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_playerInputMovement_runner.c b/build/test/runners/test_playerInputMovement_runner.c new file mode 100644 index 0000000..6fde093 --- /dev/null +++ b/build/test/runners/test_playerInputMovement_runner.c @@ -0,0 +1,81 @@ +/* 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_playerInputMovement(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_playerInputMovement.c"); + run_test(test_playerInputMovement, "test_playerInputMovement", 20); + + return UnityEnd(); +} diff --git a/build/test/runners/test_pong_runner.c b/build/test/runners/test_pong_runner.c new file mode 100644 index 0000000..93a6451 --- /dev/null +++ b/build/test/runners/test_pong_runner.c @@ -0,0 +1,81 @@ +/* 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_input_all_5(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_pong.c"); + run_test(test_input_all_5, "test_input_all_5", 13); + + 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..161ff95 --- /dev/null +++ b/build/test/runners/test_tictactoe_runner.c @@ -0,0 +1,57 @@ +/* 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); + + +/*=======Mock Management=====*/ +static void CMock_Init(void) +{ + GlobalExpectCount = 0; + GlobalVerifyOrder = 0; + GlobalOrderError = NULL; +} +static void CMock_Verify(void) +{ +} +static void CMock_Destroy(void) +{ +} + +/*=======Setup (stub)=====*/ +void setUp(void) {} + +/*=======Teardown (stub)=====*/ +void tearDown(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(); +} + +/*=======MAIN=====*/ +int main(void) +{ + UnityBegin("test_tictactoe.c"); + + return UnityEnd(); +} diff --git a/src/main/c/Minesweeper/minesweeper_start.c b/src/main/c/Minesweeper/minesweeper_start.c index fae882a..a0f0d58 100644 --- a/src/main/c/Minesweeper/minesweeper_start.c +++ b/src/main/c/Minesweeper/minesweeper_start.c @@ -3,6 +3,7 @@ #include #include #include "minesweeper_start.h" + #pragma region defines #define BLOCK '#' #define FLAG 'x' @@ -13,9 +14,13 @@ #define EASY 7 #define NORMAL 5 #define HARD 3 +#define OFFSET_NUM_CHARS 48 +#define OPEN_TILE 0 +#define FLAG_TILE 1 +#define QUIT_GAME 2 +#define ERROR -1 #pragma endregion - #pragma region Funktion_heads void main_menu_minesweeper(); void game_minesweeper(); @@ -27,6 +32,7 @@ void draw_minesweeper(Minesweeper_Board *board); int open_tile(Minesweeper_Board *board, int tile); int number_of_bombs(Minesweeper_Board *board, int tile); void open_empty_space(Minesweeper_Board *board, int tile, int index); +int is_Valid_tile(Minesweeper_Board *board, int tile, int i); #pragma endregion #pragma region Global @@ -35,7 +41,6 @@ unsigned int height = MIDDLE; int num_bombs = MIDDLE * MIDDLE / NORMAL; #pragma endregion //Global - void minesweeper_start(){ system("clear"); main_menu_minesweeper(); @@ -90,15 +95,23 @@ void game_minesweeper(){ getchar(); if(x < board.width && x > -1 && y < board.height && y > -1){ x = x + y * board.width; - if(t == 0){ + if(t == OPEN_TILE){ int bombs = open_tile(&board, x); - if(bombs == -1){running = false;} - else if(bombs == 0){open_empty_space(&board, x, 0);} - else{board.tiles[x] = bombs + 48;} + if(bombs == ERROR){printf("You Lose!"); getchar(); break;} + else if(bombs == 0){ + open_empty_space(&board, x, 0); + for(int i = 0; i < board.width * board.height; i++){board.marked[i] = ERROR;} + } + else{board.tiles[x] = bombs + OFFSET_NUM_CHARS;} } - if(t == 1){board.tiles[x] = board.tiles[x] == FLAG ? BLOCK : board.tiles[x] == BLOCK ? FLAG : board.tiles[x];} + if(t == FLAG_TILE){board.tiles[x] = board.tiles[x] == FLAG ? BLOCK : board.tiles[x] == BLOCK ? FLAG : board.tiles[x];} } - if (t == 2){break;} + if (t == QUIT_GAME){break;} + + int test = 1; + for (int i = 0; i < board.height * board.width; i++){if(board.tiles[i] == BLOCK){test = 0; break;}} + if(test){printf("You Win!"); getchar(); break;} + } } @@ -119,7 +132,7 @@ void options_minesweeper(){ switch (option){ case 1: - printf("Bitte neu Schwierigkeit eingeben (1 - 3): "); + printf("Bitte neue Schwierigkeit eingeben (1 - 3): "); scanf("%d", &num_bombs); getchar(); num_bombs = num_bombs == 1 ? EASY : num_bombs == 2 ? NORMAL : HARD; @@ -127,7 +140,7 @@ void options_minesweeper(){ break; case 2: num_bombs = num_bombs < width * height / NORMAL ? EASY : num_bombs == width * height / NORMAL ? NORMAL : HARD; - printf("Bitte neu Groesse eingeben (1 - 3): "); + printf("Bitte neue Groesse eingeben (1 - 3): "); scanf("%d", &width); getchar(); width = width == 1 ? SMALL : width == 2 ? MIDDLE : LARGE; @@ -162,10 +175,10 @@ Minesweeper_Board initialize_minesweeper(){ board.tiles = (int*) malloc(width * height * sizeof(int)); for(int i = 0; i < width * height; i++){board.tiles[i] = BLOCK;} board.marked = (int*) malloc(width * height * sizeof(int)); - for(int i = 0; i < width * height; i++){board.marked[i] = 0;} + for(int i = 0; i < width * height; i++){board.marked[i] = ERROR;} board.num_bombs = num_bombs; board.bombs = (int*) malloc(board.num_bombs * sizeof(int)); - for(int i = 0; i < num_bombs; i++){board.bombs[i] = -1;} + for(int i = 0; i < num_bombs; i++){board.bombs[i] = ERROR;} return board; } @@ -189,6 +202,9 @@ bool array_contains_value(int *array, int value, int length){ } void draw_minesweeper(Minesweeper_Board *board){ + int s = 0; + for(int i = 0; i < board->height * board->width; i++){s += board->tiles[i] == FLAG ? 1 : 0;} + printf("Score: %d\n", s); printf(" "); for(int i = 0; i < board->width; i++){printf("%d", i / 10);} printf("\n "); @@ -213,23 +229,15 @@ void draw_minesweeper(Minesweeper_Board *board){ } int open_tile(Minesweeper_Board *board, int tile){ - if(array_contains_value(board->bombs, tile, board->num_bombs)){return -1;} - int num = number_of_bombs(board, tile); - if(1){return num;} + if(array_contains_value(board->bombs, tile, board->num_bombs)){return ERROR;} + return number_of_bombs(board, tile); } int number_of_bombs(Minesweeper_Board *board, int tile){ int sum = 0; for(int i = 0; i < 8; i++){ - int check_tile = tile; - if(i < 3){if(tile % board->width == 0){continue;} - else{check_tile -= 1;}} - if(i > 4){if(tile % board->width + 1 == board->width){continue;} - else{check_tile += 1;}} - if(i % 3 == 0){if(i != 0 && tile / board->width == 0){continue;} - else{check_tile -= board->width;}} - if(i % 3 == 1){if(tile / board->width + 1 == height){continue;} - else{check_tile += board->width;}} + int check_tile = is_Valid_tile(board, tile, i); + if(check_tile == ERROR){continue;} if(array_contains_value(board->bombs, check_tile, board->num_bombs)){sum++;} } return sum; @@ -237,19 +245,28 @@ int number_of_bombs(Minesweeper_Board *board, int tile){ void open_empty_space(Minesweeper_Board *board, int tile, int index){ board->tiles[tile] = EMPTY; - board->marked[index++] = tile; + board->marked[index] = tile; for(int i = 0; i < 8; i++){ - int check_tile = tile; - if(i < 3){if(tile % board->width == 0){continue;} - else{check_tile -= 1;}} - if(i > 4){if(tile % board->width + 1 == board->width){continue;} - else{check_tile += 1;}} - if(i % 3 == 0){if(i != 0 && tile / board->width == 0){continue;} - else{check_tile -= board->width;}} - if(i % 3 == 1){if(tile / board->width + 1 == height){continue;} - else{check_tile += board->width;}} + int check_tile = is_Valid_tile(board, tile, i); + if(check_tile == ERROR){continue;} int sum = open_tile(board, check_tile); - if(sum != 0){board->tiles[check_tile] = sum + 48;} - else if(!array_contains_value(board->marked, check_tile, index)){open_empty_space(board, check_tile, index);} + if(sum != 0){board->tiles[check_tile] = sum + OFFSET_NUM_CHARS;} + else if(!array_contains_value(board->marked, check_tile, board->height * board->width)){open_empty_space(board, check_tile, index + 1);} } +} + +//0 = up-left, 1 = down-left, 2 = mid-left, 3 = up-mid, 4 = down-mid, 5 = mid-right, 6 = up-right, 7 = down-right +int is_Valid_tile(Minesweeper_Board *board, int tile, int direction){ + int check_tile = tile; + + if(direction < 3){if(tile % board->width == 0){return ERROR;} + else{check_tile -= 1;}} + if(direction > 4){if(tile % board->width + 1 == board->width){return ERROR;} + else{check_tile += 1;}} + if(direction % 3 == 0){if(tile / board->width == 0){return ERROR;} + else{check_tile -= board->width;}} + if(direction % 3 == 1){if(tile / board->width + 1 == height){return ERROR;} + else{check_tile += board->width;}} + + return check_tile; } \ No newline at end of file diff --git a/src/main/c/Minesweeper/minesweeper_start.h b/src/main/c/Minesweeper/minesweeper_start.h index c37d731..750003e 100644 --- a/src/main/c/Minesweeper/minesweeper_start.h +++ b/src/main/c/Minesweeper/minesweeper_start.h @@ -1,5 +1,6 @@ #ifndef MINESWEEPER_START_H #define MINESWEEPER_START_H +#include typedef struct Minesweeper_Board{ unsigned int width; @@ -10,11 +11,10 @@ typedef struct Minesweeper_Board{ int *bombs; }Minesweeper_Board; - void minesweeper_start(); Minesweeper_Board initialize_minesweeper(); bool array_contains_value(int *array, int bomb, int length); int number_of_bombs(Minesweeper_Board *board, int tile); - +int is_Valid_tile(Minesweeper_Board *board, int tile, int direction); #endif // MINESWEEPER_START_H \ No newline at end of file diff --git a/src/main/c/Snake/snake_start.c b/src/main/c/Snake/snake_start.c index 26c83c4..ac8690f 100644 --- a/src/main/c/Snake/snake_start.c +++ b/src/main/c/Snake/snake_start.c @@ -5,12 +5,15 @@ #include #include "snake_start.h" #include "get_character.h" + +#pragma region defines #define WIDTH 15 #define HEIGHT 15 #define TURN 0.5 #define START_LENGTH 3 #define START_DIRECTION 1 #define START_TILE 8 * 16 + 8 +#pragma endregion #pragma region Funktion_heads void main_menu_snake(); @@ -77,12 +80,13 @@ void game_snake(){ while (running){ system("clear"); draw_snake(&snake, fruit); - if(check_if_dead(&snake)){break;} + if(check_if_dead(&snake)){printf("You Lose!"); getchar(); break;} t = clock() - t; get_next_move(TIME_TURN - (double)t / CLOCKS_PER_SEC, &snake, &running); t = clock(); move_snake(&snake); if(part_of_snake(&snake, fruit) == 0){fruit = eating_fruit(&snake);} + if(snake.length == WIDTH * HEIGHT){printf("You Win!"); running = false; getchar();} } } @@ -150,7 +154,13 @@ void draw_snake(Snake *snake, unsigned char fruit){ printf("|"); for(int j = 1; j <= WIDTH; j++){ int index = part_of_snake(snake, i * 16 + j); - if(index == 0){printf("0");} + if(index == 0){ + switch(snake->direction){ + case -16: printf("A");break; + case -1: printf("<");break; + case 1: printf(">");break; + case 16: printf("V");break; + default: break;}} else if(index > 0){printf("O");} else if(i * 16 + j == fruit){printf("X");} else{printf(" ");} @@ -175,14 +185,10 @@ int part_of_snake(Snake *snake, unsigned char tile){ bool check_if_dead(Snake *snake){ //Self - if(part_of_snake(snake, snake->segments[0]) > 0){ - return true; - } + if(part_of_snake(snake, snake->segments[0])){return true;} //Wall - if(snake->segments[0] % 16 == 0 || (snake->segments[0] / 16) % 16 == 0){ - return true; - } + if(snake->segments[0] % 16 == 0 || (snake->segments[0] / 16) % 16 == 0){return true;} return false; } diff --git a/test/Minesweeper/test_is_Valid_tile.c b/test/Minesweeper/test_is_Valid_tile.c new file mode 100644 index 0000000..13e8980 --- /dev/null +++ b/test/Minesweeper/test_is_Valid_tile.c @@ -0,0 +1,122 @@ +#ifdef TEST +#include "unity.h" +#include "../../src/main/c/Minesweeper/minesweeper_start.h" + + +void setUp(void){} +void tearDown(void){} + + +void test_detect_not_valid_tile_left(void){ + /* arrange */ + Minesweeper_Board board = initialize_minesweeper(); + int tile = 0; + int direction = 2; + 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_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_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 +} + +void test_detect_valid_tile_left(void){ + /* arrange */ + Minesweeper_Board board = initialize_minesweeper(); + int tile = board.width * board.height - 1; + int direction = 2; + int result; + + /* act */ + result = is_Valid_tile(&board, tile, direction); + + /* assert */ + TEST_ASSERT_EQUAL_INT(board.width * board.height - 2, result);//not valid tile +} + +void test_detect_valid_tile_up(void){ + /* arrange */ + Minesweeper_Board board = initialize_minesweeper(); + int tile = board.width * board.height - 1; + int direction = 3; + int result; + + /* act */ + result = is_Valid_tile(&board, tile, direction); + + /* assert */ + TEST_ASSERT_EQUAL_INT(board.width * (board.height - 1) - 1, result);//not valid tile +} + +void test_detect_valid_tile_right(void){ + /* arrange */ + Minesweeper_Board board = initialize_minesweeper(); + int tile = 0; + 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_valid_tile_down(void){ + /* arrange */ + Minesweeper_Board board = initialize_minesweeper(); + int tile = 0; + int direction = 4; + int result; + + /* act */ + result = is_Valid_tile(&board, tile, direction); + + /* assert */ + TEST_ASSERT_EQUAL_INT(0 + board.width, result);//not valid tile +} + +#endif // TEST \ No newline at end of file