Sha256: 4347657a67c5cc565e8b1e862c4aecd0a36eed29ca88743b481d11affc2cc05d

Contents?: true

Size: 1.18 KB

Versions: 68

Compression:

Stored size: 1.18 KB

Contents

open OUnit2
open Grade_school

let assert_lists_equal exp got _ctx =
  let printer = String.concat ";" in
  assert_equal exp got ~printer

let tests = [
  "an empty school has no children in grade 1" >::
    assert_lists_equal [] (grade 1 empty_school);
  "an empty school has Emma in grade 1 after she's been added to grade 1" >::(
    let s = add "Emma" 1 empty_school in
    assert_lists_equal ["Emma"] (grade 1 s)
  );
  "an empty school does not have Emma in grade 1 after she's been added to grade 2" >::(
    let s = add "Emma" 2 empty_school in
    assert_lists_equal [] (grade 1 s)
  );
  "an empty school has Emma, Timmy, Bob and Becky in grade 1 after they've been added to grade 1" >::(
    let s = empty_school |> add "Emma" 1 |> add "Timmy" 1 |> add "Bob" 1 |> add "Becky" 1 in
    assert_lists_equal ["Becky"; "Bob"; "Emma"; "Timmy"] (grade 1 s |> List.sort compare)
  );
  "a sorted school has Emma, Timmy, Bob and Becky in grade 1 in sorted order" >::(
    let s = empty_school |> add "Emma" 1 |> add "Timmy" 1 |> add "Bob" 1 |> add "Becky" 1 |> sorted in
    assert_lists_equal ["Becky"; "Bob"; "Emma"; "Timmy"] (grade 1 s)
  );
]

let () =
  run_test_tt_main ("grade-school tests" >::: tests)

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.179 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.178 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.177 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.176 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.175 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.174 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.173 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.172 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.171 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.170 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.169 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.167 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.166 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.165 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.164 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.163 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.162 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.161 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.160 tracks/ocaml/exercises/grade-school/test.ml