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.2.1.50 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.49 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.48 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.47 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.46 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.45 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.44 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.43 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.42 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.41 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.40 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.39 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.38 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.37 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.36 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.35 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.34 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.33 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.32 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.31 tracks/ocaml/exercises/triangle/test.ml