specify precedence for some operators
[sqlgg.git] / test.ml
blobc4999e8bfa2989a87f575e0638c1e2e311f6ba12
2 open OUnit
3 open RA
4 open Sql.Type
5 open Stmt
7 (*
8 CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,descr TEXT);
9 -- [sql2cpp] name=select_all
10 SELECT * FROM test;
11 SELECT name,descr FROM test;
14 let tt stmt scheme params =
15 let print_scheme = RA.Scheme.to_string in
16 let print_params = Stmt.params_to_string in
17 let (s1,p1,_) =
18 try
19 Parser.parse_stmt stmt
20 with
21 | _ -> assert_failure "parsing failed"
23 assert_equal ~printer:print_scheme scheme s1;
24 assert_equal ~printer:print_params params p1
26 let test () =
27 tt "CREATE TABLE q (id INT, str TEXT, name TEXT)"
29 [];
30 tt "SELECT str FROM q WHERE id=?"
31 [attr "str" Text]
32 [Next,None];
33 tt "SELECT x,y+? AS z FROM (SELECT id AS y,CONCAT(str,name) AS x FROM q WHERE id=@id*2) ORDER BY x,x+y LIMIT @lim"
34 [attr "x" Text; attr "z" Text]
35 [Next,None; Named "id", None; Named "lim",Some Int; ]
37 let run () =
38 let tests =
40 "test" >:: test ;
43 let test_suite = "main" >::: tests in
44 ignore (run_test_tt test_suite)