blob: 0f41f11dfa82207bd2191ad9b3663a574e44b859 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
module C = Colitur_kernel.Colour
module S = Colitur_kernel.Subject
let test_colour_strings () =
Alcotest.(check string) "violet" "violet" (C.to_string C.Violet);
Alcotest.(check bool) "of_string rose" true (C.of_string "rose" = Some C.Rose);
Alcotest.(check bool) "of_string junk" true (C.of_string "puce" = None);
Alcotest.(check int) "all has six" 6 (List.length C.all)
let test_subject_strings () =
Alcotest.(check string) "bvm" "bvm" (S.to_string S.Bvm);
Alcotest.(check bool) "of_string lord" true (S.of_string "lord" = Some S.Lord);
Alcotest.(check int) "all has four" 4 (List.length S.all)
(* Every constructor round-trips through both string and sexp. *)
let test_roundtrips () =
List.iter
(fun c ->
Alcotest.(check bool) "colour string roundtrip" true (C.of_string (C.to_string c) = Some c);
Alcotest.(check bool) "colour sexp roundtrip" true (C.t_of_sexp (C.sexp_of_t c) = c))
C.all;
List.iter
(fun s ->
Alcotest.(check bool) "subject string roundtrip" true (S.of_string (S.to_string s) = Some s);
Alcotest.(check bool) "subject sexp roundtrip" true (S.t_of_sexp (S.sexp_of_t s) = s))
S.all
let suite =
( "Colour/Subject",
[ Alcotest.test_case "colour strings" `Quick test_colour_strings;
Alcotest.test_case "subject strings" `Quick test_subject_strings;
Alcotest.test_case "roundtrips" `Quick test_roundtrips ] )
|