Sha256: 03e16eb99917b5845968c924196774569af021cac834439a35fc2bd22f40be9f

Contents?: true

Size: 1.03 KB

Versions: 150

Compression:

Stored size: 1.03 KB

Contents

(* Test/exercise version: "1.0.0" *)

open Core
open OUnit2
open Prime_factors

(* Assert Equals *)
let ae exp got _test_ctxt =
  let printer = List.to_string ~f:Int64.to_string in
  assert_equal exp got ~printer

let to_int64s = List.map ~f:Int64.of_int

(* 64 bits integers are needed for the last number.
 *
 * If you happen to use a 64 bits machine normal ints would do as well, but this
 * works for everybody.
 *)
let tests = [
   "no factors" >::
      ae (to_int64s []) (factors_of 1L);
   "prime number" >::
      ae (to_int64s [2]) (factors_of 2L);
   "square of a prime" >::
      ae (to_int64s [3; 3]) (factors_of 9L);
   "cube of a prime" >::
      ae (to_int64s [2; 2; 2]) (factors_of 8L);
   "product of primes and non-primes" >::
      ae (to_int64s [2; 2; 3]) (factors_of 12L);
   "product of primes" >::
      ae (to_int64s [5; 17; 23; 461]) (factors_of 901255L);
   "factors include a large prime" >::
      ae (to_int64s [11; 9539; 894119]) (factors_of 93819012551L);
]

let () =
  run_test_tt_main ("prime-factors tests" >::: tests)

Version data entries

150 entries across 150 versions & 1 rubygems

Version Path
trackler-2.2.1.49 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.48 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.47 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.46 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.45 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.44 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.43 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.42 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.41 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.40 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.39 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.38 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.37 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.36 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.35 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.34 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.33 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.32 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.31 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.30 tracks/ocaml/exercises/prime-factors/test.ml