test: add stronger test to compare with uutf in ccutf8string

This commit is contained in:
Simon Cruanes 2020-12-07 23:42:31 -05:00
parent 52abbcd978
commit fcd1247ec8

View file

@ -334,6 +334,11 @@ let of_string s = if is_valid s then Some s else None
| `Malformed _ -> f (Uchar.of_int 0xfffd)
| `Uchar c -> f c)
() s
let uutf_of_l l =
let buf = Buffer.create 32 in
List.iter (Uutf.Buffer.add_utf_8 buf) l;
Buffer.contents buf
*)
(*$R
@ -362,7 +367,7 @@ let of_string s = if is_valid s then Some s else None
)
*)
(*$QR & ~long_factor:10
(*$QR & ~long_factor:10 ~count:20_000
Q.(small_list arb_uchar) (fun l ->
let s = of_list l in
l = to_list s)
@ -421,6 +426,17 @@ let of_string s = if is_valid s then Some s else None
)
*)
(*$QR & ~long_factor:40 ~count:50_000
Q.(small_list arb_uchar) (fun l ->
let pp s = Q.Print.(list pp_uchar) s in
let uutf = uutf_of_l l in
let s = (of_list l:>string) in
if uutf = s then true
else Q.Test.fail_reportf "l: '%s', uutf: '%s', containers: '%s'"
(pp l) uutf s
)
*)
(*$QR & ~long_factor:40 ~count:50_000
Q.small_string (fun s ->
Q.assume (is_valid s && uutf_is_valid s);