Sha256: 759d26e8cc2e379356ddb46d081298f6a81389671e0d896084c9579790cbd9d1

Contents?: true

Size: 1.17 KB

Versions: 289

Compression:

Stored size: 1.17 KB

Contents

(ns luhn-test
  (:require [clojure.test :refer [deftest is testing]]
            luhn))

(deftest validity-tests
  (testing "single digit strings can not be valid"
    (is (false? (luhn/valid? "1"))))
  (testing "A single zero is invalid"
    (is (false? (luhn/valid? "0"))))
  (testing "simple valid sin"
    (is (true? (luhn/valid? " 5 9 "))))
  (testing "valid Canadian SIN"
    (is (true? (luhn/valid? "046 454 286"))))
  (testing "invalid Canadian SIN"
    (is (false? (luhn/valid? "046 454 287"))))
  (testing "invalid credit card"
    (is (false? (luhn/valid? "8273 1232 7352 0569"))))
  (testing "valid strings with a non-digit added become invalid"
    (is (false? (luhn/valid? "046a 454 286"))))
  (testing "punctuation is not allowed"
    (is (false? (luhn/valid? "055-444-285"))))
  (testing "symbols are not allowed"
    (is (false? (luhn/valid? "055£ 444$ 285"))))
  (testing "single zero with space is invalid"
    (is (false? (luhn/valid? " 0"))))
  (testing "lots of zeros are valid"
    (is (true? (luhn/valid? " 00000"))))
  (testing "another valid sin"
    (is (true? (luhn/valid? "055 444 285"))))
  (testing "nine doubled is nine"
    (is (true? (luhn/valid? "091"))))
)

Version data entries

289 entries across 289 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.179 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.178 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.177 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.176 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.175 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.174 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.173 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.172 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.171 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.170 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.169 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.167 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.166 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.165 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.164 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.163 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.162 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.161 tracks/clojure/exercises/luhn/test/luhn_test.clj
trackler-2.2.1.160 tracks/clojure/exercises/luhn/test/luhn_test.clj