~williewillus/persistent

c3847c95c848f8a9948789409dded757493cc143 — Vincent Lee 1 year, 9 months ago fa6bb1c
Add test
3 files changed, 31 insertions(+), 1 deletions(-)

M test/dune
D test/persistent.ml
A test/vectorTest.ml
M test/dune => test/dune +2 -1
@@ 1,2 1,3 @@
(test
 (name persistent))
 (name vectorTest)
 (libraries persistent))

D test/persistent.ml => test/persistent.ml +0 -0
A test/vectorTest.ml => test/vectorTest.ml +29 -0
@@ 0,0 1,29 @@
module Vector = Persistent.Vector

(* Just spams a bunch of numbers in and asserts we get the same stuff back out
   Should cover pretty much all of the insertion logic.
 *)
let test_insert_sanity () =
  let num = 1 lsl 20 in
  let v = Seq.init num Fun.id
          |> Seq.fold_left
               (fun acc i -> Vector.append acc i)
               (Vector.empty ())
  in
  let expected = List.of_seq (Seq.init num Fun.id) in
  let actual = List.of_seq (Vector.to_seq v) in
  assert (List.equal Int.equal actual expected)

let all_tests = [
    ("Insert Sanity", test_insert_sanity)
  ]

let main () =
  List.iter
    (fun (name, test_function) ->
      Printf.eprintf "Running test: %s..." name;
      test_function ();
      Printf.eprintf "Ok\n")
    all_tests

let () = main ()