trackler 2.0.0.5 → 2.0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/bash/docs/TESTS.md +1 -1
  4. data/tracks/bash/exercises/bob/bob_test.sh +2 -0
  5. data/tracks/bash/exercises/gigasecond/gigasecond_test.sh +2 -0
  6. data/tracks/bash/exercises/hamming/hamming_test.sh +2 -0
  7. data/tracks/bash/exercises/hello-world/hello_world_test.sh +2 -0
  8. data/tracks/bash/exercises/leap/leap_test.sh +2 -0
  9. data/tracks/bash/exercises/raindrops/raindrops_test.sh +2 -0
  10. data/tracks/bash/exercises/rna-transcription/rna_transcription_test.sh +2 -0
  11. data/tracks/c/bin/verify-indent +5 -1
  12. data/tracks/c/config.json +10 -1
  13. data/tracks/c/exercises/clock/src/clock.h +1 -1
  14. data/tracks/c/exercises/largest-series-product/test/test_largest_series_product.c +1 -1
  15. data/tracks/c/exercises/phone-number/src/example.c +4 -2
  16. data/tracks/c/exercises/roman-numerals/src/example.c +20 -21
  17. data/tracks/c/exercises/roman-numerals/src/example.h +1 -1
  18. data/tracks/c/exercises/roman-numerals/test/test_roman_numerals.c +1 -0
  19. data/tracks/c/exercises/sum-of-multiples/src/example.c +3 -1
  20. data/tracks/c/exercises/sum-of-multiples/src/example.h +3 -1
  21. data/tracks/c/exercises/sum-of-multiples/test/test_sum_of_multiples.c +44 -22
  22. data/tracks/c/exercises/word-count/makefile +16 -0
  23. data/tracks/c/exercises/word-count/src/example.c +65 -0
  24. data/tracks/c/exercises/word-count/src/word_count.h +22 -0
  25. data/tracks/c/exercises/word-count/test/test_word_count.c +372 -0
  26. data/tracks/c/exercises/word-count/test/vendor/unity.c +1300 -0
  27. data/tracks/c/exercises/word-count/test/vendor/unity.h +274 -0
  28. data/tracks/c/exercises/word-count/test/vendor/unity_internals.h +701 -0
  29. data/tracks/crystal/.gitignore +1 -0
  30. data/tracks/crystal/Makefile +6 -0
  31. data/tracks/crystal/README.md +25 -0
  32. data/tracks/crystal/config.json +10 -2
  33. data/tracks/crystal/exercises/acronym/spec/acronym_spec.cr +32 -0
  34. data/tracks/crystal/exercises/acronym/src/example.cr +7 -0
  35. data/tracks/crystal/exercises/hello-world/spec/hello_world_spec.cr +8 -10
  36. data/tracks/crystal/exercises/hello-world/src/example.cr +1 -1
  37. data/tracks/crystal/src/generator/exercises/acronym.cr +34 -0
  38. data/tracks/crystal/src/generator/exercises/exercise_generator.cr +39 -0
  39. data/tracks/crystal/src/generator/exercises/exercise_test_case.cr +8 -0
  40. data/tracks/crystal/src/generator/exercises/hello_world.cr +38 -0
  41. data/tracks/crystal/src/generator/exercises/templates/example.tt +10 -0
  42. data/tracks/crystal/src/generator/generate.cr +15 -0
  43. data/tracks/crystal/src/generator/spec/exercise_generator_spec.cr +27 -0
  44. data/tracks/crystal/src/generator/spec/exercise_test_case_spec.cr +23 -0
  45. data/tracks/elixir/exercises/space-age/space_age.exs +1 -1
  46. data/tracks/elm/config.json +5 -31
  47. data/tracks/elm/elm-package.json +1 -0
  48. data/tracks/elm/exercises/bob/BobTests.elm +1 -1
  49. data/tracks/elm/exercises/run-length-encoding/RunLengthEncoding.elm +5 -0
  50. data/tracks/elm/exercises/scrabble-score/ScrabbleScore.elm +1 -0
  51. data/tracks/elm/exercises/scrabble-score/ScrabbleScore.example +32 -0
  52. data/tracks/elm/exercises/scrabble-score/ScrabbleScoreTests.elm +43 -0
  53. data/tracks/elm/exercises/scrabble-score/elm-package.json +16 -0
  54. data/tracks/elm/exercises/scrabble-score/runtests.bat +1 -0
  55. data/tracks/elm/exercises/scrabble-score/runtests.sh +2 -0
  56. data/tracks/elm/exercises/sublist/Sublist.elm +5 -0
  57. data/tracks/fsharp/exercises/sum-of-multiples/SumOfMultiplesTest.fs +6 -1
  58. data/tracks/haskell/docs/LEARNING.md +11 -2
  59. data/tracks/haskell/exercises/list-ops/test/Tests.hs +2 -0
  60. data/tracks/java/config.json +13 -1
  61. data/tracks/java/exercises/etl/src/test/java/EtlTest.java +101 -55
  62. data/tracks/java/exercises/hello-world/TUTORIAL.md +1 -1
  63. data/tracks/java/exercises/largest-series-product/build.gradle +17 -0
  64. data/tracks/java/exercises/largest-series-product/src/example/java/LargestSeriesProductCalculator.java +56 -0
  65. data/tracks/java/exercises/largest-series-product/src/main/java/LargestSeriesProductCalculator.java +5 -0
  66. data/tracks/java/exercises/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java +218 -0
  67. data/tracks/java/exercises/queen-attack/build.gradle +17 -0
  68. data/tracks/java/exercises/queen-attack/src/example/java/BoardCoordinate.java +39 -0
  69. data/tracks/java/exercises/queen-attack/src/example/java/QueenAttackCalculator.java +54 -0
  70. data/tracks/java/exercises/queen-attack/src/main/java/BoardCoordinate.java +5 -0
  71. data/tracks/java/exercises/queen-attack/src/main/java/QueenAttackCalculator.java +5 -0
  72. data/tracks/java/exercises/queen-attack/src/test/java/QueenAttackCalculatorTest.java +135 -0
  73. data/tracks/java/exercises/settings.gradle +2 -0
  74. data/tracks/ocaml/exercises/leap/test.ml +17 -6
  75. data/tracks/rust/_test/check-exercises.sh +5 -0
  76. data/tracks/swift/docs/TESTS.md +23 -3
  77. metadata +35 -2
