OSDN Git Service

Change CmdOpt module's return type
[happyabc/happyabc.git] / link / cmdOptTest.ml
1 open Base
2 open OUnit
3 open CmdOpt
4 open ExtString
5
6 let ok x f y =
7   assert_equal x @@ f @@ snd @@ parse @@ Array.of_list @@ String.nsplit y " "
8
9 let _ = begin "cmdOpt.ml" >::: [
10   "filename" >:: begin fun () ->
11     assert_equal ["foo"]        @@ fst @@ parse [| "foo" |];
12     assert_equal ["foo"; "bar"] @@ fst @@ parse [| "foo"; "bar" |]
13   end;
14   "size" >:: begin fun () ->
15     ok (100,200) (fun t -> t#size) "-W 100 -H 200";
16     ok (100,200) (fun t -> t#size) "--width=100 --height=200";
17   end;
18   "color" >:: begin fun () ->
19     ok (1,2,3) (fun t -> t#color) "--red=1 --green=2 --blue=3"
20   end;
21   "main class" >:: begin fun () ->
22     ok "foo" (fun t -> t#main_class) "-m foo";
23     ok "foo" (fun t -> t#main_class) "--main=foo"
24   end
25 ] end +> run_test_tt_main