adding alcotest testing suite

This commit is contained in:
simon petit 2024-12-02 11:08:20 +00:00
parent 35b5c1b41b
commit cc8540e4f4
3 changed files with 18 additions and 4 deletions

View File

@ -40,9 +40,10 @@ and search_condition =
| Search of string
let rec pp_query ast =
let rec pp_query fmt ast =
match ast with
| Query(s) -> pp_select s
| Query(s) -> Format.fprintf fmt "%s" (pp_select s)
and pp_select s =
match s with
@ -79,3 +80,5 @@ and pp_join_type j =
| Cross -> "cross"
| Union -> "union"
| Natural -> "natural"

View File

@ -6,6 +6,10 @@
(name logical_plan_test)
(libraries ast logical_plan))
(test
(name test_ast)
(libraries parser lexer ast alcotest))
(test
(name test_parquet)

View File

@ -7,9 +7,16 @@ let parse query =
let equal_ast ast1 ast2 =
ast1 = ast2
let
let query_testable =
Alcotest.testable Ast.pp_query equal_ast
let test_simple_select() =
let q1 = parse "SELECT a FROM t" in
let ast1 = Query(Select([Column("a")], [Table("t")])) in
Alcotest.(check
Alcotest.(check query_testable) "Ok" q1 ast1
let simple_select_set = [ ("Equals", `Quick, test_simple_select) ]
let () =
Alcotest.run "Ast tests"
[ ("Simple Selects", simple_select_set) ]