|
19 | 19 | (should (string= (numbers "223 456 7890 ") "2234567890")))
|
20 | 20 |
|
21 | 21 | (ert-deftest invalid-when-9-digits ()
|
22 |
| - (should (string= (cadr (should-error (numbers "123456789"))) |
23 |
| - "must not be fewer than 10 digits"))) |
| 22 | + (should-error (numbers "123456789") :type 'short-phone-num-error)) |
24 | 23 |
|
25 | 24 | (ert-deftest invalid-when-11-digits-does-not-start-with-a-1 ()
|
26 |
| - (should (string= (cadr (should-error (numbers "22234567890"))) |
27 |
| - "11 digits must start with 1"))) |
| 25 | + (should-error (numbers "22234567890") :type 'country-code-error)) |
28 | 26 |
|
29 | 27 | (ert-deftest valid-when-11-digits-and-starting-with-1 ()
|
30 | 28 | (should (string= (numbers "12234567890") "2234567890")))
|
|
33 | 31 | (should (string= (numbers "+1 (223) 456-7890") "2234567890")))
|
34 | 32 |
|
35 | 33 | (ert-deftest invalid-when-more-than-11-digits ()
|
36 |
| - (should (string= (cadr (should-error (numbers "321234567890"))) |
37 |
| - "must not be greater than 11 digits"))) |
| 34 | + (should-error (numbers "321234567890") :type 'long-phone-num-error)) |
38 | 35 |
|
39 | 36 | (ert-deftest invalid-with-letters ()
|
40 |
| - (should (string= (cadr (should-error (numbers "523-abc-7890"))) |
41 |
| - "letters not permitted"))) |
| 37 | + (should-error (numbers "523-abc-7890") :type 'letters-in-phone-num-error)) |
42 | 38 |
|
43 | 39 | (ert-deftest invalid-with-punctuations ()
|
44 |
| - (should (string= (cadr (should-error (numbers "523-@:!-7890"))) |
45 |
| - "punctuations not permitted"))) |
| 40 | + (should-error (numbers "523-@:!-7890") :type 'punctuations-in-phone-num-error)) |
46 | 41 |
|
47 | 42 | (ert-deftest invalid-if-area-code-starts-with-0 ()
|
48 |
| - (should (string= (cadr (should-error (numbers "(023) 456-7890"))) |
49 |
| - "area code cannot start with zero"))) |
| 43 | + (should-error (numbers "(023) 456-7890") :type 'area-code-starting-with-0-error)) |
50 | 44 |
|
51 | 45 | (ert-deftest invalid-if-area-code-starts-with-1 ()
|
52 |
| - (should (string= (cadr (should-error (numbers "(123) 456-7890"))) |
53 |
| - "area code cannot start with one"))) |
| 46 | + (should-error (numbers "(123) 456-7890") :type 'area-code-starting-with-1-error)) |
54 | 47 |
|
55 | 48 | (ert-deftest invalid-if-exchange-code-starts-with-0 ()
|
56 |
| - (should (string= (cadr (should-error (numbers "(223) 056-7890"))) |
57 |
| - "exchange code cannot start with zero"))) |
| 49 | + (should-error (numbers "(223) 056-7890") :type 'exchange-code-starting-with-0-error)) |
58 | 50 |
|
59 | 51 | (ert-deftest invalid-if-exchange-code-starts-with-1 ()
|
60 |
| - (should (string= (cadr (should-error (numbers "(223) 156-7890"))) |
61 |
| - "exchange code cannot start with one"))) |
| 52 | + (should-error (numbers "(223) 156-7890") :type 'exchange-code-starting-with-1-error)) |
62 | 53 |
|
63 | 54 | (ert-deftest invalid-if-area-code-starts-with-0-on-valid-11-digit-number ()
|
64 |
| - (should (string= (cadr (should-error (numbers "1 (023) 456-7890"))) |
65 |
| - "area code cannot start with zero"))) |
| 55 | + (should-error (numbers "1 (023) 456-7890") :type 'area-code-starting-with-0-error)) |
66 | 56 |
|
67 | 57 | (ert-deftest invalid-if-area-code-starts-with-1-on-valid-11-digit-number ()
|
68 |
| - (should (string= (cadr (should-error (numbers "1 (123) 456-7890"))) |
69 |
| - "area code cannot start with one"))) |
| 58 | + (should-error (numbers "1 (123) 456-7890") :type 'area-code-starting-with-1-error)) |
70 | 59 |
|
71 | 60 | (ert-deftest invalid-if-exchange-code-starts-with-0-on-valid-11-digit-number ()
|
72 |
| - (should (string= (cadr (should-error (numbers "1 (223) 056-7890"))) |
73 |
| - "exchange code cannot start with zero"))) |
| 61 | + (should-error (numbers "1 (223) 056-7890") :type 'exchange-code-starting-with-0-error)) |
74 | 62 |
|
75 | 63 | (ert-deftest invalid-if-exchange-code-starts-with-1-on-valid-11-digit-number ()
|
76 |
| - (should (string= (cadr (should-error (numbers "1 (223) 156-7890"))) |
77 |
| - "exchange code cannot start with one"))) |
| 64 | + (should-error (numbers "1 (223) 156-7890") :type 'exchange-code-starting-with-1-error)) |
78 | 65 |
|
79 | 66 | (ert-deftest area-code-test ()
|
80 | 67 | (should (equal (area-code "2234567890") "223")))
|
|
0 commit comments