diff options
Diffstat (limited to 'test/test_citation.ml')
| -rw-r--r-- | test/test_citation.ml | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/test/test_citation.ml b/test/test_citation.ml index 25fc260..d9be86e 100644 --- a/test/test_citation.ml +++ b/test/test_citation.ml @@ -174,6 +174,23 @@ let test_every_data_file_token_resolves () = Alcotest.failf "unresolved book tokens in shipped data: %s" (String.concat ", " unresolved) +(* lang/traditions.ini's own [modern] section, duplicated here on purpose: + the shipped file and this expectation are written twice and must agree, + so a typo in either is visible. Two ids mapping onto the SAME target is + always a typo -- it would silently merge two books -- so this asserts the + mapping is injective, not merely that every id is known. *) +let test_modern_tradition_is_injective () = + let fields = + [ ("kings_3", "kings_1"); ("kings_4", "kings_2"); + ("esdras_2", "nehemiah"); ("ecclesiasticus", "sirach"); + ("osee", "hosea"); ("jonas", "jonah") ] + in + Alcotest.(check (list string)) "all ids known" [] (B.unknown_fields fields); + let targets = List.map snd fields in + let uniq = List.sort_uniq compare targets in + Alcotest.(check int) "no two ids share a target" + (List.length targets) (List.length uniq) + let suite = ( "book", [ Alcotest.test_case "both spellings one book" `Quick test_both_spellings_are_one_book; @@ -185,7 +202,9 @@ let suite = Alcotest.test_case "tokens has no duplicate spelling" `Quick test_tokens_has_no_duplicate_spelling; Alcotest.test_case "every data file token resolves" `Quick - test_every_data_file_token_resolves ] ) + test_every_data_file_token_resolves; + Alcotest.test_case "modern tradition is injective" `Quick + test_modern_tradition_is_injective ] ) module P = Colitur_citation.Parse |
