Sha256: 2fe2063be47991fd4dac86adc74981545fd5c069ed6261fb0c41ac0821ba7204

Contents?: true

Size: 1.28 KB

Versions: 150

Compression:

Stored size: 1.28 KB

Contents

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

open Core
open OUnit2
open Luhn

let assert_valid expected input _test_ctxt = 
  assert_equal ~printer:Bool.to_string expected (valid input)

let tests = [
  "single digit strings can not be valid" >::
    assert_valid false "1";
  "A single zero is invalid" >::
    assert_valid false "0";
  "a simple valid SIN that remains valid if reversed" >::
    assert_valid true "059";
  "a simple valid SIN that becomes invalid if reversed" >::
    assert_valid true "59";
  "a valid Canadian SIN" >::
    assert_valid true "055 444 285";
  "invalid Canadian SIN" >::
    assert_valid false "055 444 286";
  "invalid credit card" >::
    assert_valid false "8273 1232 7352 0569";
  "valid strings with a non-digit included become invalid" >::
    assert_valid false "055a 444 285";
  "valid strings with punctuation included become invalid" >::
    assert_valid false "055-444-285";
  "valid strings with symbols included become invalid" >::
    assert_valid false "055\194\163 444$ 285";
  "single zero with space is invalid" >::
    assert_valid false " 0";
  "more than a single zero is valid" >::
    assert_valid true "0000 0";
  "input digit 9 is correctly converted to output digit 9" >::
    assert_valid true "091";
]

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

Version data entries

150 entries across 150 versions & 1 rubygems

Version Path
trackler-2.2.1.109 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.108 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.107 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.106 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.105 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.104 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.103 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.102 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.101 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.100 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.99 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.98 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.97 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.96 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.95 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.94 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.93 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.92 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.91 tracks/ocaml/exercises/luhn/test.ml
trackler-2.2.1.90 tracks/ocaml/exercises/luhn/test.ml