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.139 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.138 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.137 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.136 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.135 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.134 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.133 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.132 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.131 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.130 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.129 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.128 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.127 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.126 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.125 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.124 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.123 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.122 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.121 tracks/ocaml/exercises/grade-school/test.ml
trackler-2.2.1.120 tracks/ocaml/exercises/grade-school/test.ml