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.110 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.109 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.108 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.107 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.106 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.105 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.104 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.103 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.102 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.101 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.100 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.99 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.98 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.97 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.96 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.95 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.94 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.93 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.92 tracks/ocaml/exercises/triangle/test.ml
trackler-2.2.1.91 tracks/ocaml/exercises/triangle/test.ml