3 let o i
= i
|> Optint.of_int
5 let oi i
= i
|> Optint.of_unsigned_int32
7 let oo i
= i
|> Optint.of_int64
9 let b = Bytes.of_string
12 let cdb = "mini.cdb" |> Ds_cdb.open_cdb_in
in
13 assert (b "Ä" = ("a" |> b |> Ds_cdb.find_first
cdb |> Option.get
));
14 assert (b "B" = ("b" |> b |> Ds_cdb.find_first
cdb |> Option.get
));
15 assert (b "ß" = ("s" |> b |> Ds_cdb.find_first
cdb |> Option.get
));
16 Ds_cdb.close_cdb_in
cdb
19 let test_pipe_big () =
20 let fd0 = Unix.openfile "mini.cdb" [ Unix.O_RDONLY ] 0
22 Unix.openfile "dst.cdb"
23 [ Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC; Unix.O_EXCL ]
26 let ctx = Cdb.start fd1 in
28 let _ = pair |> Cdb.add fd1 ctx in
31 let _ = Cdb.dump fd0 fkt in
32 let _ = Cdb.finish fd1 in
39 assert (0x2b5c4l
= ("a" |> b |> Ds_cdb.hash
));
41 "http://www.traunsteiner-tagblatt.de/region+lokal/landkreis-traunstein/traunstein/pressemitteilungen-der-stadt-traunstein_artikel,-Traunstein-20-%E2%80%93-Neue-Medien-im-Mittelpunkt-_arid,198374.html"
43 assert (0xc7410a37l
= (k0 |> b |> Ds_cdb.hash
));
44 Assrt.equals_optint __LOC__
(oo 0xc7410a37L
) (oi 0xc7410a37l
);
45 Assrt.equals_optint __LOC__
(oo 0xc7410a37L
) (k0 |> b |> Ds_cdb.hash
|> Optint.of_unsigned_int32
)
49 (* Printf.printf "0x%x\n" ("a" |> b |> Cdb.hash); *)
50 Assrt.equals_optint __LOC__
(o 0x2b5c4) ("a" |> b |> Mapcdb.hash32_byt
);
52 "http://www.traunsteiner-tagblatt.de/region+lokal/landkreis-traunstein/traunstein/pressemitteilungen-der-stadt-traunstein_artikel,-Traunstein-20-%E2%80%93-Neue-Medien-im-Mittelpunkt-_arid,198374.html"
54 (* Printf.printf "%x\n" (k0 |> b |> Cdb.hash); *)
55 Assrt.equals_optint __LOC__
(oo 0xc7410a37L
) (k0 |> b |> Mapcdb.hash32_byt
)
59 "http://www.traunsteiner-tagblatt.de/region+lokal/landkreis-traunstein/traunstein/pressemitteilungen-der-stadt-traunstein_artikel,-Traunstein-20-%E2%80%93-Neue-Medien-im-Mittelpunkt-_arid,198374.html"
61 let cdb = "big.cdb" |> Ds_cdb.open_cdb_in
in
62 (* Printf.printf "%d\n" (k0 |> b |> Ds_cdb.find cdb |> Bytes.length); *)
63 assert (1000 = (k0 |> b |> Ds_cdb.find_first
cdb |> Option.get
|> Bytes.length
));
64 Ds_cdb.close_cdb_in
cdb
67 Unix.chdir
"../../../test/";