This commit is contained in:
parent
2f5489363e
commit
3cafed77aa
3 changed files with 24 additions and 5 deletions
23
test/b32.ml
23
test/b32.ml
|
|
@ -1,6 +1,6 @@
|
|||
let () =
|
||||
let id s = s |> B32.encode |> B32.decode |> Result.get_ok in
|
||||
let f s =
|
||||
let round_trip s =
|
||||
let s' = id s in
|
||||
match s' = s with
|
||||
| false ->
|
||||
|
|
@ -8,8 +8,25 @@ let () =
|
|||
| true -> ()
|
||||
in
|
||||
let s = String.init 0xff Char.chr in
|
||||
round_trip s;
|
||||
let s_l = List.init 0x0f (fun i -> String.init i Char.chr) in
|
||||
f s;
|
||||
List.iter f s_l;
|
||||
List.iter round_trip s_l; ()
|
||||
|
||||
let () =
|
||||
let input = "91JPRV3F5GG4EKJNDSJQ8" in
|
||||
Fmt.epr "input length: %d@." (String.length input);
|
||||
let output =
|
||||
input
|
||||
|> Hash.H64.of_b32
|
||||
|> Result.get_ok
|
||||
|> Hash.H64.to_octets
|
||||
|> B32.encode
|
||||
in
|
||||
let expected =
|
||||
"D0R24RZ1TPASVQ2NY56CT8AJDYZE9ZGDB0GVZ05E9D4YGZQW2RC5YFPQ0Q86EPW836DY7VYQTNFFJT3ZR2K508F4JVS5JNJKYN2MMFR"
|
||||
in
|
||||
Fmt.pr "input : %s@." input;
|
||||
Fmt.pr "output : %s@." output;
|
||||
Fmt.pr "expected: %s@." expected;
|
||||
|
||||
()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue