trackler 2.2.1.59 → 2.2.1.60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/food-chain/canonical-data.json +31 -23
  4. data/problem-specifications/exercises/house/canonical-data.json +45 -33
  5. data/problem-specifications/exercises/house/description.md +1 -1
  6. data/problem-specifications/exercises/kindergarten-garden/description.md +3 -3
  7. data/problem-specifications/exercises/nucleotide-count/description.md +2 -2
  8. data/problem-specifications/exercises/palindrome-products/description.md +1 -1
  9. data/problem-specifications/exercises/rectangles/description.md +9 -9
  10. data/problem-specifications/exercises/twelve-days/canonical-data.json +171 -0
  11. data/problem-specifications/exercises/two-bucket/description.md +7 -7
  12. data/tracks/c/docs/CONTRIBUTING.md +88 -39
  13. data/tracks/c/exercises/phone-number/test/test_phone_number.c +33 -29
  14. data/tracks/c/exercises/triangle/src/example.c +12 -12
  15. data/tracks/c/exercises/triangle/src/example.h +3 -3
  16. data/tracks/c/exercises/triangle/test/test_triangle.c +16 -16
  17. data/tracks/c/exercises/word-count/src/example.c +12 -3
  18. data/tracks/c/exercises/word-count/src/word_count.h +10 -5
  19. data/tracks/c/exercises/word-count/test/test_word_count.c +248 -58
  20. data/tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon +3 -3
  21. data/tracks/ceylon/exercises/leap/source/leap/LeapTest.ceylon +2 -2
  22. data/tracks/dart/exercises/phone-number/README.md +1 -1
  23. data/tracks/dart/exercises/phone-number/test/phone_number_test.dart +5 -5
  24. data/tracks/gnu-apl/.dockerignore +5 -0
  25. data/tracks/gnu-apl/.travis.yml +9 -4
  26. data/tracks/gnu-apl/Dockerfiles/release.dockerfile +15 -0
  27. data/tracks/gnu-apl/Dockerfiles/svn.dockerfile +22 -0
  28. data/tracks/gnu-apl/README.md +1 -1
  29. data/tracks/gnu-apl/bin/install-apl +26 -0
  30. data/tracks/gnu-apl/test.apl +7 -6
  31. data/tracks/go/docs/TESTS.md +1 -1
  32. data/tracks/haskell/.travis.yml +1 -1
  33. data/tracks/haskell/config.json +9 -0
  34. data/tracks/haskell/exercises/accumulate/stack.yaml +1 -1
  35. data/tracks/haskell/exercises/acronym/package.yaml +1 -1
  36. data/tracks/haskell/exercises/acronym/stack.yaml +1 -1
  37. data/tracks/haskell/exercises/acronym/test/Tests.hs +3 -0
  38. data/tracks/haskell/exercises/all-your-base/stack.yaml +1 -1
  39. data/tracks/haskell/exercises/allergies/stack.yaml +1 -1
  40. data/tracks/haskell/exercises/alphametics/examples/success-standard/src/Alphametics.hs +2 -1
  41. data/tracks/haskell/exercises/alphametics/stack.yaml +1 -1
  42. data/tracks/haskell/exercises/anagram/stack.yaml +1 -1
  43. data/tracks/haskell/exercises/atbash-cipher/stack.yaml +1 -1
  44. data/tracks/haskell/exercises/bank-account/stack.yaml +1 -1
  45. data/tracks/haskell/exercises/beer-song/stack.yaml +1 -1
  46. data/tracks/haskell/exercises/binary-search-tree/stack.yaml +1 -1
  47. data/tracks/haskell/exercises/binary/stack.yaml +1 -1
  48. data/tracks/haskell/exercises/bob/stack.yaml +1 -1
  49. data/tracks/haskell/exercises/bowling/stack.yaml +1 -1
  50. data/tracks/haskell/exercises/bracket-push/stack.yaml +1 -1
  51. data/tracks/haskell/exercises/change/stack.yaml +1 -1
  52. data/tracks/haskell/exercises/clock/stack.yaml +1 -1
  53. data/tracks/haskell/exercises/collatz-conjecture/stack.yaml +1 -1
  54. data/tracks/haskell/exercises/complex-numbers/stack.yaml +1 -1
  55. data/tracks/haskell/exercises/connect/stack.yaml +1 -1
  56. data/tracks/haskell/exercises/crypto-square/package.yaml +1 -1
  57. data/tracks/haskell/exercises/crypto-square/stack.yaml +1 -1
  58. data/tracks/haskell/exercises/crypto-square/test/Tests.hs +9 -5
  59. data/tracks/haskell/exercises/custom-set/package.yaml +1 -1
  60. data/tracks/haskell/exercises/custom-set/stack.yaml +1 -1
  61. data/tracks/haskell/exercises/custom-set/test/Tests.hs +3 -0
  62. data/tracks/haskell/exercises/diamond/stack.yaml +1 -1
  63. data/tracks/haskell/exercises/difference-of-squares/stack.yaml +1 -1
  64. data/tracks/haskell/exercises/dominoes/README.md +3 -3
  65. data/tracks/haskell/exercises/dominoes/stack.yaml +1 -1
  66. data/tracks/haskell/exercises/etl/stack.yaml +1 -1
  67. data/tracks/haskell/exercises/food-chain/stack.yaml +1 -1
  68. data/tracks/haskell/exercises/forth/stack.yaml +1 -1
  69. data/tracks/haskell/exercises/gigasecond/stack.yaml +1 -1
  70. data/tracks/haskell/exercises/go-counting/stack.yaml +1 -1
  71. data/tracks/haskell/exercises/grade-school/stack.yaml +1 -1
  72. data/tracks/haskell/exercises/grains/stack.yaml +1 -1
  73. data/tracks/haskell/exercises/hamming/package.yaml +1 -1
  74. data/tracks/haskell/exercises/hamming/stack.yaml +1 -1
  75. data/tracks/haskell/exercises/hamming/test/Tests.hs +4 -4
  76. data/tracks/haskell/exercises/hello-world/stack.yaml +1 -1
  77. data/tracks/haskell/exercises/hexadecimal/stack.yaml +1 -1
  78. data/tracks/haskell/exercises/house/README.md +1 -1
  79. data/tracks/haskell/exercises/house/stack.yaml +1 -1
  80. data/tracks/haskell/exercises/isbn-verifier/README.md +96 -0
  81. data/tracks/haskell/exercises/isbn-verifier/examples/success-standard/package.yaml +16 -0
  82. data/tracks/haskell/exercises/isbn-verifier/examples/success-standard/src/IsbnVerifier.hs +10 -0
  83. data/tracks/haskell/exercises/isbn-verifier/package.yaml +20 -0
  84. data/tracks/haskell/exercises/isbn-verifier/src/IsbnVerifier.hs +4 -0
  85. data/tracks/haskell/exercises/isbn-verifier/stack.yaml +1 -0
  86. data/tracks/haskell/exercises/isbn-verifier/test/Tests.hs +74 -0
  87. data/tracks/haskell/exercises/isogram/stack.yaml +1 -1
  88. data/tracks/haskell/exercises/kindergarten-garden/README.md +3 -3
  89. data/tracks/haskell/exercises/kindergarten-garden/stack.yaml +1 -1
  90. data/tracks/haskell/exercises/largest-series-product/stack.yaml +1 -1
  91. data/tracks/haskell/exercises/leap/package.yaml +1 -1
  92. data/tracks/haskell/exercises/leap/stack.yaml +1 -1
  93. data/tracks/haskell/exercises/leap/test/Tests.hs +1 -1
  94. data/tracks/haskell/exercises/lens-person/stack.yaml +1 -1
  95. data/tracks/haskell/exercises/linked-list/stack.yaml +1 -1
  96. data/tracks/haskell/exercises/list-ops/stack.yaml +1 -1
  97. data/tracks/haskell/exercises/luhn/stack.yaml +1 -1
  98. data/tracks/haskell/exercises/matrix/stack.yaml +1 -1
  99. data/tracks/haskell/exercises/meetup/stack.yaml +1 -1
  100. data/tracks/haskell/exercises/minesweeper/stack.yaml +1 -1
  101. data/tracks/haskell/exercises/nth-prime/package.yaml +1 -1
  102. data/tracks/haskell/exercises/nth-prime/stack.yaml +1 -1
  103. data/tracks/haskell/exercises/nucleotide-count/README.md +2 -2
  104. data/tracks/haskell/exercises/nucleotide-count/package.yaml +1 -1
  105. data/tracks/haskell/exercises/nucleotide-count/stack.yaml +1 -1
  106. data/tracks/haskell/exercises/nucleotide-count/test/Tests.hs +6 -0
  107. data/tracks/haskell/exercises/ocr-numbers/stack.yaml +1 -1
  108. data/tracks/haskell/exercises/octal/stack.yaml +1 -1
  109. data/tracks/haskell/exercises/palindrome-products/README.md +1 -1
  110. data/tracks/haskell/exercises/palindrome-products/stack.yaml +1 -1
  111. data/tracks/haskell/exercises/pangram/package.yaml +1 -1
  112. data/tracks/haskell/exercises/pangram/stack.yaml +1 -1
  113. data/tracks/haskell/exercises/pangram/test/Tests.hs +6 -2
  114. data/tracks/haskell/exercises/parallel-letter-frequency/stack.yaml +1 -1
  115. data/tracks/haskell/exercises/pascals-triangle/stack.yaml +1 -1
  116. data/tracks/haskell/exercises/perfect-numbers/stack.yaml +1 -1
  117. data/tracks/haskell/exercises/phone-number/README.md +1 -1
  118. data/tracks/haskell/exercises/phone-number/stack.yaml +1 -1
  119. data/tracks/haskell/exercises/pig-latin/stack.yaml +1 -1
  120. data/tracks/haskell/exercises/pov/stack.yaml +1 -1
  121. data/tracks/haskell/exercises/prime-factors/stack.yaml +1 -1
  122. data/tracks/haskell/exercises/pythagorean-triplet/stack.yaml +1 -1
  123. data/tracks/haskell/exercises/queen-attack/stack.yaml +1 -1
  124. data/tracks/haskell/exercises/raindrops/stack.yaml +1 -1
  125. data/tracks/haskell/exercises/rna-transcription/stack.yaml +1 -1
  126. data/tracks/haskell/exercises/robot-name/stack.yaml +1 -1
  127. data/tracks/haskell/exercises/robot-simulator/stack.yaml +1 -1
  128. data/tracks/haskell/exercises/roman-numerals/stack.yaml +1 -1
  129. data/tracks/haskell/exercises/rotational-cipher/stack.yaml +1 -1
  130. data/tracks/haskell/exercises/run-length-encoding/stack.yaml +1 -1
  131. data/tracks/haskell/exercises/saddle-points/stack.yaml +1 -1
  132. data/tracks/haskell/exercises/say/stack.yaml +1 -1
  133. data/tracks/haskell/exercises/scrabble-score/stack.yaml +1 -1
  134. data/tracks/haskell/exercises/secret-handshake/stack.yaml +1 -1
  135. data/tracks/haskell/exercises/series/stack.yaml +1 -1
  136. data/tracks/haskell/exercises/sgf-parsing/stack.yaml +1 -1
  137. data/tracks/haskell/exercises/sieve/stack.yaml +1 -1
  138. data/tracks/haskell/exercises/simple-cipher/stack.yaml +1 -1
  139. data/tracks/haskell/exercises/simple-linked-list/stack.yaml +1 -1
  140. data/tracks/haskell/exercises/space-age/stack.yaml +1 -1
  141. data/tracks/haskell/exercises/spiral-matrix/stack.yaml +1 -1
  142. data/tracks/haskell/exercises/strain/stack.yaml +1 -1
  143. data/tracks/haskell/exercises/sublist/stack.yaml +1 -1
  144. data/tracks/haskell/exercises/sum-of-multiples/stack.yaml +1 -1
  145. data/tracks/haskell/exercises/triangle/stack.yaml +1 -1
  146. data/tracks/haskell/exercises/trinary/stack.yaml +1 -1
  147. data/tracks/haskell/exercises/word-count/stack.yaml +1 -1
  148. data/tracks/haskell/exercises/wordy/examples/success-standard/src/WordProblem.hs +6 -5
  149. data/tracks/haskell/exercises/wordy/stack.yaml +1 -1
  150. data/tracks/haskell/exercises/zebra-puzzle/package.yaml +1 -1
  151. data/tracks/haskell/exercises/zebra-puzzle/stack.yaml +1 -1
  152. data/tracks/haskell/exercises/zipper/README.md +1 -1
  153. data/tracks/haskell/exercises/zipper/stack.yaml +1 -1
  154. data/tracks/javascript/.eslintignore +43 -0
  155. data/tracks/javascript/.travis.yml +2 -1
  156. data/tracks/javascript/exercises/bowling/README.md +5 -5
  157. data/tracks/javascript/exercises/crypto-square/example.js +2 -1
  158. data/tracks/javascript/exercises/diffie-hellman/diffie-hellman.spec.js +20 -20
  159. data/tracks/javascript/exercises/diffie-hellman/example.js +10 -10
  160. data/tracks/javascript/exercises/largest-series-product/example.js +2 -1
  161. data/tracks/javascript/exercises/sieve/example.js +5 -2
  162. data/tracks/javascript/package-lock.json +129 -76
  163. data/tracks/javascript/package.json +6 -5
  164. data/tracks/ocaml/config.json +10 -0
  165. data/tracks/ocaml/exercises/hamming/test.ml +3 -3
  166. data/tracks/ocaml/exercises/leap/test.ml +2 -2
  167. data/tracks/ocaml/exercises/pangram/test.ml +3 -3
  168. data/tracks/ocaml/exercises/rectangles/.merlin +5 -0
  169. data/tracks/ocaml/exercises/rectangles/Makefile +11 -0
  170. data/tracks/ocaml/exercises/rectangles/example.ml +30 -0
  171. data/tracks/ocaml/exercises/rectangles/rectangles.mli +1 -0
  172. data/tracks/ocaml/exercises/rectangles/test.ml +72 -0
  173. data/tracks/ocaml/tools/test-generator/templates/ocaml/leap/test.ml +1 -1
  174. data/tracks/ocaml/tools/test-generator/templates/ocaml/rectangles/test.ml +15 -0
  175. data/tracks/pony/README.md +1 -1
  176. data/tracks/pony/exercises/atbash-cipher/example.pony +6 -10
  177. data/tracks/pony/exercises/difference-of-squares/example.pony +3 -7
  178. data/tracks/rust/_test/count-ignores.sh +2 -2
  179. data/tracks/rust/config.json +24 -0
  180. data/tracks/rust/config/maintainers.json +10 -0
  181. data/tracks/rust/exercises/acronym/README.md +0 -1
  182. data/tracks/rust/exercises/all-your-base/README.md +1 -1
  183. data/tracks/rust/exercises/allergies/README.md +0 -1
  184. data/tracks/rust/exercises/alphametics/README.md +2 -2
  185. data/tracks/rust/exercises/atbash-cipher/README.md +2 -1
  186. data/tracks/rust/exercises/beer-song/README.md +1 -1
  187. data/tracks/rust/exercises/bowling/README.md +20 -6
  188. data/tracks/rust/exercises/circular-buffer/README.md +13 -6
  189. data/tracks/rust/exercises/crypto-square/README.md +10 -8
  190. data/tracks/rust/exercises/dominoes/Cargo.toml +1 -1
  191. data/tracks/rust/exercises/etl/README.md +2 -0
  192. data/tracks/rust/exercises/grade-school/README.md +0 -1
  193. data/tracks/rust/exercises/grains/README.md +0 -1
  194. data/tracks/rust/exercises/isbn-verifier/Cargo.lock +4 -0
  195. data/tracks/rust/exercises/isbn-verifier/Cargo.toml +3 -0
  196. data/tracks/rust/exercises/isbn-verifier/README.md +74 -0
  197. data/tracks/rust/exercises/isbn-verifier/example.rs +44 -0
  198. data/tracks/rust/exercises/isbn-verifier/src/lib.rs +4 -0
  199. data/tracks/rust/exercises/isbn-verifier/tests/isbn-verifier.rs +83 -0
  200. data/tracks/rust/exercises/isogram/README.md +3 -2
  201. data/tracks/rust/exercises/leap/README.md +1 -1
  202. data/tracks/rust/exercises/luhn/README.md +7 -7
  203. data/tracks/rust/exercises/nucleotide-count/README.md +8 -22
  204. data/tracks/rust/exercises/ocr-numbers/README.md +5 -5
  205. data/tracks/rust/exercises/pangram/README.md +1 -1
  206. data/tracks/rust/exercises/pascals-triangle/README.md +1 -1
  207. data/tracks/rust/exercises/perfect-numbers/README.md +2 -2
  208. data/tracks/rust/exercises/phone-number/README.md +3 -2
  209. data/tracks/rust/exercises/protein-translation/README.md +4 -5
  210. data/tracks/rust/exercises/proverb/README.md +13 -11
  211. data/tracks/rust/exercises/proverb/example.rs +14 -15
  212. data/tracks/rust/exercises/proverb/tests/proverb.rs +40 -13
  213. data/tracks/rust/exercises/pythagorean-triplet/README.md +3 -3
  214. data/tracks/rust/exercises/queen-attack/README.md +1 -1
  215. data/tracks/rust/exercises/rectangles/README.md +7 -7
  216. data/tracks/rust/exercises/roman-numerals/README.md +1 -1
  217. data/tracks/rust/exercises/rotational-cipher/README.md +2 -1
  218. data/tracks/rust/exercises/run-length-encoding/README.md +4 -4
  219. data/tracks/rust/exercises/scrabble-score/README.md +3 -1
  220. data/tracks/rust/exercises/space-age/README.md +1 -1
  221. data/tracks/rust/exercises/tournament/README.md +5 -5
  222. data/tracks/rust/exercises/triangle/README.md +9 -6
  223. data/tracks/rust/exercises/two-bucket/Cargo.lock +4 -0
  224. data/tracks/rust/exercises/two-bucket/Cargo.toml +3 -0
  225. data/tracks/rust/exercises/two-bucket/README.md +69 -0
  226. data/tracks/rust/exercises/two-bucket/example.rs +129 -0
  227. data/tracks/rust/exercises/two-bucket/src/lib.rs +26 -0
  228. data/tracks/rust/exercises/two-bucket/tests/two-bucket.rs +68 -0
  229. data/tracks/rust/exercises/variable-length-quantity/README.md +6 -7
  230. data/tracks/rust/exercises/word-count/README.md +1 -2
  231. data/tracks/rust/exercises/wordy/README.md +0 -5
  232. metadata +33 -4
  233. data/tracks/go/.github/PULL_REQUEST_TEMPLATE.md +0 -23
  234. data/tracks/ruby/.github/PULL_REQUEST_TEMPLATE.md +0 -40
