trackler 2.2.1.111 → 2.2.1.113

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/README.md +6 -2
  4. data/problem-specifications/exercises/go-counting/canonical-data.json +200 -0
  5. data/problem-specifications/exercises/go-counting/description.md +2 -0
  6. data/tracks/c/config.json +24 -0
  7. data/tracks/c/exercises/minesweeper/README.md +26 -0
  8. data/tracks/c/exercises/minesweeper/makefile +25 -0
  9. data/tracks/c/exercises/minesweeper/src/example.c +64 -0
  10. data/tracks/c/exercises/minesweeper/src/example.h +7 -0
  11. data/tracks/c/exercises/minesweeper/test/test_minesweeper.c +261 -0
  12. data/tracks/c/exercises/minesweeper/test/vendor/unity.c +1300 -0
  13. data/tracks/c/exercises/minesweeper/test/vendor/unity.h +274 -0
  14. data/tracks/c/exercises/minesweeper/test/vendor/unity_internals.h +701 -0
  15. data/tracks/c/exercises/run-length-encoding/README.md +23 -0
  16. data/tracks/c/exercises/run-length-encoding/makefile +27 -0
  17. data/tracks/c/exercises/run-length-encoding/src/example.c +126 -0
  18. data/tracks/c/exercises/run-length-encoding/src/example.h +7 -0
  19. data/tracks/c/exercises/run-length-encoding/test/test_run_length_encoding.c +139 -0
  20. data/tracks/c/exercises/run-length-encoding/test/vendor/unity.c +1300 -0
  21. data/tracks/c/exercises/run-length-encoding/test/vendor/unity.h +274 -0
  22. data/tracks/c/exercises/run-length-encoding/test/vendor/unity_internals.h +701 -0
  23. data/tracks/delphi/exercises/clock/uClockTest.pas +6 -6
  24. data/tracks/ecmascript/config.json +11 -0
  25. data/tracks/ecmascript/exercises/armstrong-numbers/README.md +48 -0
  26. data/tracks/ecmascript/exercises/armstrong-numbers/armstrong-numbers.spec.js +43 -0
  27. data/tracks/ecmascript/exercises/armstrong-numbers/example.js +11 -0
  28. data/tracks/ecmascript/exercises/armstrong-numbers/package.json +70 -0
  29. data/tracks/javascript/config.json +11 -0
  30. data/tracks/javascript/exercises/armstrong-numbers/README.md +46 -0
  31. data/tracks/javascript/exercises/armstrong-numbers/armstrong-numbers.spec.js +43 -0
  32. data/tracks/javascript/exercises/armstrong-numbers/example.js +11 -0
  33. data/tracks/objective-c/config.json +12 -0
  34. data/tracks/objective-c/exercises/series/README.md +50 -0
  35. data/tracks/objective-c/exercises/series/SeriesExample.h +12 -0
  36. data/tracks/objective-c/exercises/series/SeriesExample.m +50 -0
  37. data/tracks/objective-c/exercises/series/SeriesTest.m +97 -0
  38. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  39. data/tracks/rust/exercises/gigasecond/.meta/hints.md +1 -0
  40. data/tracks/rust/exercises/gigasecond/README.md +3 -0
  41. data/tracks/rust/exercises/gigasecond/example.rs +1 -1
  42. data/tracks/rust/exercises/gigasecond/src/lib.rs +7 -7
  43. data/tracks/rust/exercises/gigasecond/tests/gigasecond.rs +1 -1
  44. data/tracks/rust/exercises/prime-factors/src/lib.rs +3 -0
  45. data/tracks/scala/exercises/saddle-points/src/test/scala/SaddlePointsTest.scala +1 -1
  46. data/tracks/scala/exercises/say/src/test/scala/SayTest.scala +18 -19
  47. data/tracks/scala/exercises/scrabble-score/src/test/scala/ScrabbleScoreTest.scala +13 -13
  48. data/tracks/scala/testgen/src/main/scala/SaddlePointsTestGenerator.scala +3 -3
  49. data/tracks/scala/testgen/src/main/scala/SayTestGenerator.scala +6 -6
  50. data/tracks/scala/testgen/src/main/scala/ScrabbleScoreTestGenerator.scala +2 -2
  51. data/tracks/typescript/config.json +16 -0
  52. data/tracks/typescript/exercises/simple-cipher/README.md +114 -0
  53. data/tracks/typescript/exercises/simple-cipher/package.json +36 -0
  54. data/tracks/typescript/exercises/simple-cipher/simple-cipher.example.ts +42 -0
  55. data/tracks/typescript/exercises/simple-cipher/simple-cipher.test.ts +84 -0
  56. data/tracks/typescript/exercises/simple-cipher/simple-cipher.ts +11 -0
  57. data/tracks/typescript/exercises/simple-cipher/tsconfig.json +22 -0
  58. data/tracks/typescript/exercises/simple-cipher/tslint.json +127 -0
  59. data/tracks/typescript/exercises/simple-cipher/yarn.lock +2624 -0
  60. metadata +39 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01d8bfdb5552025a07daa9c37f86e06af88cbf3e
