Sha256: 97d8cc2171c67fe6b9510bae3d79519993b2f087980b4bdcb6f44430c231fdb3

Contents?: true

Size: 1.64 KB

Versions: 99

Compression:

Stored size: 1.64 KB

Contents

open Core.Std
open OUnit2
open Word_count

module SMap = String.Map

let ae exp got _test_ctxt =
  let printer m = SMap.sexp_of_t Int.sexp_of_t m |> Sexp.to_string_hum ~indent:1 in
  assert_equal (SMap.of_alist_exn exp) got ~cmp:(SMap.equal (=)) ~printer

let tests = [
   "count one word" >::
      ae [("word", 1)]
         (word_count "word");
   "count one of each word" >::
      ae [("one", 1); ("of", 1); ("each", 1)]
         (word_count "one of each");
   "multiple occurrences of a word" >::
      ae [("one", 1); ("fish", 4); ("two", 1); ("red", 1); ("blue", 1)]
         (word_count "one fish two fish red fish blue fish");
   "handles cramped lists" >::
      ae [("one", 1); ("two", 1); ("three", 1)]
         (word_count "one,two,three");
   "handles expanded lists" >::
      ae [("one", 1); ("two", 1); ("three", 1)]
         (word_count "one,\ntwo,\nthree");
   "ignore punctuation" >::
      ae [("car", 1); ("carpet", 1); ("as", 1); ("java", 1); ("javascript", 1)]
         (word_count "car: carpet as java: javascript!!&@$%^&");
   "include numbers" >::
      ae [("testing", 2); ("1", 1); ("2", 1)]
         (word_count "testing, 1, 2 testing");
   "normalize case" >::
      ae [("go", 3); ("stop", 2)]
         (word_count "go Go GO Stop stop");
   "with apostrophes" >::
      ae [("first", 1); ("don't", 2); ("laugh", 1); ("then", 1); ("cry", 1)]
         (word_count "First: don't laugh. Then: don't cry.");
   "with_quotations" >::
      ae [("joe", 1); ("can't", 1); ("tell", 1); ("between", 1); ("large", 2); ("and", 1)]
         (word_count "Joe can't tell between 'large' and large.");
]

let () =
  run_test_tt_main ("word_count tests" >::: tests)

Version data entries

99 entries across 99 versions & 1 rubygems

Version Path
trackler-2.0.6.3 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.6.2 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.6.1 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.6.0 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.18 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.17 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.16 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.15 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.14 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.13 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.12 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.11 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.10 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.9 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.8 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.7 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.6 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.5 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.4 tracks/ocaml/exercises/word-count/test.ml
trackler-2.0.5.3 tracks/ocaml/exercises/word-count/test.ml