@@ -20,7 +20,7 @@ static int word_match(char *testWord, int current_word_count,
20
20
  return match_index;
21
21
  }
22
22
 
23
- int word_count(char *input_text, word_count_word_t words[MAX_WORDS])
23
+ int word_count(const char *input_text, word_count_word_t * words)
24
24
  {
25
25
  int index;
26
26
  int unique_words = 0;
@@ -36,7 +36,7 @@ int word_count(char *input_text, word_count_word_t words[MAX_WORDS])
36
36
  lower_case_input_text[index] = '\0';
37
37
 
38
38
  // start with known results...
39
- memset(words, 0, sizeof(word_count_word_t));
39
+ memset(words, 0, sizeof(word_count_word_t) * MAX_WORDS);
40
40
 
41
41
  test_word = strtok(lower_case_input_text, delimiters);
42
42
  while (test_word != NULL) {
@@ -50,8 +50,17 @@ int word_count(char *input_text, word_count_word_t words[MAX_WORDS])
50
50
 
51
51
  // add if not yet counted else increment count.
52
52
  if (-1 == index) {
53
+ // reject anything that would overrun buffers
54
+ if (MAX_WORD_LENGTH < strlen(test_word)) {
55
+ unique_words = EXCESSIVE_LENGTH_WORD;
56
+ break;
57
+ }
58
+ if (MAX_WORDS == unique_words) {
59
+ unique_words = EXCESSIVE_NUMBER_OF_WORDS;
60
+ break;
61
+ }
53
62
  words[unique_words].count = 1;
54
- strcpy(words[unique_words].text, test_word);
63
+ strncpy(words[unique_words].text, test_word, MAX_WORD_LENGTH);
55
64
  unique_words++;
56
65
  } else {
57
66
  words[index].count++;
@@ -1,8 +1,8 @@
1
1
  #ifndef WORD_COUNT_H
2
2
  #define WORD_COUNT_H
3
3
 
4
- #define MAX_WORDS 20 // at most MAX_WORDS will be found in the test input string
5
- #define MAX_WORD_LENGTH 50 // no individual word will exceed this length
4
+ #define MAX_WORDS 20 // at most MAX_WORDS can be found in the test input string
5
+ #define MAX_WORD_LENGTH 50 // no individual word can exceed this length
6
6
 
7
7
  // results structure
8
8
  typedef struct word_count_word {
@@ -10,13 +10,18 @@ typedef struct word_count_word {
10
10
  int count;
11
11
  } word_count_word_t;
12
12
 
13
+ #define EXCESSIVE_LENGTH_WORD -1
14
+ #define EXCESSIVE_NUMBER_OF_WORDS -2
15
+
13
16
  // word_count - routine to classify the unique words and their frequency in a test input string
14
17
  // inputs:
15
- // input_text = string no longer than will take (MAX_WORDS * MAX_WORD_LENGTH)
16
- // words = allocated structure to record the words fourn and their frequency
18
+ // input_text = a null-terminated string containing that is analyzed
17
19
  //
18
20
  // outputs:
21
+ // words = allocated structure to record the words found and their frequency
19
22
  // uniqueWords - number of words in the words structure
20
- int word_count(char *input_text, word_count_word_t words[MAX_WORDS]);
23
+ // returns a negative number if an error.
24
+ // words will contain the results up to that point.
25
+ int word_count(const char *input_text, word_count_word_t * words);
21
26
 
22
27
  #endif
@@ -5,7 +5,7 @@
5
5
  #include "../src/word_count.h"
6
6
 
7
7
  word_count_word_t actual_solution[MAX_WORDS];
8
-
8
+ word_count_word_t expected_solution[MAX_WORDS];
9
9
  void setUp(void)
10
10
  {
11
11
  }
@@ -14,28 +14,24 @@ void tearDown(void)
14
14
  {
15
15
  }
16
16
 
17
- static void test_solution(word_count_word_t * expected_solution,
18
- int expected_word_count,
19
- word_count_word_t * actual_solution,
20
- int actual_word_count)
17
+ static void check_solution(word_count_word_t * expected_solution,
18
+ int expected_word_count,
19
+ word_count_word_t * actual_solution,
20
+ int actual_word_count)
21
21
  {
22
22
  // All words counted?
23
23
  TEST_ASSERT_EQUAL(expected_word_count, actual_word_count);
24
24
 
25
25
  // now test the word count for the words...
26
- for (int index = 0; index < actual_word_count; index++) {
26
+ for (int index = 0; index < MAX_WORDS; index++) {
27
27
  TEST_ASSERT_EQUAL(expected_solution[index].count,
28
28
  actual_solution[index].count);
29
- TEST_ASSERT_EQUAL_STRING(expected_solution[index].text,
30
- actual_solution[index].text);
29
+ TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_solution[index].text,
30
+ actual_solution[index].text,
31
+ MAX_WORD_LENGTH);
31
32
  }
32
33
  }
33
34
 
34
- static void reset_actual_solution(void)
35
- {
36
- memset(actual_solution, 0, sizeof(actual_solution));
37
- }
38
-
39
35
  // Tests Start here
40
36
  void test_word_count_one_word(void)
41
37
  {
@@ -43,7 +39,6 @@ void test_word_count_one_word(void)
43
39
  int actual_word_count;
44
40
  char *input_text = "word";
45
41
  const int expected_word_count = 1;
46
- word_count_word_t expected_solution[expected_word_count];
47
42
 
48
43
  // build the expected solution
49
44
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -52,12 +47,10 @@ void test_word_count_one_word(void)
52
47
  expected_solution[index].count = 1;
53
48
  strncpy(expected_solution[index++].text, "word", MAX_WORD_LENGTH);
54
49
 
55
- reset_actual_solution();
56
-
57
50
  actual_word_count = word_count(input_text, actual_solution);
58
51
 
59
- test_solution(expected_solution,
60
- expected_word_count, actual_solution, actual_word_count);
52
+ check_solution(expected_solution,
53
+ expected_word_count, actual_solution, actual_word_count);
61
54
  }
62
55
 
63
56
  void test_word_count_one_of_each_word(void)
@@ -67,7 +60,6 @@ void test_word_count_one_of_each_word(void)
67
60
  int actual_word_count;
68
61
  char *input_text = "one of each";
69
62
  const int expected_word_count = 3;
70
- word_count_word_t expected_solution[expected_word_count];
71
63
 
72
64
  // build the expected solution
73
65
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -82,11 +74,10 @@ void test_word_count_one_of_each_word(void)
82
74
  expected_solution[index].count = 1;
83
75
  strncpy(expected_solution[index++].text, "each", MAX_WORD_LENGTH);
84
76
 
85
- reset_actual_solution();
86
77
  actual_word_count = word_count(input_text, actual_solution);
87
78
 
88
- test_solution(expected_solution,
89
- expected_word_count, actual_solution, actual_word_count);
79
+ check_solution(expected_solution,
80
+ expected_word_count, actual_solution, actual_word_count);
90
81
  }
91
82
 
92
83
  void test_word_count_multiple_occurrences_of_a_word(void)
@@ -96,7 +87,6 @@ void test_word_count_multiple_occurrences_of_a_word(void)
96
87
  int actual_word_count;
97
88
  char *input_text = "one fish two fish red fish blue fish";
98
89
  const int expected_word_count = 5;
99
- word_count_word_t expected_solution[expected_word_count];
100
90
 
101
91
  // build the expected solution
102
92
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -116,11 +106,10 @@ void test_word_count_multiple_occurrences_of_a_word(void)
116
106
  expected_solution[index].count = 1;
117
107
  strncpy(expected_solution[index++].text, "blue", MAX_WORD_LENGTH);
118
108
 
119
- reset_actual_solution();
120
109
  actual_word_count = word_count(input_text, actual_solution);
121
110
 
122
- test_solution(expected_solution,
123
- expected_word_count, actual_solution, actual_word_count);
111
+ check_solution(expected_solution,
112
+ expected_word_count, actual_solution, actual_word_count);
124
113
  }
125
114
 
126
115
  void test_word_count_handles_cramped_lists(void)
@@ -130,7 +119,6 @@ void test_word_count_handles_cramped_lists(void)
130
119
  int actual_word_count;
131
120
  char *input_text = "one,two,three";
132
121
  const int expected_word_count = 3;
133
- word_count_word_t expected_solution[expected_word_count];
134
122
 
135
123
  // build the expected solution
136
124
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -144,11 +132,10 @@ void test_word_count_handles_cramped_lists(void)
144
132
  expected_solution[index].count = 1;
145
133
  strncpy(expected_solution[index++].text, "three", MAX_WORD_LENGTH);
146
134
 
147
- reset_actual_solution();
148
135
  actual_word_count = word_count(input_text, actual_solution);
149
136
 
150
- test_solution(expected_solution,
151
- expected_word_count, actual_solution, actual_word_count);
137
+ check_solution(expected_solution,
138
+ expected_word_count, actual_solution, actual_word_count);
152
139
  }
153
140
 
154
141
  void test_word_count_handles_expanded_lists(void)
@@ -158,7 +145,6 @@ void test_word_count_handles_expanded_lists(void)
158
145
  int actual_word_count;
159
146
  char *input_text = "one,\ntwo,\nthree";
160
147
  const int expected_word_count = 3;
161
- word_count_word_t expected_solution[expected_word_count];
162
148
 
163
149
  // build the expected solution
164
150
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -172,11 +158,10 @@ void test_word_count_handles_expanded_lists(void)
172
158
  expected_solution[index].count = 1;
173
159
  strncpy(expected_solution[index++].text, "three", MAX_WORD_LENGTH);
174
160
 
175
- reset_actual_solution();
176
161
  actual_word_count = word_count(input_text, actual_solution);
177
162
 
178
- test_solution(expected_solution,
179
- expected_word_count, actual_solution, actual_word_count);
163
+ check_solution(expected_solution,
164
+ expected_word_count, actual_solution, actual_word_count);
180
165
  }
