Sha256: 99457d5ab10a6ffcd9ede6cd276a9b3a4399fc4511e770ee43edbb3e9b0ff783

Contents?: true

Size: 1.52 KB

Versions: 151

Compression:

Stored size: 1.52 KB

Contents

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

open Core
open OUnit2
open Triangle

let ae exp got _test_ctxt = assert_equal exp got ~printer:Bool.to_string

let equilateral_tests = [
   "true if all sides are equal" >::
     ae true (is_equilateral 2 2 2);
   "false if any side is unequal" >::
     ae false (is_equilateral 2 3 2);
   "false if no sides are equal" >::
     ae false (is_equilateral 5 4 6);
   "All zero sides are illegal, so the triangle is not equilateral" >::
     ae false (is_equilateral 0 0 0);
]

let isosceles_tests = [
   "true if last two sides are equal" >::
     ae true (is_isosceles 3 4 4);
   "true if first two sides are equal" >::
     ae true (is_isosceles 4 4 3);
   "true if first and last sides are equal" >::
     ae true (is_isosceles 4 3 4);
   "equilateral triangles are also isosceles" >::
     ae true (is_isosceles 4 4 4);
   "false if no sides are equal" >::
     ae false (is_isosceles 2 3 4);
   "Sides that violate triangle inequality are not isosceles, even if two are equal" >::
     ae false (is_isosceles 1 1 3);
]

let scalene_tests = [
   "true if no sides are equal" >::
     ae true (is_scalene 5 4 6);
   "false if all sides are equal" >::
     ae false (is_scalene 4 4 4);
   "false if two sides are equal" >::
     ae false (is_scalene 4 4 3);
   "Sides that violate triangle inequality are not scalene, even if they are all different" >::
     ae false (is_scalene 7 3 2);
]

let () =
  run_test_tt_main (
    "triangle tests" >:::
      List.concat [equilateral_tests; isosceles_tests; scalene_tests]
  )

Version data entries

151 entries across 151 versions & 1 rubygems

Version Path
trackler-2.1.0.53 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.52 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.51 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.50 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.49 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.48 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.47 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.46 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.45 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.44 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.43 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.42 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.41 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.40 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.39 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.38 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.37 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.36 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.34 tracks/ocaml/exercises/triangle/test.ml
trackler-2.1.0.33 tracks/ocaml/exercises/triangle/test.ml