aboutsummaryrefslogtreecommitdiff
path: root/test/test_config.ml
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_config.ml')
-rw-r--r--test/test_config.ml35
1 files changed, 34 insertions, 1 deletions
diff --git a/test/test_config.ml b/test/test_config.ml
index 83da015..d348d9b 100644
--- a/test/test_config.ml
+++ b/test/test_config.ml
@@ -102,6 +102,35 @@ let test_two_defaults_blocks_report_no_unknown_sections () =
let c = ok (C.of_string text) in
Alcotest.(check (list string)) "no unknown sections" [] (C.unknown_sections c)
+(* Task 8: sigla_style/sigla_book/sigla_tradition read the same way
+ lang/template/format do, in the same [\[defaults\]] section -- no new
+ section, and every key recognised (so [unknown_keys] stays empty). *)
+let test_sigla_keys_are_read () =
+ let text =
+ "[defaults]\nsigla_style = la\nsigla_book = full\nsigla_tradition = modern\n"
+ in
+ match C.of_string text with
+ | Error e -> Alcotest.failf "parse: %s" e
+ | Ok c ->
+ Alcotest.(check (option string)) "style" (Some "la") (C.sigla_style c);
+ Alcotest.(check (option string)) "book" (Some "full") (C.sigla_book c);
+ Alcotest.(check (option string)) "tradition" (Some "modern") (C.sigla_tradition c);
+ Alcotest.(check (list string)) "nothing unknown" [] (C.unknown_keys c)
+
+(* The empty config carries no sigla settings either -- same "all None"
+ contract [test_empty_config_is_all_none] already asserts for lang. *)
+let test_empty_config_sigla_keys_are_none () =
+ Alcotest.(check (option string)) "sigla_style" None (C.sigla_style C.empty);
+ Alcotest.(check (option string)) "sigla_book" None (C.sigla_book C.empty);
+ Alcotest.(check (option string)) "sigla_tradition" None (C.sigla_tradition C.empty)
+
+(* Same last-wins duplicate policy as lang/template/format: a key repeated
+ across two [\[defaults\]] blocks resolves to the LATER block's value. *)
+let test_sigla_key_repeated_across_blocks_last_wins () =
+ let text = "[defaults]\nsigla_book = full\n\n[defaults]\nsigla_book = abbr\n" in
+ let c = ok (C.of_string text) in
+ Alcotest.(check (option string)) "later block's sigla_book wins" (Some "abbr") (C.sigla_book c)
+
let suite =
( "Config",
[ Alcotest.test_case "reads defaults" `Quick test_reads_defaults;
@@ -119,4 +148,8 @@ let suite =
Alcotest.test_case "overlays accumulate across blocks"
`Quick test_overlays_accumulate_across_blocks;
Alcotest.test_case "two defaults blocks report no unknown sections"
- `Quick test_two_defaults_blocks_report_no_unknown_sections ] )
+ `Quick test_two_defaults_blocks_report_no_unknown_sections;
+ Alcotest.test_case "sigla keys are read" `Quick test_sigla_keys_are_read;
+ Alcotest.test_case "empty config sigla keys are none" `Quick test_empty_config_sigla_keys_are_none;
+ Alcotest.test_case "sigla key repeated across blocks last wins"
+ `Quick test_sigla_key_repeated_across_blocks_last_wins ] )