mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
fix bug in CCFqueue
This commit is contained in:
parent
2395ebb2ad
commit
891725157e
2 changed files with 6 additions and 4 deletions
|
|
@ -172,11 +172,11 @@ let last q =
|
|||
let last_exn q = snd (take_back_exn q)
|
||||
|
||||
let init q =
|
||||
try snd (take_front_exn q)
|
||||
try fst (take_back_exn q)
|
||||
with Empty -> q
|
||||
|
||||
let tail q =
|
||||
try fst (take_back_exn q)
|
||||
try snd (take_front_exn q)
|
||||
with Empty -> q
|
||||
|
||||
let add_seq_front seq q =
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@ let test_empty () =
|
|||
let q = FQueue.empty in
|
||||
OUnit.assert_bool "is_empty" (FQueue.is_empty q)
|
||||
|
||||
let pp_ilist = CCPrint.(to_string (list int))
|
||||
|
||||
let test_push () =
|
||||
let q = List.fold_left FQueue.snoc FQueue.empty [1;2;3;4;5] in
|
||||
let q = FQueue.tail q in
|
||||
let q = List.fold_left FQueue.snoc q [6;7;8] in
|
||||
let l = Sequence.to_list (FQueue.to_seq q) in
|
||||
OUnit.assert_equal [2;3;4;5;6;7;8] l
|
||||
OUnit.assert_equal ~printer:pp_ilist [2;3;4;5;6;7;8] l
|
||||
|
||||
let test_pop () =
|
||||
let q = FQueue.of_list [1;2;3;4] in
|
||||
|
|
@ -30,7 +32,7 @@ let test_append () =
|
|||
let q2 = FQueue.of_seq (Sequence.of_list [5;6;7;8]) in
|
||||
let q = FQueue.append q1 q2 in
|
||||
let l = Sequence.to_list (FQueue.to_seq q) in
|
||||
OUnit.assert_equal [1;2;3;4;5;6;7;8] l
|
||||
OUnit.assert_equal ~printer:pp_ilist [1;2;3;4;5;6;7;8] l
|
||||
|
||||
let test_fold () =
|
||||
let q = FQueue.of_seq (Sequence.of_list [1;2;3;4]) in
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue