File: backoff_test.ml

package info (click to toggle)
ocaml-backoff 0.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: ml: 218; sh: 59; makefile: 3
file content (18 lines) | stat: -rw-r--r-- 677 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
let test_basics () =
  let b = Backoff.create ~lower_wait_log:5 ~upper_wait_log:6 () in
  Alcotest.(check' int)
    ~msg:"initial is lower" ~expected:5 ~actual:(Backoff.get_wait_log b);
  let b = Backoff.once b in
  Alcotest.(check' int)
    ~msg:"incremented once" ~expected:6 ~actual:(Backoff.get_wait_log b);
  let b = Backoff.once b in
  Alcotest.(check' int)
    ~msg:"not incremented above upper" ~expected:6
    ~actual:(Backoff.get_wait_log b);
  let b = Backoff.reset b in
  Alcotest.(check' int)
    ~msg:"reset to lower" ~expected:5 ~actual:(Backoff.get_wait_log b)

let () =
  Alcotest.run "Backoff"
    [ ("basics", [ Alcotest.test_case "" `Quick test_basics ]) ]