Skip to content

Commit

Permalink
Add test for is_empty for Imperative priority queue
Browse files Browse the repository at this point in the history
Signed-off-by: Frediano Ziglio <[email protected]>
  • Loading branch information
freddy77 committed Dec 3, 2024
1 parent dab8684 commit 4f5bb1a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/ipq_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,20 @@ let test_leak () =
Alcotest.(check bool) "allocated" false (Atomic.get allocated) ;
Ipq.add q {Ipq.ev= default; Ipq.time= Mtime_clock.now ()}

(* test Ipq.is_empty call *)
let test_empty () =
let q = Ipq.create 10 0 in
Alcotest.(check bool) "same value" true (Ipq.is_empty q) ;
Ipq.add q {Ipq.ev= 123; Ipq.time= Mtime_clock.now ()} ;
Alcotest.(check bool) "same value" false (Ipq.is_empty q) ;
Ipq.remove q 0 ;
Alcotest.(check bool) "same value" true (Ipq.is_empty q)

let tests =
[
("test_out_of_index", `Quick, test_out_of_index)
; ("test_leak", `Quick, test_leak)
; ("test_empty", `Quick, test_empty)
]

let () = Alcotest.run "Ipq" [("generic", tests)]

0 comments on commit 4f5bb1a

Please sign in to comment.