1
1
#include " phone_number.h"
2
-
3
2
#ifdef EXERCISM_TEST_SUITE
4
3
#include < catch2/catch.hpp>
5
4
#else
6
5
#include " test/catch.hpp"
7
6
#endif
8
- #include < exception>
9
7
10
- TEST_CASE (" cleans_the_number" ) {
11
- REQUIRE (" 2234567890" == phone_number::phone_number (" (223) 456-7890" ).number ());
8
+ TEST_CASE (" cleans_the_number" , " [79666dce-e0f1-46de-95a1-563802913c35]" ) {
9
+ REQUIRE (" 2234567890" ==
10
+ phone_number::phone_number (" (223) 456-7890" ).number ());
12
11
}
13
12
14
13
#if defined(EXERCISM_RUN_ALL_TESTS)
15
14
16
- TEST_CASE (" cleans_numbers_with_dots" ) {
17
- REQUIRE (" 2234567890" == phone_number::phone_number (" 223.456.7890" ).number ());
18
- }
19
-
20
- TEST_CASE (" cleans_numbers_with_spaces" ) {
21
- REQUIRE (" 2234567890" == phone_number::phone_number (" 223 456 7890 " ).number ());
22
- }
23
-
24
- TEST_CASE (" has_an_area_code" ) {
25
- REQUIRE (" 223" == phone_number::phone_number (" +1 (223) 456-7890" ).area_code ());
15
+ TEST_CASE (" cleans_numbers_with_dots" ,
16
+ " [c360451f-549f-43e4-8aba-fdf6cb0bf83f]" ) {
17
+ REQUIRE (" 2234567890" ==
18
+ phone_number::phone_number (" 223.456.7890" ).number ());
26
19
}
27
20
28
- TEST_CASE (" formats_a_number" ) {
29
- const phone_number::phone_number phone (" +1 (223) 456-7890" );
30
- REQUIRE (" (223) 456-7890" == std::string (phone));
21
+ TEST_CASE (" cleans_numbers_with_multiple_spaces" ,
22
+ " [08f94c34-9a37-46a2-a123-2a8e9727395d]" ) {
23
+ REQUIRE (" 2234567890" ==
24
+ phone_number::phone_number (" 223 456 7890 " ).number ());
31
25
}
32
26
33
- TEST_CASE (" invalid_when_9_digits" ) {
34
- REQUIRE_THROWS_AS (phone_number::phone_number (" 123456789" ), std::domain_error);
27
+ TEST_CASE (" invalid_when_9_digits" , " [2de74156-f646-42b5-8638-0ef1d8b58bc2]" ) {
28
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 123456789" ),
29
+ std::domain_error);
35
30
}
36
31
37
- TEST_CASE (" invalid_when_11_digits_does_not_start_with_a_1" ) {
38
- REQUIRE_THROWS_AS (phone_number::phone_number (" 22234567890" ), std::domain_error);
32
+ TEST_CASE (" invalid_when_11_digits_does_not_start_with_a_1" ,
33
+ " [57061c72-07b5-431f-9766-d97da7c4399d]" ) {
34
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 22234567890" ),
35
+ std::domain_error);
39
36
}
40
37
41
- TEST_CASE (" valid_when_11_digits_and_starting_with_1" ) {
42
- REQUIRE (" 2234567890" == phone_number::phone_number (" 12234567890" ).number ());
38
+ TEST_CASE (" valid_when_11_digits_and_starting_with_1" ,
39
+ " [9962cbf3-97bb-4118-ba9b-38ff49c64430]" ) {
40
+ REQUIRE (" 2234567890" == phone_number::phone_number (" 12234567890" ).number ());
43
41
}
44
42
45
- TEST_CASE (
46
- " valid_when_11_digits_and_starting_with_1_even_with_punctuation" ) {
47
- REQUIRE (" 2234567890" == phone_number::phone_number (" +1 (223) 456-7890" ).number ());
43
+ TEST_CASE (" valid_when_11_digits_and_starting_with_1_even_with_punctuation" ,
44
+ " [fa724fbf-054c-4d91-95da-f65ab5b6dbca]" ) {
45
+ REQUIRE (" 2234567890" ==
46
+ phone_number::phone_number (" +1 (223) 456-7890" ).number ());
48
47
}
49
48
50
- TEST_CASE (" invalid_when_more_than_11_digits" ) {
51
- REQUIRE_THROWS_AS (phone_number::phone_number (" 321234567890" ), std::domain_error);
49
+ TEST_CASE (" invalid_when_more_than_11_digits" ,
50
+ " [4a1509b7-8953-4eec-981b-c483358ff531]" ) {
51
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 321234567890" ),
52
+ std::domain_error);
52
53
}
53
54
54
- TEST_CASE (" invalid_with_letters" ) {
55
- REQUIRE_THROWS_AS (phone_number::phone_number (" 123-abc-7890" ), std::domain_error);
55
+ TEST_CASE (" invalid_with_letters" , " [eb8a1fc0-64e5-46d3-b0c6-33184208e28a]" ) {
56
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 123-abc-7890" ),
57
+ std::domain_error);
56
58
}
57
59
58
- TEST_CASE (" invalid_with_punctuation" ) {
59
- REQUIRE_THROWS_AS (phone_number::phone_number (" 123-@:!-7890" ), std::domain_error);
60
+ TEST_CASE (" invalid_with_punctuation" ,
61
+ " [065f6363-8394-4759-b080-e6c8c351dd1f]" ) {
62
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 123-@:!-7890" ),
63
+ std::domain_error);
60
64
}
61
65
62
- TEST_CASE (" invalid_if_area_code_starts_with_0" ) {
63
- REQUIRE_THROWS_AS (phone_number::phone_number (" (023) 456-7890" ), std::domain_error);
66
+ TEST_CASE (" invalid_if_area_code_starts_with_0" ,
67
+ " [d77d07f8-873c-4b17-8978-5f66139bf7d7]" ) {
68
+ REQUIRE_THROWS_AS (phone_number::phone_number (" (023) 456-7890" ),
69
+ std::domain_error);
64
70
}
65
71
66
- TEST_CASE (" invalid_if_area_code_starts_with_1" ) {
67
- REQUIRE_THROWS_AS (phone_number::phone_number (" (123) 456-7890" ), std::domain_error);
72
+ TEST_CASE (" invalid_if_area_code_starts_with_1" ,
73
+ " [c7485cfb-1e7b-4081-8e96-8cdb3b77f15e]" ) {
74
+ REQUIRE_THROWS_AS (phone_number::phone_number (" (123) 456-7890" ),
75
+ std::domain_error);
68
76
}
69
77
70
- TEST_CASE (" invalid_if_exchange_code_starts_with_0" ) {
71
- REQUIRE_THROWS_AS (phone_number::phone_number (" (223) 056-7890" ), std::domain_error);
78
+ TEST_CASE (" invalid_if_exchange_code_starts_with_0" ,
79
+ " [4d622293-6976-413d-b8bf-dd8a94d4e2ac]" ) {
80
+ REQUIRE_THROWS_AS (phone_number::phone_number (" (223) 056-7890" ),
81
+ std::domain_error);
72
82
}
73
83
74
- TEST_CASE (" invalid_if_exchange_code_starts_with_1" ) {
75
- REQUIRE_THROWS_AS (phone_number::phone_number (" (223) 156-7890" ), std::domain_error);
84
+ TEST_CASE (" invalid_if_exchange_code_starts_with_1" ,
85
+ " [4cef57b4-7d8e-43aa-8328-1e1b89001262]" ) {
86
+ REQUIRE_THROWS_AS (phone_number::phone_number (" (223) 156-7890" ),
87
+ std::domain_error);
76
88
}
77
89
78
- TEST_CASE (
79
- " invalid_if_area_code_starts_with_0_on_valid_11_digit_number" ) {
80
- REQUIRE_THROWS_AS (phone_number::phone_number (" 1 (023) 456-7890" ), std::domain_error);
90
+ TEST_CASE (" invalid_if_area_code_starts_with_0_on_valid_11_digit_number" ,
91
+ " [9925b09c-1a0d-4960-a197-5d163cbe308c]" ) {
92
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 1 (023) 456-7890" ),
93
+ std::domain_error);
81
94
}
82
95
83
- TEST_CASE (
84
- " invalid_if_area_code_starts_with_1_on_valid_11_digit_number" ) {
85
- REQUIRE_THROWS_AS (phone_number::phone_number (" 1 (123) 456-7890" ), std::domain_error);
96
+ TEST_CASE (" invalid_if_area_code_starts_with_1_on_valid_11_digit_number" ,
97
+ " [3f809d37-40f3-44b5-ad90-535838b1a816]" ) {
98
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 1 (123) 456-7890" ),
99
+ std::domain_error);
86
100
}
87
101
88
- TEST_CASE (
89
- " invalid_if_exchange_code_starts_with_0_on_valid_11_digit_number" ) {
90
- REQUIRE_THROWS_AS (phone_number::phone_number (" 1 (223) 056-7890" ), std::domain_error);
102
+ TEST_CASE (" invalid_if_exchange_code_starts_with_0_on_valid_11_digit_number" ,
103
+ " [e08e5532-d621-40d4-b0cc-96c159276b65]" ) {
104
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 1 (223) 056-7890" ),
105
+ std::domain_error);
91
106
}
92
107
93
- TEST_CASE (
94
- " invalid_if_exchange_code_starts_with_1_on_valid_11_digit_number" ) {
95
- REQUIRE_THROWS_AS (phone_number::phone_number (" 1 (223) 156-7890" ), std::domain_error);
108
+ TEST_CASE (" invalid_if_exchange_code_starts_with_1_on_valid_11_digit_number" ,
109
+ " [57b32f3d-696a-455c-8bf1-137b6d171cdf]" ) {
110
+ REQUIRE_THROWS_AS (phone_number::phone_number (" 1 (223) 156-7890" ),
111
+ std::domain_error);
96
112
}
97
113
98
114
#endif
0 commit comments