181
166
 
182
167
  void test_word_count_ignore_punctuation(void)
@@ -186,7 +171,6 @@ void test_word_count_ignore_punctuation(void)
186
171
  int actual_word_count;
187
172
  char *input_text = "car: carpet as java: javascript!!&@$%^&";
188
173
  const int expected_word_count = 5;
189
- word_count_word_t expected_solution[expected_word_count];
190
174
 
191
175
  // build the expected solution
192
176
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -206,11 +190,10 @@ void test_word_count_ignore_punctuation(void)
206
190
  expected_solution[index].count = 1;
207
191
  strncpy(expected_solution[index++].text, "javascript", MAX_WORD_LENGTH);
208
192
 
209
- reset_actual_solution();
210
193
  actual_word_count = word_count(input_text, actual_solution);
211
194
 
212
- test_solution(expected_solution,
213
- expected_word_count, actual_solution, actual_word_count);
195
+ check_solution(expected_solution,
196
+ expected_word_count, actual_solution, actual_word_count);
214
197
  }
215
198
 
216
199
  void test_word_count_include_numbers(void)
@@ -220,7 +203,6 @@ void test_word_count_include_numbers(void)
220
203
  int actual_word_count;
221
204
  char *input_text = "testing, 1, 2 testing";
222
205
  const int expected_word_count = 3;
