|
4 | 4 |
|
5 | 5 | ;;; Code:
|
6 | 6 |
|
| 7 | + |
7 | 8 | (load-file "allergies.el")
|
8 | 9 | (declare-function allergen-list "allergies.el" (score))
|
9 | 10 | (declare-function allergic-to-p "allergies.el" (score allergen))
|
10 | 11 |
|
11 |
| -(ert-deftest no-allergies-at-all () |
12 |
| - (should (equal '() (allergen-list 0)))) |
13 | 12 |
|
14 |
| -(ert-deftest allergic-to-just-eggs () |
15 |
| - (should (equal '("eggs") (allergen-list 1)))) |
| 13 | +(ert-deftest eggs-not-allergic-to-anything () |
| 14 | + (should-not (allergic-to-p 0 "eggs"))) |
| 15 | + |
| 16 | + |
| 17 | +(ert-deftest eggs-allergic-only-to-eggs () |
| 18 | + (should (allergic-to-p 1 "eggs"))) |
| 19 | + |
| 20 | + |
| 21 | +(ert-deftest eggs-allergic-to-eggs-and-something-else () |
| 22 | + (should (allergic-to-p 3 "eggs"))) |
| 23 | + |
| 24 | + |
| 25 | +(ert-deftest eggs-allergic-to-something-but-not-eggs () |
| 26 | + (should-not (allergic-to-p 2 "eggs"))) |
| 27 | + |
| 28 | + |
| 29 | +(ert-deftest eggs-allergic-to-everything () |
| 30 | + (should (allergic-to-p 255 "eggs"))) |
| 31 | + |
| 32 | + |
| 33 | +(ert-deftest peanuts-not-allergic-to-anything () |
| 34 | + (should-not (allergic-to-p 0 "peanuts"))) |
| 35 | + |
| 36 | + |
| 37 | +(ert-deftest peanuts-allergic-only-to-peanuts () |
| 38 | + (should (allergic-to-p 2 "peanuts"))) |
| 39 | + |
| 40 | + |
| 41 | +(ert-deftest peanuts-allergic-to-peanuts-and-something-else () |
| 42 | + (should (allergic-to-p 7 "peanuts"))) |
| 43 | + |
| 44 | + |
| 45 | +(ert-deftest peanuts-allergic-to-something-but-not-peanuts () |
| 46 | + (should-not (allergic-to-p 5 "peanuts"))) |
| 47 | + |
| 48 | + |
| 49 | +(ert-deftest peanuts-allergic-to-everything () |
| 50 | + (should (allergic-to-p 255 "peanuts"))) |
| 51 | + |
| 52 | + |
| 53 | +(ert-deftest shellfish-not-allergic-to-anything () |
| 54 | + (should-not (allergic-to-p 0 "shellfish"))) |
| 55 | + |
16 | 56 |
|
17 |
| -(ert-deftest allergic-to-just-peanuts () |
18 |
| - (should (equal '("peanuts") (allergen-list 2)))) |
| 57 | +(ert-deftest shellfish-allergic-only-to-shellfish () |
| 58 | + (should (allergic-to-p 4 "shellfish"))) |
19 | 59 |
|
20 |
| -(ert-deftest allergic-to-just-strawberries () |
21 |
| - (should (equal '("strawberries") (allergen-list 8)))) |
22 | 60 |
|
23 |
| -(ert-deftest allergic-to-eggs-and-peanuts () |
24 |
| - (should (equal '("eggs" "peanuts") (allergen-list 3)))) |
| 61 | +(ert-deftest shellfish-allergic-to-shellfish-and-something-else () |
| 62 | + (should (allergic-to-p 14 "shellfish"))) |
25 | 63 |
|
26 |
| -(ert-deftest allergic-to-more-than-eggs-but-not-peanuts () |
27 |
| - (should (equal '("eggs" "shellfish") (allergen-list 5)))) |
28 | 64 |
|
29 |
| -(ert-deftest allergic-to-lots-of-stuff () |
30 |
| - (should (equal '("strawberries" "tomatoes" "chocolate" "pollen" "cats") |
31 |
| - (allergen-list 248)))) |
| 65 | +(ert-deftest shellfish-allergic-to-something-but-not-shellfish () |
| 66 | + (should-not (allergic-to-p 10 "shellfish"))) |
32 | 67 |
|
33 |
| -(ert-deftest allergic-to-everything () |
34 |
| - (should (equal '("eggs" "peanuts" "shellfish" "strawberries" "tomatoes" |
35 |
| - "chocolate" "pollen" "cats") |
36 |
| - (allergen-list 255)))) |
37 | 68 |
|
38 |
| -(ert-deftest no-allergies-means-not-allergic () |
39 |
| - (should-not (allergic-to-p 0 "peanuts")) |
40 |
| - (should-not (allergic-to-p 0 "cats")) |
| 69 | +(ert-deftest shellfish-allergic-to-everything () |
| 70 | + (should (allergic-to-p 255 "shellfish"))) |
| 71 | + |
| 72 | + |
| 73 | +(ert-deftest strawberries-not-allergic-to-anything () |
41 | 74 | (should-not (allergic-to-p 0 "strawberries")))
|
42 | 75 |
|
43 |
| -(ert-deftest is-allergic-to-eggs () |
44 |
| - (should (allergic-to-p 1 "eggs"))) |
45 | 76 |
|
46 |
| -(ert-deftest allergic-to-eggs-and-other-stuff () |
47 |
| - (should (allergic-to-p 5 "eggs"))) |
| 77 | +(ert-deftest strawberries-allergic-only-to-strawberries () |
| 78 | + (should (allergic-to-p 8 "strawberries"))) |
| 79 | + |
| 80 | + |
| 81 | +(ert-deftest strawberries-allergic-to-strawberries-and-something-else () |
| 82 | + (should (allergic-to-p 28 "strawberries"))) |
| 83 | + |
| 84 | + |
| 85 | +(ert-deftest strawberries-allergic-to-something-but-not-strawberries () |
| 86 | + (should-not (allergic-to-p 20 "strawberries"))) |
| 87 | + |
| 88 | + |
| 89 | +(ert-deftest strawberries-allergic-to-everything () |
| 90 | + (should (allergic-to-p 255 "strawberries"))) |
| 91 | + |
| 92 | + |
| 93 | +(ert-deftest tomatoes-not-allergic-to-anything () |
| 94 | + (should-not (allergic-to-p 0 "tomatoes"))) |
| 95 | + |
| 96 | + |
| 97 | +(ert-deftest tomatoes-allergic-only-to-tomatoes () |
| 98 | + (should (allergic-to-p 16 "tomatoes"))) |
| 99 | + |
| 100 | + |
| 101 | +(ert-deftest tomatoes-allergic-to-tomatoes-and-something-else () |
| 102 | + (should (allergic-to-p 56 "tomatoes"))) |
| 103 | + |
| 104 | + |
| 105 | +(ert-deftest tomatoes-allergic-to-something-but-not-tomatoes () |
| 106 | + (should-not (allergic-to-p 40 "tomatoes"))) |
| 107 | + |
| 108 | + |
| 109 | +(ert-deftest tomatoes-allergic-to-everything () |
| 110 | + (should (allergic-to-p 255 "tomatoes"))) |
| 111 | + |
| 112 | + |
| 113 | +(ert-deftest chocolate-not-allergic-to-anything () |
| 114 | + (should-not (allergic-to-p 0 "chocolate"))) |
| 115 | + |
| 116 | + |
| 117 | +(ert-deftest chocolate-allergic-only-to-chocolate () |
| 118 | + (should (allergic-to-p 32 "chocolate"))) |
| 119 | + |
| 120 | + |
| 121 | +(ert-deftest chocolate-allergic-to-chocolate-and-something-else () |
| 122 | + (should (allergic-to-p 112 "chocolate"))) |
| 123 | + |
| 124 | + |
| 125 | +(ert-deftest chocolate-allergic-to-something-but-not-chocolate () |
| 126 | + (should-not (allergic-to-p 80 "chocolate"))) |
| 127 | + |
| 128 | + |
| 129 | +(ert-deftest chocolate-allergic-to-everything () |
| 130 | + (should (allergic-to-p 255 "chocolate"))) |
| 131 | + |
| 132 | + |
| 133 | +(ert-deftest pollen-not-allergic-to-anything () |
| 134 | + (should-not (allergic-to-p 0 "pollen"))) |
| 135 | + |
| 136 | + |
| 137 | +(ert-deftest pollen-allergic-only-to-pollen () |
| 138 | + (should (allergic-to-p 64 "pollen"))) |
| 139 | + |
| 140 | + |
| 141 | +(ert-deftest pollen-allergic-to-pollen-and-something-else () |
| 142 | + (should (allergic-to-p 224 "pollen"))) |
| 143 | + |
| 144 | + |
| 145 | +(ert-deftest pollen-allergic-to-something-but-not-pollen () |
| 146 | + (should-not (allergic-to-p 160 "pollen"))) |
| 147 | + |
| 148 | + |
| 149 | +(ert-deftest pollen-allergic-to-everything () |
| 150 | + (should (allergic-to-p 255 "pollen"))) |
| 151 | + |
| 152 | + |
| 153 | +(ert-deftest cats-not-allergic-to-anything () |
| 154 | + (should-not (allergic-to-p 0 "cats"))) |
| 155 | + |
| 156 | + |
| 157 | +(ert-deftest cats-allergic-only-to-cats () |
| 158 | + (should (allergic-to-p 128 "cats"))) |
| 159 | + |
| 160 | + |
| 161 | +(ert-deftest cats-allergic-to-cats-and-something-else () |
| 162 | + (should (allergic-to-p 192 "cats"))) |
| 163 | + |
| 164 | + |
| 165 | +(ert-deftest cats-allergic-to-something-but-not-cats () |
| 166 | + (should-not (allergic-to-p 64 "cats"))) |
| 167 | + |
| 168 | + |
| 169 | +(ert-deftest cats-allergic-to-everything () |
| 170 | + (should (allergic-to-p 255 "cats"))) |
| 171 | + |
| 172 | + |
| 173 | +(ert-deftest list-when-no-allergies-at-all () |
| 174 | + (should (equal (allergen-list 0) '()))) |
| 175 | + |
| 176 | + |
| 177 | +(ert-deftest list-when-allergic-to-just-eggs () |
| 178 | + (should (equal (allergen-list 1) '("eggs")))) |
| 179 | + |
| 180 | + |
| 181 | +(ert-deftest list-when-allergic-to-just-peanuts () |
| 182 | + (should (equal (allergen-list 2) '("peanuts")))) |
| 183 | + |
| 184 | + |
| 185 | +(ert-deftest list-when-allergic-to-just-strawberries () |
| 186 | + (should (equal (allergen-list 8) '("strawberries")))) |
| 187 | + |
| 188 | + |
| 189 | +(ert-deftest list-when-allergic-to-eggs-and-peanuts () |
| 190 | + (should (equal (allergen-list 3) '("eggs" "peanuts")))) |
| 191 | + |
| 192 | + |
| 193 | +(ert-deftest list-when-allergic-to-more-than-eggs-but-not-peanuts () |
| 194 | + (should (equal (allergen-list 5) '("eggs" "shellfish")))) |
| 195 | + |
| 196 | + |
| 197 | +(ert-deftest list-when-allergic-to-lots-of-stuff () |
| 198 | + (should (equal (allergen-list 248) |
| 199 | + '("strawberries" "tomatoes" "chocolate" "pollen" "cats")))) |
| 200 | + |
| 201 | + |
| 202 | +(ert-deftest list-when-allergic-to-everything () |
| 203 | + (should (equal (allergen-list 255) |
| 204 | + '("eggs" |
| 205 | + "peanuts" |
| 206 | + "shellfish" |
| 207 | + "strawberries" |
| 208 | + "tomatoes" |
| 209 | + "chocolate" |
| 210 | + "pollen" |
| 211 | + "cats")))) |
| 212 | + |
48 | 213 |
|
49 | 214 | (ert-deftest ignore-non-allergen-score-parts ()
|
50 |
| - (should (equal '("eggs" "shellfish" "strawberries" "tomatoes" |
51 |
| - "chocolate" "pollen" "cats") |
52 |
| - (allergen-list 509)))) |
| 215 | + (should (equal (allergen-list 509) |
| 216 | + '("eggs" |
| 217 | + "shellfish" |
| 218 | + "strawberries" |
| 219 | + "tomatoes" |
| 220 | + "chocolate" |
| 221 | + "pollen" |
| 222 | + "cats")))) |
| 223 | + |
| 224 | + |
| 225 | +(ert-deftest list-when-no-allergen-score-parts-without-highest-valid-score () |
| 226 | + (should (equal (allergen-list 257) '("eggs")))) |
53 | 227 |
|
54 |
| -(ert-deftest no-allergen-score-parts-without-highest-valid-score () |
55 |
| - (should (equal '("eggs") (allergen-list 257)))) |
56 | 228 |
|
57 |
| -(provide 'allergies) |
| 229 | +(provide 'allergies-tests) |
58 | 230 | ;;; allergies-test.el ends here
|
0 commit comments