4
- data.tar.gz: 9ba7233e30a1774861a44b0da783675cd792cea8
3
+ metadata.gz: 0e4e17fbfd6725286f53a29a3080230bef5b3dcd
4
+ data.tar.gz: 699cefe1dddc600e28ca10c11b903b6914fc94a1
5
5
  SHA512:
6
- metadata.gz: d713b6f1d0df102bebd1a8f3eb9a5467464527d54a758fd3fa662ab4f8ddeb1b4fa218556c57e44a19aa45ef7dff10da8fe3069b90ede3b7660bffa9831f6422
7
- data.tar.gz: bd11a04b89ff78e87f44015621ddc02abd8ed7409f0263983c59a0860e9d3da5041492617655a4055c2639af23824b5e2595ab1bfce3d34db740a66b9ec31666
6
+ metadata.gz: 9d8bd5fa9fa3ecd2797859ee707f79f03fe034d500cdea054b2d260c89dc75394f0a597ee98376e190a6a43b82138ebefefad9e3beeb5cddf582ef6bb374a480
7
+ data.tar.gz: 9c1ef17519b4a583c0db16c842619f7f33fae053dd845f09cdab449547b0d33c53a61b31adeea1c657e4d6c468c6341175a5f3a11100704f32d6cf4fb2621b3b
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.2.1.111"
2
+ VERSION = "2.2.1.113"
3
3
  end
@@ -66,7 +66,9 @@ is easier to understand with an example:
66
66
  ]
67
67
  , "description": "Foo'ing a word returns it reversed"
68
68
  , "property" : "foo"
69
- , "input" : "lion"
69
+ , "input" : {
70
+ "word" : "lion"
71
+ }
70
72
  , "expected" : "noil"
71
73
  }