223
- word_count_word_t expected_solution[expected_word_count];
224
206
 
225
207
  // build the expected solution
226
208
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -234,11 +216,10 @@ void test_word_count_include_numbers(void)
234
216
  expected_solution[index].count = 1;
235
217
  strncpy(expected_solution[index++].text, "2", MAX_WORD_LENGTH);
236
218
 
237
- reset_actual_solution();
238
219
  actual_word_count = word_count(input_text, actual_solution);
239
220
 
240
- test_solution(expected_solution,
241
- expected_word_count, actual_solution, actual_word_count);
221
+ check_solution(expected_solution,
222
+ expected_word_count, actual_solution, actual_word_count);
242
223
  }
243
224
 
244
225
  void test_word_count_normalize_case(void)
@@ -248,7 +229,6 @@ void test_word_count_normalize_case(void)
248
229
  int actual_word_count;
249
230
  char *input_text = "go Go GO Stop stop";
250
231
  const int expected_word_count = 2;
251
- word_count_word_t expected_solution[expected_word_count];
252
232
 
253
233
  // build the expected solution
254
234
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -259,11 +239,10 @@ void test_word_count_normalize_case(void)
259
239
  expected_solution[index].count = 2;
260
240
  strncpy(expected_solution[index++].text, "stop", MAX_WORD_LENGTH);
