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.69 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.68 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.67 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.66 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.65 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.64 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.63 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.62 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.61 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.60 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.59 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.58 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.57 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.56 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.55 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.54 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.53 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.52 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.51 tracks/ocaml/exercises/prime-factors/test.ml
trackler-2.2.1.50 tracks/ocaml/exercises/prime-factors/test.ml