@@ -0,0 +1,372 @@
1
+ #include <stddef.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+ #include "vendor/unity.h"
5
+ #include "../src/word_count.h"
6
+
7
+ WordCount_Word_t ActualSolution[MAX_WORDS];
8
+
9
+ static void test_solution(WordCount_Word_t * expected_solution,
10
+ int expected_word_count,
11
+ WordCount_Word_t * actual_solution,
12
+ int actual_word_count)
13
+ {
14
+ // All words counted?
15
+ TEST_ASSERT_EQUAL(expected_word_count, actual_word_count);
16
+
17
+ // now test the word count for the words...
18
+ for (int index = 0; index < actual_word_count; index++) {
19
+ TEST_ASSERT_EQUAL(expected_solution[index].count,
20
+ actual_solution[index].count);
21
+ TEST_ASSERT_EQUAL_STRING(expected_solution[index].text,
22
+ actual_solution[index].text);
23
+ }
24
+ }
25
+
26
+ static void reset_actual_solution(void)
27
+ {
28
+ memset(ActualSolution, 0, sizeof(ActualSolution));
29
+ }
30
+
31
+ // Tests Start here
32
+ void test_word_count_one_word(void)
33
+ {
34
+ int index = 0;
35
+ int actual_word_count;
36
+ char *input_text = "word";
37
+ const int expected_word_count = 1;
38
+ WordCount_Word_t ExpectedSolution[expected_word_count];
39
+
40
+ // build the expected solution
41
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
42
+
43
+ // fill in the expected words
44
+ ExpectedSolution[index].count = 1;
45
+ strncpy(ExpectedSolution[index++].text, "word", MAX_WORD_LENGTH);
46
+
47
+ reset_actual_solution();
48
+
49
+ actual_word_count = word_count(input_text, ActualSolution);
50
+
51
+ test_solution(ExpectedSolution,
52
+ expected_word_count, ActualSolution, actual_word_count);
53
+ }
54
+
55
+ void test_word_count_one_of_each_word(void)
56
+ {
57
+ int index = 0;
58
+ int actual_word_count;
59
+ char *input_text = "one of each";
60
+ const int expected_word_count = 3;
61
+ WordCount_Word_t ExpectedSolution[expected_word_count];
62
+
63
+ // build the expected solution
64
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
65
+
66
+ // fill in the expected words
67
+ ExpectedSolution[index].count = 1;
68
+ strncpy(ExpectedSolution[index++].text, "one", MAX_WORD_LENGTH);
69
+
70
+ ExpectedSolution[index].count = 1;
71
+ strncpy(ExpectedSolution[index++].text, "of", MAX_WORD_LENGTH);
72
+
73
+ ExpectedSolution[index].count = 1;
74
+ strncpy(ExpectedSolution[index++].text, "each", MAX_WORD_LENGTH);
75
+
76
+ reset_actual_solution();
77
+ actual_word_count = word_count(input_text, ActualSolution);
78
+
79
+ test_solution(ExpectedSolution,
80
+ expected_word_count, ActualSolution, actual_word_count);
81
+ }
82
+
83
+ void test_word_count_multiple_occurrences_of_a_word(void)
84
+ {
85
+ int index = 0;
86
+ int actual_word_count;
87
+ char *input_text = "one fish two fish red fish blue fish";
88
+ const int expected_word_count = 5;
89
+ WordCount_Word_t ExpectedSolution[expected_word_count];
90
+
91
+ // build the expected solution
92
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
93
+
94
+ ExpectedSolution[index].count = 1;
95
+ strncpy(ExpectedSolution[index++].text, "one", MAX_WORD_LENGTH);
96
+
97
+ ExpectedSolution[index].count = 4;
98
+ strncpy(ExpectedSolution[index++].text, "fish", MAX_WORD_LENGTH);
99
+
100
+ ExpectedSolution[index].count = 1;
101
+ strncpy(ExpectedSolution[index++].text, "two", MAX_WORD_LENGTH);
102
+
103
+ ExpectedSolution[index].count = 1;
104
+ strncpy(ExpectedSolution[index++].text, "red", MAX_WORD_LENGTH);
105
+
106
+ ExpectedSolution[index].count = 1;
107
+ strncpy(ExpectedSolution[index++].text, "blue", MAX_WORD_LENGTH);
108
+
109
+ reset_actual_solution();
110
+ actual_word_count = word_count(input_text, ActualSolution);
111
+
112
+ test_solution(ExpectedSolution,
113
+ expected_word_count, ActualSolution, actual_word_count);
114
+ }
115
+
116
+ void test_word_count_handles_cramped_lists(void)
117
+ {
118
+ int index = 0;
119
+ int actual_word_count;
120
+ char *input_text = "one,two,three";
121
+ const int expected_word_count = 3;
122
+ WordCount_Word_t ExpectedSolution[expected_word_count];
123
+
124
+ // build the expected solution
125
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
126
+
127
+ ExpectedSolution[index].count = 1;
128
+ strncpy(ExpectedSolution[index++].text, "one", MAX_WORD_LENGTH);
129
+
130
+ ExpectedSolution[index].count = 1;
131
+ strncpy(ExpectedSolution[index++].text, "two", MAX_WORD_LENGTH);
132
+
133
+ ExpectedSolution[index].count = 1;
134
+ strncpy(ExpectedSolution[index++].text, "three", MAX_WORD_LENGTH);
135
+
136
+ reset_actual_solution();
137
+ actual_word_count = word_count(input_text, ActualSolution);
138
+
139
+ test_solution(ExpectedSolution,
140
+ expected_word_count, ActualSolution, actual_word_count);
141
+ }
142
+
143
+ void test_word_count_handles_expanded_lists(void)
144
+ {
145
+ int index = 0;
146
+ int actual_word_count;
147
+ char *input_text = "one,\ntwo,\nthree";
148
+ const int expected_word_count = 3;
149
+ WordCount_Word_t ExpectedSolution[expected_word_count];
150
+
151
+ // build the expected solution
152
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
153
+
154
+ ExpectedSolution[index].count = 1;
155
+ strncpy(ExpectedSolution[index++].text, "one", MAX_WORD_LENGTH);
156
+
157
+ ExpectedSolution[index].count = 1;
158
+ strncpy(ExpectedSolution[index++].text, "two", MAX_WORD_LENGTH);
159
+
160
+ ExpectedSolution[index].count = 1;
161
+ strncpy(ExpectedSolution[index++].text, "three", MAX_WORD_LENGTH);
162
+
163
+ reset_actual_solution();
164
+ actual_word_count = word_count(input_text, ActualSolution);
165
+
166
+ test_solution(ExpectedSolution,
167
+ expected_word_count, ActualSolution, actual_word_count);
168
+ }
169
+
170
+ void test_word_count_ignore_punctuation(void)
171
+ {
172
+ int index = 0;
173
+ int actual_word_count;
174
+ char *input_text = "car: carpet as java: javascript!!&@$%^&";
175
+ const int expected_word_count = 5;
176
+ WordCount_Word_t ExpectedSolution[expected_word_count];
177
+
178
+ // build the expected solution
179
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
180
+
181
+ ExpectedSolution[index].count = 1;
182
+ strncpy(ExpectedSolution[index++].text, "car", MAX_WORD_LENGTH);
183
+
184
+ ExpectedSolution[index].count = 1;
185
+ strncpy(ExpectedSolution[index++].text, "carpet", MAX_WORD_LENGTH);
186
+
187
+ ExpectedSolution[index].count = 1;
188
+ strncpy(ExpectedSolution[index++].text, "as", MAX_WORD_LENGTH);
189
+
190
+ ExpectedSolution[index].count = 1;
191
+ strncpy(ExpectedSolution[index++].text, "java", MAX_WORD_LENGTH);
192
+
193
+ ExpectedSolution[index].count = 1;
194
+ strncpy(ExpectedSolution[index++].text, "javascript", MAX_WORD_LENGTH);
195
+
196
+ reset_actual_solution();
197
+ actual_word_count = word_count(input_text, ActualSolution);
198
+
199
+ test_solution(ExpectedSolution,
200
+ expected_word_count, ActualSolution, actual_word_count);
201
+ }
202
+
203
+ void test_word_count_include_numbers(void)
204
+ {
205
+ int index = 0;
206
+ int actual_word_count;
207
+ char *input_text = "testing, 1, 2 testing";
208
+ const int expected_word_count = 3;
209
+ WordCount_Word_t ExpectedSolution[expected_word_count];
210
+
211
+ // build the expected solution
212
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
213
+
214
+ ExpectedSolution[index].count = 2;
215
+ strncpy(ExpectedSolution[index++].text, "testing", MAX_WORD_LENGTH);
216
+
217
+ ExpectedSolution[index].count = 1;
218
+ strncpy(ExpectedSolution[index++].text, "1", MAX_WORD_LENGTH);
219
+
220
+ ExpectedSolution[index].count = 1;
221
+ strncpy(ExpectedSolution[index++].text, "2", MAX_WORD_LENGTH);
222
+
223
+ reset_actual_solution();
224
+ actual_word_count = word_count(input_text, ActualSolution);
225
+
226
+ test_solution(ExpectedSolution,
227
+ expected_word_count, ActualSolution, actual_word_count);
228
+ }
229
+
230
+ void test_word_count_normalize_case(void)
231
+ {
232
+ int index = 0;
233
+ int actual_word_count;
234
+ char *input_text = "go Go GO Stop stop";
235
+ const int expected_word_count = 2;
236
+ WordCount_Word_t ExpectedSolution[expected_word_count];
237
+
238
+ // build the expected solution
239
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
240
+
241
+ ExpectedSolution[index].count = 3;
242
+ strncpy(ExpectedSolution[index++].text, "go", MAX_WORD_LENGTH);
243
+
244
+ ExpectedSolution[index].count = 2;
245
+ strncpy(ExpectedSolution[index++].text, "stop", MAX_WORD_LENGTH);
246
+
247
+ reset_actual_solution();
248
+ actual_word_count = word_count(input_text, ActualSolution);
249
+
250
+ test_solution(ExpectedSolution,
251
+ expected_word_count, ActualSolution, actual_word_count);
252
+ }
253
+
254
+ void test_word_count_with_apostrophes(void)
255
+ {
256
+ int index = 0;
257
+ int actual_word_count;
258
+ char *input_text = "First: don't laugh. Then: don't cry.";
259
+ const int expected_word_count = 5;
260
+ WordCount_Word_t ExpectedSolution[expected_word_count];
261
+
262
+ // build the expected solution
263
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
264
+
265
+ ExpectedSolution[index].count = 1;
266
+ strncpy(ExpectedSolution[index++].text, "first", MAX_WORD_LENGTH);
267
+
268
+ ExpectedSolution[index].count = 2;
269
+ strncpy(ExpectedSolution[index++].text, "don't", MAX_WORD_LENGTH);
270
+
271
+ ExpectedSolution[index].count = 1;
272
+ strncpy(ExpectedSolution[index++].text, "laugh", MAX_WORD_LENGTH);
273
+
274
+ ExpectedSolution[index].count = 1;
275
+ strncpy(ExpectedSolution[index++].text, "then", MAX_WORD_LENGTH);
276
+
277
+ ExpectedSolution[index].count = 1;
278
+ strncpy(ExpectedSolution[index++].text, "cry", MAX_WORD_LENGTH);
279
+
280
+ reset_actual_solution();
281
+ actual_word_count = word_count(input_text, ActualSolution);
282
+
283
+ test_solution(ExpectedSolution,
284
+ expected_word_count, ActualSolution, actual_word_count);
285
+ }
286
+
287
+ void test_word_count_with_quotation(void)
288
+ {
289
+ int index = 0;
290
+ int actual_word_count;
291
+ char *input_text = "Joe can't tell between 'large' and large.";
292
+ const int expected_word_count = 6;
293
+ WordCount_Word_t ExpectedSolution[expected_word_count];
294
+
295
+ // build the expected solution
296
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
297
+
298
+ ExpectedSolution[index].count = 1;
299
+ strncpy(ExpectedSolution[index++].text, "joe", MAX_WORD_LENGTH);
300
+
301
+ ExpectedSolution[index].count = 1;
302
+ strncpy(ExpectedSolution[index++].text, "can't", MAX_WORD_LENGTH);
303
+
304
+ ExpectedSolution[index].count = 1;
305
+ strncpy(ExpectedSolution[index++].text, "tell", MAX_WORD_LENGTH);
306
+
307
+ ExpectedSolution[index].count = 1;
308
+ strncpy(ExpectedSolution[index++].text, "between", MAX_WORD_LENGTH);
309
+
310
+ ExpectedSolution[index].count = 2;
311
+ strncpy(ExpectedSolution[index++].text, "large", MAX_WORD_LENGTH);
312
+
313
+ ExpectedSolution[index].count = 1;
314
+ strncpy(ExpectedSolution[index++].text, "and", MAX_WORD_LENGTH);
315
+
316
+ reset_actual_solution();
317
+ actual_word_count = word_count(input_text, ActualSolution);
318
+
319
+ test_solution(ExpectedSolution,
320
+ expected_word_count, ActualSolution, actual_word_count);
321
+ }
322
+
323
+ void test_word_count_from_example(void)
324
+ {
325
+ int index = 0;
326
+ int actual_word_count;
327
+ char *input_text = "olly olly in come free";
328
+ const int expected_word_count = 4;
329
+ WordCount_Word_t ExpectedSolution[expected_word_count];
330
+
331
+ // build the expected solution
332
+ memset(ExpectedSolution, 0, sizeof(ExpectedSolution)); // clear to start with a known value
333
+
334
+ ExpectedSolution[index].count = 2;
335
+ strncpy(ExpectedSolution[index++].text, "olly", MAX_WORD_LENGTH);
336
+
337
+ ExpectedSolution[index].count = 1;
338
+ strncpy(ExpectedSolution[index++].text, "in", MAX_WORD_LENGTH);
339
+
340
+ ExpectedSolution[index].count = 1;
341
+ strncpy(ExpectedSolution[index++].text, "come", MAX_WORD_LENGTH);
342
+
343
+ ExpectedSolution[index].count = 1;
344
+ strncpy(ExpectedSolution[index++].text, "free", MAX_WORD_LENGTH);
345
+
346
+ reset_actual_solution();
347
+ actual_word_count = word_count(input_text, ActualSolution);
348
+
349
+ test_solution(ExpectedSolution,
350
+ expected_word_count, ActualSolution, actual_word_count);
351
+ }
352
+
353
+ int main(void)
354
+ {
355
+ UnityBegin("test/test_word_count.c");
356
+
357
+ RUN_TEST(test_word_count_one_word);
358
+ RUN_TEST(test_word_count_one_of_each_word);
359
+ RUN_TEST(test_word_count_multiple_occurrences_of_a_word);
360
+ RUN_TEST(test_word_count_handles_cramped_lists);
361
+ RUN_TEST(test_word_count_handles_expanded_lists);
362
+ RUN_TEST(test_word_count_ignore_punctuation);
363
+ RUN_TEST(test_word_count_include_numbers);
364
+ RUN_TEST(test_word_count_normalize_case);
365
+ RUN_TEST(test_word_count_with_apostrophes);
366
+ RUN_TEST(test_word_count_with_quotation);
367
+ RUN_TEST(test_word_count_from_example);
368
+
369
+ UnityEnd();
370
+
371
+ return 0;
372
+ }