|
1 | 1 | (ns luhn-test |
2 | | - (:require [clojure.test :refer [deftest is testing]] |
| 2 | + (:require [clojure.test :refer [deftest testing is]] |
3 | 3 | luhn)) |
4 | 4 |
|
5 | | -(deftest single-digit-strings-are-invalid |
6 | | - (testing "Single digit strings can not be valid" |
| 5 | +(deftest valid?_test_1 |
| 6 | + (testing "single digit strings can not be valid" |
7 | 7 | (is (false? (luhn/valid? "1"))))) |
8 | 8 |
|
9 | | -(deftest single-zero-is-invalid |
10 | | - (testing "A single zero is invalid" |
| 9 | +(deftest valid?_test_2 |
| 10 | + (testing "a single zero is invalid" |
11 | 11 | (is (false? (luhn/valid? "0"))))) |
12 | 12 |
|
13 | | -(deftest simple-valid-SIN-that-remains-valid-if-reversed |
14 | | - (testing "A simple valid SIN that remains valid if reversed" |
| 13 | +(deftest valid?_test_3 |
| 14 | + (testing "a simple valid SIN that remains valid if reversed" |
15 | 15 | (is (true? (luhn/valid? "059"))))) |
16 | 16 |
|
17 | | -(deftest simple-valid-SIN-that-becomes-invalid-if-reversed |
18 | | - (testing "A simple valid SIN that becomes invalid if reversed" |
| 17 | +(deftest valid?_test_4 |
| 18 | + (testing "a simple valid SIN that becomes invalid if reversed" |
19 | 19 | (is (true? (luhn/valid? "59"))))) |
20 | 20 |
|
21 | | -(deftest valid-canadian-SIN |
22 | | - (testing "A valid Canadian SIN" |
| 21 | +(deftest valid?_test_5 |
| 22 | + (testing "a valid Canadian SIN" |
23 | 23 | (is (true? (luhn/valid? "055 444 285"))))) |
24 | 24 |
|
25 | | -(deftest invalid-canadian-SIN |
26 | | - (testing "Invalid Canadian SIN" |
| 25 | +(deftest valid?_test_6 |
| 26 | + (testing "invalid Canadian SIN" |
27 | 27 | (is (false? (luhn/valid? "055 444 286"))))) |
28 | 28 |
|
29 | | -(deftest invalid-credit-card |
30 | | - (testing "Invalid credit card" |
| 29 | +(deftest valid?_test_7 |
| 30 | + (testing "invalid credit card" |
31 | 31 | (is (false? (luhn/valid? "8273 1232 7352 0569"))))) |
32 | 32 |
|
33 | | -(deftest invalid-long-number-with-an-even-remainder |
34 | | - (testing "Invalid long number with an even remainder" |
| 33 | +(deftest valid?_test_8 |
| 34 | + (testing "invalid long number with an even remainder" |
35 | 35 | (is (false? (luhn/valid? "1 2345 6789 1234 5678 9012"))))) |
36 | 36 |
|
37 | | -(deftest invalid-long-number-with-a-remainder-divisible-by-5 |
38 | | - (testing "Invalid long number with a remainder divisible by 5" |
| 37 | +(deftest valid?_test_9 |
| 38 | + (testing "invalid long number with a remainder divisible by 5" |
39 | 39 | (is (false? (luhn/valid? "1 2345 6789 1234 5678 9013"))))) |
40 | 40 |
|
41 | | -(deftest valid-number-with-an-even-number-of-digits |
42 | | - (testing "Valid number with an even number of digits" |
| 41 | +(deftest valid?_test_10 |
| 42 | + (testing "valid number with an even number of digits" |
43 | 43 | (is (true? (luhn/valid? "095 245 88"))))) |
44 | 44 |
|
45 | | -(deftest valid-number-with-an-odd-number-of-spaces |
46 | | - (testing "Valid number with an odd number of spaces" |
| 45 | +(deftest valid?_test_11 |
| 46 | + (testing "valid number with an odd number of spaces" |
47 | 47 | (is (true? (luhn/valid? "234 567 891 234"))))) |
48 | 48 |
|
49 | | -(deftest valid-strings-with-a-non-digit-added-at-the-end-become-invalid |
50 | | - (testing "Valid strings with a non-digit added at the end become invalid" |
| 49 | +(deftest valid?_test_12 |
| 50 | + (testing "valid strings with a non-digit added at the end become invalid" |
51 | 51 | (is (false? (luhn/valid? "059a"))))) |
52 | 52 |
|
53 | | -(deftest valid-strings-with-punctuation-included-become-invalid |
54 | | - (testing "Valid strings with punctuation included become invalid" |
| 53 | +(deftest valid?_test_13 |
| 54 | + (testing "valid strings with punctuation included become invalid" |
55 | 55 | (is (false? (luhn/valid? "055-444-285"))))) |
56 | 56 |
|
57 | | -(deftest valid-strings-with-symbols-included-become-invalid |
58 | | - (testing "Valid strings with symbols included become invalid" |
| 57 | +(deftest valid?_test_14 |
| 58 | + (testing "valid strings with symbols included become invalid" |
59 | 59 | (is (false? (luhn/valid? "055# 444$ 285"))))) |
60 | 60 |
|
61 | | -(deftest single-zero-with-space-is-invalid |
62 | | - (testing "Single zero with space is invalid" |
| 61 | +(deftest valid?_test_15 |
| 62 | + (testing "single zero with space is invalid" |
63 | 63 | (is (false? (luhn/valid? " 0"))))) |
64 | 64 |
|
65 | | -(deftest more-than-a-single-zero-is-valid |
66 | | - (testing "More than a single zero is valid" |
| 65 | +(deftest valid?_test_16 |
| 66 | + (testing "more than a single zero is valid" |
67 | 67 | (is (true? (luhn/valid? "0000 0"))))) |
68 | 68 |
|
69 | | -(deftest input-digit-9-is-correctly-converted-to-output-digit-9 |
70 | | - (testing "Input digit 9 is correctly converted to output digit 9" |
| 69 | +(deftest valid?_test_17 |
| 70 | + (testing "input digit 9 is correctly converted to output digit 9" |
71 | 71 | (is (true? (luhn/valid? "091"))))) |
72 | 72 |
|
73 | | -(deftest very-long-input-is-valid |
74 | | - (testing "Very long input is valid" |
| 73 | +(deftest valid?_test_18 |
| 74 | + (testing "very long input is valid" |
75 | 75 | (is (true? (luhn/valid? "9999999999 9999999999 9999999999 9999999999"))))) |
76 | 76 |
|
77 | | -(deftest valid-luhn-with-an-odd-number-of-digits-and-non-zero-first-digit |
78 | | - (testing "Valid luhn with an odd number of digits and non zero first digit" |
| 77 | +(deftest valid?_test_19 |
| 78 | + (testing "valid luhn with an odd number of digits and non zero first digit" |
79 | 79 | (is (true? (luhn/valid? "109"))))) |
80 | 80 |
|
81 | | -(deftest using-ascii-value-for-non-doubled-non-digit-is-not-allowed |
82 | | - (testing "Using ascii value for non-doubled non-digit isn't allowed" |
| 81 | +(deftest valid?_test_20 |
| 82 | + (testing "using ascii value for non-doubled non-digit isn't allowed" |
83 | 83 | (is (false? (luhn/valid? "055b 444 285"))))) |
84 | 84 |
|
85 | | -(deftest using-ascii-value-for-doubled-non-digit-is-not-allowed |
86 | | - (testing "Using ascii value for doubled non-digit isn't allowed" |
| 85 | +(deftest valid?_test_21 |
| 86 | + (testing "using ascii value for doubled non-digit isn't allowed" |
87 | 87 | (is (false? (luhn/valid? ":9"))))) |
88 | 88 |
|
89 | | -(deftest non-numeric-non-space-char-in-middle-with-sum-that-is-divisible-by-10-is-not-allowed |
90 | | - (testing "Non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed" |
| 89 | +(deftest valid?_test_22 |
| 90 | + (testing "non-numeric, non-space char in the middle with a sum that's divisible by 10 isn't allowed" |
91 | 91 | (is (false? (luhn/valid? "59%59"))))) |
0 commit comments