From 6b377719c10d5ab3343fd5221f99a4a21008e25a Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 14 Mar 2024 08:26:58 +0100 Subject: Initial commit --- tests/configuration_toml.ml | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/configuration_toml.ml (limited to 'tests/configuration_toml.ml') diff --git a/tests/configuration_toml.ml b/tests/configuration_toml.ml new file mode 100644 index 0000000..3c8bfc2 --- /dev/null +++ b/tests/configuration_toml.ml @@ -0,0 +1,71 @@ +open OUnit2 +module Expression = ImportExpression.T +module Path = ImportDataTypes.Path + +let test_suit = + [ + ( "parse_extern" >:: fun _ -> + let toml = Otoml.Parser.from_file "configuration/simple.toml" in + let toml = ImportConf.t_of_toml toml in + match toml with + | Error s -> raise (Failure s) + | Ok result -> + let open ImportConf.Syntax in + let expected = + { + target = { file = ""; tab = 1; name = "target" }; + extern_key = Literal "_B"; + intern_key = + Function + ( "function", + [ + Path { alias = None; column = 1 }; + Path { alias = None; column = 2 }; + ] ); + match_rule = None; + allow_missing = true; + } + in + + let printer s = + String.concat "," (List.map ImportConf.print_extern s) + in + + assert_equal ~printer [ expected ] result.externals ); + ( "parse_columns" >:: fun _ -> + let toml = Otoml.Parser.from_file "configuration/simple.toml" in + let toml = ImportConf.t_of_toml toml in + + match toml with + | Error s -> raise (Failure s) + | Ok result -> + let open Path in + let open Expression in + let expected = + [ + Function + ( "function", + [ + Path { alias = Some "target"; column = 1 }; + Path { alias = None; column = 2 }; + Literal "free' text"; + ] ); + Window + ( Counter, + [ Path { alias = Some "target"; column = 1 } ], + [ Path { alias = Some "target"; column = 1 } ] ); + ] + in + + List.iter2 + (fun expected result -> + assert_equal ~printer:ImportConf.print_path_expression expected + result) + expected result.columns ); + ( "parse_csv" >:: fun _ -> + let toml = Otoml.Parser.from_file "configuration/example_csv.toml" in + let toml = ImportConf.t_of_toml toml in + ignore toml ); + ] + +let tests = "configuration_toml" >::: test_suit -- cgit v1.2.3