9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-18 11:23:38 +01:00
qp2/ocaml/tests/test_progress_bar.ml
2019-01-25 11:39:31 +01:00

39 lines
729 B
OCaml

open Core
let test1 () =
let bar =
Progress_bar.init ~title:"Title" ~start_value:2. ~end_value:23. ~bar_length:30
in
let rec loop bar = function
| i when i = 24 -> ()
| i ->
let x =
Float.of_int i
in
let bar =
Progress_bar.update ~cur_value:x bar
|> Progress_bar.display
in
Unix.sleep 1 ;
loop bar (i+1)
in
loop bar 2
let test2 () =
let bar =
Progress_bar.init ~title:"Title" ~start_value:2. ~end_value:23. ~bar_length:30
in
let rec loop bar = function
| i when i = 24 -> ()
| i ->
let bar =
Progress_bar.increment bar
|> Progress_bar.display
in
Unix.sleep 1 ;
loop bar (i+1)
in
loop bar 2
let () = test2 ()