261
241
 
262
- reset_actual_solution();
263
242
  actual_word_count = word_count(input_text, actual_solution);
264
243
 
265
- test_solution(expected_solution,
266
- expected_word_count, actual_solution, actual_word_count);
244
+ check_solution(expected_solution,
245
+ expected_word_count, actual_solution, actual_word_count);
267
246
  }
268
247
 
269
248
  void test_word_count_with_apostrophes(void)
@@ -273,7 +252,6 @@ void test_word_count_with_apostrophes(void)
273
252
  int actual_word_count;
274
253
  char *input_text = "First: don't laugh. Then: don't cry.";
275
254
  const int expected_word_count = 5;
276
- word_count_word_t expected_solution[expected_word_count];
277
255
 
278
256
  // build the expected solution
279
257
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -293,11 +271,10 @@ void test_word_count_with_apostrophes(void)
293
271
  expected_solution[index].count = 1;
294
272
  strncpy(expected_solution[index++].text, "cry", MAX_WORD_LENGTH);
295
273
 
296
- reset_actual_solution();
297
274
  actual_word_count = word_count(input_text, actual_solution);
298
275
 
299
- test_solution(expected_solution,
300
- expected_word_count, actual_solution, actual_word_count);
276
+ check_solution(expected_solution,
277
+ expected_word_count, actual_solution, actual_word_count);
301
278
  }
