blob: 0694d8bc66d072f5213cf4fd72c9f8342637fcd3 (
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
33
34
35
36
37
38
39
40
41
42
43
|
module B = Colitur_citation.Book
let s = Alcotest.string
let test_both_spellings_are_one_book () =
(* The seven inherited duplicate spellings must collapse. This is the
whole reason the parser exists rather than a regex. *)
let same a b =
match B.of_token a, B.of_token b with
| Some x, Some y ->
Alcotest.(check s) (a ^ " = " ^ b) (B.to_string x) (B.to_string y)
| _ -> Alcotest.failf "%s or %s did not resolve" a b
in
same "Isa" "Isa.";
same "Matt" "Matt.";
same "1 Cor" "1 Cor.";
same "1 Pet" "1 Pet.";
same "1 Thess" "1 Thess.";
same "Eph" "Eph.";
same "3 Kgs." "3 Kings"
let test_unknown_token_is_none () =
Alcotest.(check bool) "not a book" true (B.of_token "Nonesuch" = None)
let test_vulgate_is_identity () =
match B.of_token "3 Kings" with
| None -> Alcotest.fail "3 Kings did not resolve"
| Some k ->
Alcotest.(check s) "unmapped" "kings_3" (B.to_string (B.map B.vulgate k))
let test_modern_renumbers () =
let modern = B.tradition_of_fields [ ("kings_3", "kings_1") ] in
match B.of_token "3 Kings" with
| None -> Alcotest.fail "3 Kings did not resolve"
| Some k ->
Alcotest.(check s) "renumbered" "kings_1" (B.to_string (B.map modern k))
let suite =
( "book",
[ Alcotest.test_case "both spellings one book" `Quick test_both_spellings_are_one_book;
Alcotest.test_case "unknown token" `Quick test_unknown_token_is_none;
Alcotest.test_case "vulgate identity" `Quick test_vulgate_is_identity;
Alcotest.test_case "modern renumbers" `Quick test_modern_renumbers ] )
|