72
74
  , { "description": "Bar'ing a name returns its parts combined"
@@ -85,7 +87,9 @@ is easier to understand with an example:
85
87
  , "cases":
86
88
  [ { "description": "Foo'ing a number returns nothing"
87
89
  , "property" : "foo"
88
- , "input" : "42"
90
+ , "input" : {
91
+ "word" : "42"
92
+ }
89
93
  , "expected" : null
90
94
  }
91
95
  , { "description": "Bar'ing a name with numbers gives an error"
@@ -0,0 +1,200 @@
1
+ {
2
+ "exercise": "go-counting",
3
+ "version": "1.0.0",
4
+ "comments": [
5
+ "Territory consists of [x, y] coordinate pairs."
6
+ ],
7
+ "cases": [
8
+ {
9
+ "description": "Black corner territory on 5x5 board",
10
+ "property": "territory",
11
+ "input": {
12
+ "board": [
13
+ " B ",
14
+ " B B ",
15
+ "B W B",
16
+ " W W ",
17
+ " W "
18
+ ],
19
+ "x": 0,
20
+ "y": 1
21
+ },
22
+ "expected": {
23
+ "owner": "BLACK",
24
+ "territory": [[0, 0], [0, 1], [1, 0]]
25
+ }
26
+ },
27
+ {
28
+ "description": "White center territory on 5x5 board",
29
+ "property": "territory",
30
+ "input": {
31
+ "board": [
32
+ " B ",
33
+ " B B ",
34
+ "B W B",
35
+ " W W ",
36
+ " W "
37
+ ],
38
+ "x": 2,
39
+ "y": 3
40
+ },
41
+ "expected": {
42
+ "owner": "WHITE",
43
+ "territory": [[2, 3]]
44
+ }
45
+ },
46
+ {
47
+ "description": "Open corner territory on 5x5 board",
48
+ "property": "territory",
49
+ "input": {
50
+ "board": [
51
+ " B ",
52
+ " B B ",
53
+ "B W B",
54
+ " W W ",
55
+ " W "
56
+ ],
57
+ "x": 1,
58
+ "y": 4
59
+ },
60
+ "expected": {
61
+ "owner": "NONE",
62
+ "territory": [[0, 3], [0, 4], [1, 4]]
63
+ }
64
+ },
65
+ {
66
+ "description": "A stone and not a territory on 5x5 board",
67
+ "property": "territory",
68
+ "input": {
69
+ "board": [
70
+ " B ",
71
+ " B B ",
72
+ "B W B",
73
+ " W W ",
74
+ " W "
75
+ ],
76
+ "x": 1,
77
+ "y": 1
78
+ },
79
+ "expected": {
80
+ "owner": "NONE",
81
+ "territory": []
82
+ }
83
+ },
84
+ {
85
+ "description": "Invalid because X is too low for 5x5 board",
86
+ "property": "territory",
87
+ "input": {
88
+ "board": [
89
+ " B ",
90
+ " B B ",
91
+ "B W B",
92
+ " W W ",
93
+ " W "
94
+ ],
95
+ "x": -1,
96
+ "y": 1
97
+ },
98
+ "expected": {
99
+ "error": "Invalid coordinate"
100
+ }
101
+ },
102
+ {
103
+ "description": "Invalid because X is too high for 5x5 board",
104
+ "property": "territory",
105
+ "input": {
106
+ "board": [
107
+ " B ",
108
+ " B B ",
109
+ "B W B",
110
+ " W W ",
111
+ " W "
112
+ ],
113
+ "x": 5,
114
+ "y": 1
115
+ },
116
+ "expected": {
117
+ "error": "Invalid coordinate"
118
+ }
119
+ },
120
+ {
121
+ "description": "Invalid because Y is too low for 5x5 board",
122
+ "property": "territory",
123
+ "input": {
124
+ "board": [
125
+ " B ",
126
+ " B B ",
127
+ "B W B",
128
+ " W W ",
129
+ " W "
130
+ ],
131
+ "x": 1,
132
+ "y": -1
133
+ },
134
+ "expected": {
135
+ "error": "Invalid coordinate"
136
+ }
137
+ },
138
+ {
139
+ "description": "Invalid because Y is too high for 5x5 board",
140
+ "property": "territory",
141
+ "input": {
142
+ "board": [
143
+ " B ",
144
+ " B B ",
145
+ "B W B",
146
+ " W W ",
147
+ " W "
148
+ ],
149
+ "x": 1,
150
+ "y": 5
151
+ },
152
+ "expected": {
153
+ "error": "Invalid coordinate"
154
+ }
155
+ },
156
+ {
157
+ "description": "One territory is the whole board",
158
+ "property": "territories",
159
+ "input": {
160
+ "board": [
161
+ " "
162
+ ]
163
+ },
164
+ "expected": {
165
+ "territoryBlack": [],
166
+ "territoryWhite": [],
167
+ "territoryNone": [[0, 0]]
168
+ }
169
+ },
170
+ {
171
+ "description": "Two territory rectangular board",
172
+ "property": "territories",
173
+ "input": {
174
+ "board": [
175
+ " BW ",
176
+ " BW "
177
+ ]
178
+ },
179
+ "expected": {
180
+ "territoryBlack": [[0, 0], [0, 1]],
181
+ "territoryWhite": [[3, 0], [3, 1]],
182
+ "territoryNone": []
183
+ }
184
+ },
185
+ {
186
+ "description": "Two region rectangular board",
187
+ "property": "territories",
188
+ "input": {
189
+ "board": [
190
+ " B "
191
+ ]
192
+ },
193
+ "expected": {
194
+ "territoryBlack": [[0, 0], [2, 0]],
195
+ "territoryWhite": [],
196
+ "territoryNone": []
197
+ }
198
+ }
199
+ ]
200
+ }
@@ -9,6 +9,8 @@ Write a function that determines the territory of each player. You may
9
9
  assume that any stones that have been stranded in enemy territory have
10
10
  already been taken off the board.
11
11
 
12
+ Write a function that determines the territory which includes a specified coordinate.
13
+
12
14
  Multiple empty intersections may be encircled at once and for encircling
13
15
  only horizontal and vertical neighbours count. In the following diagram
14
16
  the stones which matter are marked "O" and the stones that don't are
data/tracks/c/config.json CHANGED
@@ -581,6 +581,30 @@
581
581
  ],
582
582
  "unlocked_by": "hamming",
583
583
  "uuid": "62f539e7-f682-412d-bf86-38503e7cebca"
584
+ },
585
+ {
586
+ "core": false,
587
+ "difficulty": 3,
588
+ "slug": "minesweeper",
589
+ "topics": [
590
+ "strings",
591
+ "arrays",
592
+ "control_flow_if_statements"
593
+ ],
594
+ "unlocked_by": "scrabble-score",
595
+ "uuid": "2e97072f-9e77-4ddd-9d75-6162a927bab1"
596
+ },
597
+ {
598
+ "core": false,
599
+ "difficulty": 4,
600
+ "slug": "run-length-encoding",
601
+ "topics": [
602
+ "algorithms",
603
+ "strings",
604
+ "control_flow_if_statements"
605
+ ],
606
+ "unlocked_by": "atbash-cipher",
607
+ "uuid": "b22152b9-99d1-411c-8cf2-f89e8f5f8141"
584
608
  }
585
609
  ],
