Sha256: a82a524c7e46a2878ec3c9c1eaad12a4a8d372637fd9da5ed6e8fb5db033e587

Contents?: true

Size: 1.55 KB

Versions: 60

Compression:

Stored size: 1.55 KB

Contents

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

open Core
open OUnit2
open Change

let printer = Option.value_map ~default:"None" ~f:(List.to_string ~f:Int.to_string)
let ae exp got _test_ctxt = assert_equal ~printer exp got

let tests = [
   "single coin change" >::
      ae (Some [25]) 
         (make_change ~target:25 ~coins:[1; 5; 10; 25; 100]);
   "multiple coin change" >::
      ae (Some [5; 10]) 
         (make_change ~target:15 ~coins:[1; 5; 10; 25; 100]);
   "change with Lilliputian Coins" >::
      ae (Some [4; 4; 15]) 
         (make_change ~target:23 ~coins:[1; 4; 15; 20; 50]);
   "change with Lower Elbonia Coins" >::
      ae (Some [21; 21; 21]) 
         (make_change ~target:63 ~coins:[1; 5; 10; 21; 25]);
   "large target values" >::
      ae (Some [2; 2; 5; 20; 20; 50; 100; 100; 100; 100; 100; 100; 100; 100; 100]) 
         (make_change ~target:999 ~coins:[1; 2; 5; 10; 20; 50; 100]);
   "possible change without unit coins available" >::
      ae (Some [2; 2; 2; 5; 10]) 
         (make_change ~target:21 ~coins:[2; 5; 10; 20; 50]);
   "no coins make 0 change" >::
      ae (Some []) 
         (make_change ~target:0 ~coins:[1; 5; 10; 21; 25]);
   "error testing for change smaller than the smallest of coins" >::
      ae None 
         (make_change ~target:3 ~coins:[5; 10]);
   "error if no combination can add up to target" >::
      ae None 
         (make_change ~target:94 ~coins:[5; 10]);
   "cannot find negative change values" >::
      ae None 
         (make_change ~target:(-5) ~coins:[1; 2; 5]);
]

let () =
  run_test_tt_main ("change tests" >::: tests)

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
trackler-2.2.0.6 tracks/ocaml/exercises/change/test.ml
trackler-2.2.0.5 tracks/ocaml/exercises/change/test.ml
trackler-2.2.0.4 tracks/ocaml/exercises/change/test.ml
trackler-2.2.0.3 tracks/ocaml/exercises/change/test.ml
trackler-2.2.0.2 tracks/ocaml/exercises/change/test.ml
trackler-2.2.0.1 tracks/ocaml/exercises/change/test.ml
trackler-2.2.0.0 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.55 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.54 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.53 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.52 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.51 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.50 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.49 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.48 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.47 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.46 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.45 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.44 tracks/ocaml/exercises/change/test.ml
trackler-2.1.0.43 tracks/ocaml/exercises/change/test.ml