302
279
 
303
280
  void test_word_count_with_quotation(void)
@@ -307,7 +284,6 @@ void test_word_count_with_quotation(void)
307
284
  int actual_word_count;
308
285
  char *input_text = "Joe can't tell between 'large' and large.";
309
286
  const int expected_word_count = 6;
310
- word_count_word_t expected_solution[expected_word_count];
311
287
 
312
288
  // build the expected solution
313
289
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -330,11 +306,10 @@ void test_word_count_with_quotation(void)
330
306
  expected_solution[index].count = 1;
331
307
  strncpy(expected_solution[index++].text, "and", MAX_WORD_LENGTH);
332
308
 
333
- reset_actual_solution();
334
309
  actual_word_count = word_count(input_text, actual_solution);
335
310
 
336
- test_solution(expected_solution,
337
- expected_word_count, actual_solution, actual_word_count);
311
+ check_solution(expected_solution,
312
+ expected_word_count, actual_solution, actual_word_count);
338
313
  }
339
314
 
340
315
  void test_word_count_from_example(void)
@@ -344,7 +319,6 @@ void test_word_count_from_example(void)
344
319
  int actual_word_count;
345
320
  char *input_text = "olly olly in come free";
346
321
  const int expected_word_count = 4;
347
- word_count_word_t expected_solution[expected_word_count];
348
322
 