586
610
  "foregone": [],
@@ -0,0 +1,26 @@
1
+ Add the numbers to a minesweeper board.
2
+
3
+ Minesweeper is a popular game where the user has to find the mines using
4
+ numeric hints that indicate how many mines are directly adjacent
5
+ (horizontally, vertically, diagonally) to a square.
6
+
7
+ In this exercise you have to create some code that counts the number of
8
+ mines adjacent to a square and transforms boards like this (where `*`
9
+ indicates a mine):
10
+
11
+ +-----+
12
+ | * * |
13
+ | * |
14
+ | * |
15
+ | |
16
+ +-----+
17
+
18
+ into this:
19
+
20
+ +-----+
21
+ |1*3*1|
22
+ |13*31|
23
+ | 2*2 |
24
+ | 111 |
25
+ +-----+
26
+
@@ -0,0 +1,25 @@
1
+ CFLAGS = -std=c99
2
+ CFLAGS += -g
3
+ CFLAGS += -Wall
4
+ CFLAGS += -Wextra
5
+ CFLAGS += -pedantic
6
+ CFLAGS += -Werror
7
+
8
+ VFLAGS = --quiet
9
+ VFLAGS += --tool=memcheck
10
+ VFLAGS += --leak-check=full
11
+ VFLAGS += --error-exitcode=1
12
+
13
+ test: tests.out
14
+ @./tests.out
15
+
16
+ memcheck: tests.out
17
+ @valgrind $(VFLAGS) ./tests.out
18
+ @echo "Memory check passed"
19
+
20
+ clean:
21
+ rm -rf *.o *.out *.out.dSYM
22
+
23
+ tests.out: test/test_minesweeper.c src/minesweeper.c src/minesweeper.h
24
+ @echo Compiling $@
25
+ @cc $(CFLAGS) src/minesweeper.c test/vendor/unity.c test/test_minesweeper.c -o tests.out
@@ -0,0 +1,64 @@
1
+ #include "minesweeper.h"
2
+ #include <stdlib.h>
3
+ #include <stdio.h>
4
+ #include <string.h>
5
+
6
+ static void set_single_field(char **minefield, const size_t row,
7
+ const size_t col)
8
+ {
9
+ if (minefield[row][col] == '*')
10
+ return;
11
+
12
+ const char c = minefield[row][col];
13
+ minefield[row][col] = (c == ' ') ? '1' : c + 1;
14
+ }
15
+
16
+ static void increment_neighbors(char **minefield, const size_t row_count,
17
+ const size_t col_count, const size_t row,
18
+ const size_t col)
19
+ {
20
+ const size_t from_row = row ? row - 1 : row;
21
+ const size_t to_row = (row + 1 < row_count) ? row + 1 : row;
22
+ const size_t from_col = col ? col - 1 : col;
23
+ const size_t to_col = (col + 1 < col_count) ? col + 1 : col;
24
+
25
+ for (size_t i = from_row; i <= to_row; i++) {
26
+ for (size_t k = from_col; k <= to_col; k++)
27
+ set_single_field(minefield, i, k);
28
+ }
29
+ }
30
+
31
+ char **annotate(const char **minefield, const size_t rows)
32
+ {
33
+ if (minefield == NULL || *minefield == NULL || rows == 0)
34
+ return NULL;
35
+
36
+ const size_t cols = strlen(minefield[0]);
37
+
38
+ char **annotated = malloc(sizeof(char *) * rows);
39
+ if (annotated == NULL) {
40
+ fprintf(stderr, "Memory error!\n");
41
+ return NULL;
42
+ }
43
+
44
+ char *all_rows = malloc(rows * (cols + 1));
45
+ if (all_rows == NULL) {
46
+ fprintf(stderr, "Memory error!\n");
47
+ free(annotated);
48
+ return NULL;
49
+ }
50
+
51
+ for (size_t i = 0; i < rows; i++) {
52
+ annotated[i] = &all_rows[i * (cols + 1)];
53
+ strcpy(annotated[i], minefield[i]);
54
+ }
55
+
56
+ for (size_t i = 0; i < rows; i++) {
57
+ for (size_t k = 0; k < cols; k++) {
58
+ if (minefield[i][k] == '*')
59
+ increment_neighbors(annotated, rows, cols, i, k);
60
+ }
61
+ }
62
+
63
+ return annotated;
64
+ }
@@ -0,0 +1,7 @@
1
+ #ifndef MINESWEEPER_H
2
+ #define MINESWEEPER_H
3
+ #include <stddef.h>
4
+
5
+ char **annotate(const char **minefield, const size_t rows);
6
+
7
+ #endif
@@ -0,0 +1,261 @@
1
+ #include "vendor/unity.h"
2
+ #include "../src/minesweeper.h"
3
+ #include <stdlib.h>
4
+
5
+ #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
6
+
7
+ void setUp(void)
8
+ {
9
+ }
10
+
11
+ void tearDown(void)
12
+ {
13
+ }
14
+
15
+ static void free_all(char **field)
16
+ {
17
+ free(field[0]);
18
+ free(field);
19
+ }
20
+
21
+ void test_annotate_no_rows(void)
22
+ {
23
+ const char **minefield = NULL;
24
+ const size_t rows = 0;
25
+ char **actual = annotate(minefield, rows);
26
+ TEST_ASSERT_NULL(actual);
27
+ }
28
+
29
+ void test_annotate_no_columns(void)
30
+ {
31
+ TEST_IGNORE(); // delete this line to run test
32
+ const char *minefield[] = {
33
+ ""
34
+ };
35
+ const char *expected[] = { "" };
36
+ const size_t rows = ARRAY_SIZE(expected);
37
+ char **actual = annotate(minefield, rows);
38
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
39
+ free_all(actual);
40
+ }
41
+
42
+ void test_annotate_no_mines(void)
43
+ {
44
+ TEST_IGNORE();
45
+ const char *minefield[] = {
46
+ " ",
47
+ " ",
48
+ " "
49
+ };
50
+ const char *expected[] = {
51
+ " ",
52
+ " ",
53
+ " "
54
+ };
55
+ const size_t rows = ARRAY_SIZE(expected);
56
+ char **actual = annotate(minefield, rows);
57
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
58
+ free_all(actual);
59
+ }
60
+
61
+ void test_annotate_minefield_with_only_mines(void)
62
+ {
63
+ TEST_IGNORE();
64
+ const char *minefield[] = {
65
+ "***",
66
+ "***",
67
+ "***"
68
+ };
69
+ const char *expected[] = {
70
+ "***",
71
+ "***",
72
+ "***"
73
+ };
74
+ const size_t rows = ARRAY_SIZE(expected);
75
+ char **actual = annotate(minefield, rows);
76
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
77
+ free_all(actual);
78
+ }
79
+
80
+ void test_annotate_mine_surrounded_by_spaces(void)
81
+ {
82
+ TEST_IGNORE();
83
+ const char *minefield[] = {
84
+ " ",
85
+ " * ",
86
+ " "
87
+ };
88
+ const char *expected[] = {
89
+ "111",
90
+ "1*1",
91
+ "111"
92
+ };
93
+ const size_t rows = ARRAY_SIZE(expected);
94
+ char **actual = annotate(minefield, rows);
95
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
96
+ free_all(actual);
97
+ }
98
+
99
+ void test_annotate_space_surrounded_by_mines(void)
100
+ {
101
+ TEST_IGNORE();
102
+ const char *minefield[] = {
103
+ "***",
104
+ "* *",
105
+ "***"
106
+ };
107
+ const char *expected[] = {
108
+ "***",
109
+ "*8*",
110
+ "***"
111
+ };
112
+ const size_t rows = ARRAY_SIZE(expected);
113
+ char **actual = annotate(minefield, rows);
114
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
115
+ free_all(actual);
116
+ }
117
+
118
+ void test_annotate_horizontal_line(void)
119
+ {
120
+ TEST_IGNORE();
121
+ const char *minefield[] = {
122
+ " * * "
123
+ };
124
+ const char *expected[] = {
125
+ "1*2*1"
126
+ };
127
+ const size_t rows = ARRAY_SIZE(expected);
128
+ char **actual = annotate(minefield, rows);
129
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
130
+ free_all(actual);
131
+ }
132
+
133
+ void test_annotate_horizontal_line_mines_at_edges(void)
134
+ {
135
+ TEST_IGNORE();
136
+ const char *minefield[] = {
137
+ "* *"
138
+ };
139
+ const char *expected[] = {
140
+ "*1 1*"
141
+ };
142
+ const size_t rows = ARRAY_SIZE(expected);
143
+ char **actual = annotate(minefield, rows);
144
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
145
+ free_all(actual);
146
+ }
147
+
148
+ void test_annotate_vertical_line(void)
149
+ {
150
+ TEST_IGNORE();
151
+ const char *minefield[] = {
152
+ " ",
153
+ "*",
154
+ " ",
155
+ "*",
156
+ " "
157
+ };
158
+ const char *expected[] = {
159
+ "1",
160
+ "*",
161
+ "2",
162
+ "*",
163
+ "1"
164
+ };
165
+ const size_t rows = ARRAY_SIZE(expected);
166
+ char **actual = annotate(minefield, rows);
167
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
168
+ free_all(actual);
169
+ }
170
+
171
+ void test_annotate_vertical_line_mines_at_edges(void)
172
+ {
173
+ TEST_IGNORE();
174
+ const char *minefield[] = {
175
+ "*",
176
+ " ",
177
+ " ",
178
+ " ",
179
+ "*"
180
+ };
181
+ const char *expected[] = {
182
+ "*",
183
+ "1",
184
+ " ",
185
+ "1",
186
+ "*"
187
+ };
188
+ const size_t rows = ARRAY_SIZE(expected);
189
+ char **actual = annotate(minefield, rows);
190
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
191
+ free_all(actual);
192
+ }
193
+
194
+ void test_annotate_cross(void)
195
+ {
196
+ TEST_IGNORE();
197
+ const char *minefield[] = {
198
+ " * ",
199
+ " * ",
200
+ "*****",
201
+ " * ",
202
+ " * "
203
+ };
204
+ const char *expected[] = {
205
+ " 2*2 ",
206
+ "25*52",
207
+ "*****",
208
+ "25*52",
209
+ " 2*2 "
210
+ };
211
+ const size_t rows = ARRAY_SIZE(expected);
212
+ char **actual = annotate(minefield, rows);
213
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
214
+ free_all(actual);
215
+ }
216
+
217
+ void test_annotate_large_minefield(void)
218
+ {
219
+ TEST_IGNORE();
220
+ const char *minefield[] = {
221
+ " * * ",
222
+ " * ",
223
+ " * ",
224
+ " * *",
225
+ " * * ",
226
+ " "
227
+ };
228
+ const char *expected[] = {
229
+ "1*22*1",
230
+ "12*322",
231
+ " 123*2",
232
+ "112*4*",
233
+ "1*22*2",
234
+ "111111"
235
+ };
236
+ const size_t rows = ARRAY_SIZE(expected);
237
+ char **actual = annotate(minefield, rows);
238
+ TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, rows);
239
+ free_all(actual);
240
+ }
241
+
242
+ int main(void)
243
+ {
244
+ UnityBegin("test/test_minesweeper.c");
245
+
246
+ RUN_TEST(test_annotate_no_rows);
247
+ RUN_TEST(test_annotate_no_columns);
248
+ RUN_TEST(test_annotate_no_mines);
249
+ RUN_TEST(test_annotate_minefield_with_only_mines);
250
+ RUN_TEST(test_annotate_mine_surrounded_by_spaces);
251
+ RUN_TEST(test_annotate_space_surrounded_by_mines);
252
+ RUN_TEST(test_annotate_horizontal_line);
253
+ RUN_TEST(test_annotate_horizontal_line_mines_at_edges);
254
+ RUN_TEST(test_annotate_vertical_line);
255
+ RUN_TEST(test_annotate_vertical_line_mines_at_edges);
256
+ RUN_TEST(test_annotate_cross);
257
+ RUN_TEST(test_annotate_large_minefield);
258
+
259
+ UnityEnd();
260
+ return 0;
261
+ }