Skip to content

Commit 8f79eee

Browse files
committed
add 3 test cases
1 parent e6d1d3e commit 8f79eee

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

jscomp/ounit_tests/ounit_bsb_pkg_tests.ml

+43-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,24 @@ let s_test1 s a =
3131
| Global x ->
3232
a =~ x
3333
| _ -> OUnit.assert_failure __LOC__
34-
34+
35+
let group0 = Map_string.of_list [
36+
"Liba",
37+
{Bsb_db.info = Ml_mli; dir= "a";is_re=false;case = false;
38+
name_sans_extension = "liba"}
39+
]
40+
let group1 = Map_string.of_list [
41+
"Ciba",
42+
{Bsb_db.info = Ml_mli; dir= "b";is_re=false;case = false;
43+
name_sans_extension = "liba"}
44+
]
45+
46+
let parse_db db : Bsb_db_decode.t =
47+
let buf = Ext_buffer.create 10_000 in
48+
Bsb_db_encode.encode db buf;
49+
let s = Ext_buffer.contents buf in
50+
Bsb_db_decode.decode s
51+
3552
let suites =
3653
__FILE__ >::: [
3754
__LOC__ >:: begin fun _ ->
@@ -60,6 +77,31 @@ let suites =
6077
s_test1 "xx/yy/zz" "xx/yy/zz"
6178
end;
6279

80+
__LOC__ >:: begin fun _ ->
81+
match parse_db {lib= group0; dev = group1}with
82+
| {lib = Group {modules = [|"Liba"|]};
83+
dev = Group {modules = [|"Ciba"|]}}
84+
-> OUnit.assert_bool __LOC__ true
85+
| _ ->
86+
OUnit.assert_failure __LOC__
87+
end ;
88+
__LOC__ >:: begin fun _ ->
89+
match parse_db {lib = group0;dev = Map_string.empty } with
90+
| {lib = Group {modules = [|"Liba"|]};
91+
dev = Dummy}
92+
-> OUnit.assert_bool __LOC__ true
93+
| _ ->
94+
OUnit.assert_failure __LOC__
95+
end ;
96+
__LOC__ >:: begin fun _ ->
97+
match parse_db {lib = Map_string.empty ; dev = group1} with
98+
| {lib = Dummy;
99+
dev = Group {modules = [|"Ciba"|]}
100+
}
101+
-> OUnit.assert_bool __LOC__ true
102+
| _ ->
103+
OUnit.assert_failure __LOC__
104+
end
63105
(* __LOC__ >:: begin fun _ ->
64106
OUnit.assert_equal parse_data_one data_one
65107
end ;

0 commit comments

Comments
 (0)