349
323
  // build the expected solution
350
324
  memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
@@ -361,11 +335,223 @@ void test_word_count_from_example(void)
361
335
  expected_solution[index].count = 1;
362
336
  strncpy(expected_solution[index++].text, "free", MAX_WORD_LENGTH);
363
337
 
364
- reset_actual_solution();
365
338
  actual_word_count = word_count(input_text, actual_solution);
366
339
 
367
- test_solution(expected_solution,
368
- expected_word_count, actual_solution, actual_word_count);
340
+ check_solution(expected_solution,
341
+ expected_word_count, actual_solution, actual_word_count);
342
+ }
343
+
344
+ void test_max_length_word(void)
345
+ {
346
+ TEST_IGNORE();
347
+ int actual_word_count;
348
+ int index = 0;
349
+ char *input_text =
350
+ "Look thisisaninsanelylongwordtypedwithoutusinganyspaces and look again, thisisaninsanelylongwordtypedwithoutusinganyspaces";
351
+
352
+ const int expected_word_count = 4;
353
+
354
+ // build the expected solution
355
+ memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
356
+
357
+ expected_solution[index].count = 2;
358
+ strncpy(expected_solution[index++].text, "look", MAX_WORD_LENGTH);
359
+
360
+ expected_solution[index].count = 2;
361
+ strncpy(expected_solution[index++].text,
362
+ "thisisaninsanelylongwordtypedwithoutusinganyspaces",
363
+ MAX_WORD_LENGTH);
364
+
365
+ expected_solution[index].count = 1;
366
+ strncpy(expected_solution[index++].text, "and", MAX_WORD_LENGTH);
367
+
368
+ expected_solution[index].count = 1;
369
+ strncpy(expected_solution[index++].text, "again", MAX_WORD_LENGTH);
370
+
371
+ actual_word_count = word_count(input_text, actual_solution);
372
+
373
+ check_solution(expected_solution,
374
+ expected_word_count, actual_solution, actual_word_count);
375
+ }
376
+
377
+ void test_excessive_length_word(void)
378
+ {
379
+ TEST_IGNORE();
380
+ int actual_word_count;
381
+ int index = 0;
382
+ char *input_text =
383
+ "Look thisisanexcessivelylongwordthatsomeonetypedwithoutusingthespacebar enough";
384
+
385
+ const int expected_word_count = EXCESSIVE_LENGTH_WORD;
386
+ word_count_word_t expected_solution[MAX_WORDS];
387
+
388
+ // build the expected solution
389
+ memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
390
+ expected_solution[index].count = 1;
391
+ strncpy(expected_solution[index++].text, "look", MAX_WORD_LENGTH);
392
+
393
+ actual_word_count = word_count(input_text, actual_solution);
394
+
395
+ check_solution(expected_solution,
396
+ expected_word_count, actual_solution, actual_word_count);
397
+ }
398
+
399
+ void test_max_number_words(void)
400
+ {
401
+ TEST_IGNORE();
402
+ int actual_word_count;
403
+ int index = 0;
404
+ char *input_text =
405
+ "Once upon a time, a long while in the past, there lived a strange little man who could spin straw into gold";
406
+
407
+ const int expected_word_count = 20;
408
+
409
+ // build the expected solution
410
+ memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
411
+
412
+ expected_solution[index].count = 1;
413
+ strncpy(expected_solution[index++].text, "once", MAX_WORD_LENGTH);
414
+
415
+ expected_solution[index].count = 1;
416
+ strncpy(expected_solution[index++].text, "upon", MAX_WORD_LENGTH);
417
+
418
+ expected_solution[index].count = 3;
419
+ strncpy(expected_solution[index++].text, "a", MAX_WORD_LENGTH);
420
+
421
+ expected_solution[index].count = 1;
422
+ strncpy(expected_solution[index++].text, "time", MAX_WORD_LENGTH);
423
+
424
+ expected_solution[index].count = 1;
425
+ strncpy(expected_solution[index++].text, "long", MAX_WORD_LENGTH);
426
+
427
+ expected_solution[index].count = 1;
428
+ strncpy(expected_solution[index++].text, "while", MAX_WORD_LENGTH);
429
+
430
+ expected_solution[index].count = 1;
431
+ strncpy(expected_solution[index++].text, "in", MAX_WORD_LENGTH);
432
+
433
+ expected_solution[index].count = 1;
434
+ strncpy(expected_solution[index++].text, "the", MAX_WORD_LENGTH);
435
+
436
+ expected_solution[index].count = 1;
437
+ strncpy(expected_solution[index++].text, "past", MAX_WORD_LENGTH);
438
+
439
+ expected_solution[index].count = 1;
440
+ strncpy(expected_solution[index++].text, "there", MAX_WORD_LENGTH);
441
+
442
+ expected_solution[index].count = 1;
443
+ strncpy(expected_solution[index++].text, "lived", MAX_WORD_LENGTH);
444
+
445
+ expected_solution[index].count = 1;
446
+ strncpy(expected_solution[index++].text, "strange", MAX_WORD_LENGTH);
447
+
448
+ expected_solution[index].count = 1;
449
+ strncpy(expected_solution[index++].text, "little", MAX_WORD_LENGTH);
450
+
451
+ expected_solution[index].count = 1;
452
+ strncpy(expected_solution[index++].text, "man", MAX_WORD_LENGTH);
453
+
454
+ expected_solution[index].count = 1;
455
+ strncpy(expected_solution[index++].text, "who", MAX_WORD_LENGTH);
456
+
457
+ expected_solution[index].count = 1;
458
+ strncpy(expected_solution[index++].text, "could", MAX_WORD_LENGTH);
459
+
460
+ expected_solution[index].count = 1;
461
+ strncpy(expected_solution[index++].text, "spin", MAX_WORD_LENGTH);
462
+
463
+ expected_solution[index].count = 1;
464
+ strncpy(expected_solution[index++].text, "straw", MAX_WORD_LENGTH);
465
+
466
+ expected_solution[index].count = 1;
467
+ strncpy(expected_solution[index++].text, "into", MAX_WORD_LENGTH);
468
+
469
+ expected_solution[index].count = 1;
470
+ strncpy(expected_solution[index++].text, "gold", MAX_WORD_LENGTH);
471
+
472
+ actual_word_count = word_count(input_text, actual_solution);
473
+
474
+ check_solution(expected_solution,
475
+ expected_word_count, actual_solution, actual_word_count);
476
+ }
477
+
478
+ void test_excessive_number_words(void)
479
+ {
480
+ TEST_IGNORE();
481
+ int actual_word_count;
482
+ int index = 0;
483
+ char *input_text =
484
+ "Once upon a time, a long while in the past, there lived a strange little man who could spin straw into gold. His name was...";
485
+
486
+ const int expected_word_count = EXCESSIVE_NUMBER_OF_WORDS;
487
+
488
+ // build the expected solution
489
+ memset(expected_solution, 0, sizeof(expected_solution)); // clear to start with a known value
490
+
491
+ expected_solution[index].count = 1;
492
+ strncpy(expected_solution[index++].text, "once", MAX_WORD_LENGTH);
493
+
494
+ expected_solution[index].count = 1;
495
+ strncpy(expected_solution[index++].text, "upon", MAX_WORD_LENGTH);
496
+
497
+ expected_solution[index].count = 3;
498
+ strncpy(expected_solution[index++].text, "a", MAX_WORD_LENGTH);
499
+
500
+ expected_solution[index].count = 1;
501
+ strncpy(expected_solution[index++].text, "time", MAX_WORD_LENGTH);
502
+
503
+ expected_solution[index].count = 1;
504
+ strncpy(expected_solution[index++].text, "long", MAX_WORD_LENGTH);
505
+
506
+ expected_solution[index].count = 1;
507
+ strncpy(expected_solution[index++].text, "while", MAX_WORD_LENGTH);
508
+
509
+ expected_solution[index].count = 1;
510
+ strncpy(expected_solution[index++].text, "in", MAX_WORD_LENGTH);
511
+
512
+ expected_solution[index].count = 1;
513
+ strncpy(expected_solution[index++].text, "the", MAX_WORD_LENGTH);
514
+
515
+ expected_solution[index].count = 1;
516
+ strncpy(expected_solution[index++].text, "past", MAX_WORD_LENGTH);
517
+
518
+ expected_solution[index].count = 1;
519
+ strncpy(expected_solution[index++].text, "there", MAX_WORD_LENGTH);
520
+
521
+ expected_solution[index].count = 1;
522
+ strncpy(expected_solution[index++].text, "lived", MAX_WORD_LENGTH);
523
+
524
+ expected_solution[index].count = 1;
525
+ strncpy(expected_solution[index++].text, "strange", MAX_WORD_LENGTH);
526
+
527
+ expected_solution[index].count = 1;
528
+ strncpy(expected_solution[index++].text, "little", MAX_WORD_LENGTH);
529
+
530
+ expected_solution[index].count = 1;
531
+ strncpy(expected_solution[index++].text, "man", MAX_WORD_LENGTH);
532
+
533
+ expected_solution[index].count = 1;
534
+ strncpy(expected_solution[index++].text, "who", MAX_WORD_LENGTH);
535
+
536
+ expected_solution[index].count = 1;
537
+ strncpy(expected_solution[index++].text, "could", MAX_WORD_LENGTH);
538
+
539
+ expected_solution[index].count = 1;
540
+ strncpy(expected_solution[index++].text, "spin", MAX_WORD_LENGTH);
541
+
542
+ expected_solution[index].count = 1;
543
+ strncpy(expected_solution[index++].text, "straw", MAX_WORD_LENGTH);
544
+
545
+ expected_solution[index].count = 1;
546
+ strncpy(expected_solution[index++].text, "into", MAX_WORD_LENGTH);
547
+
548
+ expected_solution[index].count = 1;
549
+ strncpy(expected_solution[index++].text, "gold", MAX_WORD_LENGTH);
550
+
551
+ actual_word_count = word_count(input_text, actual_solution);
552
+
553
+ check_solution(expected_solution,
554
+ expected_word_count, actual_solution, actual_word_count);
369
555
  }
370
556
 
371
557
  int main(void)
@@ -383,6 +569,10 @@ int main(void)
383
569
  RUN_TEST(test_word_count_with_apostrophes);
384
570
  RUN_TEST(test_word_count_with_quotation);
385
571
  RUN_TEST(test_word_count_from_example);
572
+ RUN_TEST(test_max_length_word);
573
+ RUN_TEST(test_excessive_length_word);
574
+ RUN_TEST(test_max_number_words);
575
+ RUN_TEST(test_excessive_number_words);
386
576
 
387
577
  UnityEnd();
388
578