@@ -5,26 +5,26 @@ fn to_some_string(s: &str) -> Option<String> {
5
5
}
6
6
7
7
#[ test]
8
- fn test_number_cleans ( ) {
9
- assert_eq ! ( phone:: number( "(123) 456-7890" ) , to_some_string( "1234567890" ) ) ;
8
+ fn test_cleans_the_number ( ) {
9
+ assert_eq ! (
10
+ phone:: number( "(223) 456-7890" ) ,
11
+ to_some_string( "2234567890" )
12
+ ) ;
10
13
}
11
14
12
15
#[ test]
13
16
#[ ignore]
14
- fn test_number_cleans_with_dots ( ) {
15
- assert_eq ! ( phone:: number( "123 .456.7890" ) , to_some_string( "1234567890 " ) ) ;
17
+ fn test_cleans_numbers_with_dots ( ) {
18
+ assert_eq ! ( phone:: number( "223 .456.7890" ) , to_some_string( "2234567890 " ) ) ;
16
19
}
17
20
18
21
#[ test]
19
22
#[ ignore]
20
- fn test_valid_when_11_digits_and_first_is_1 ( ) {
21
- assert_eq ! ( phone:: number( "11234567890" ) , to_some_string( "1234567890" ) ) ;
22
- }
23
-
24
- #[ test]
25
- #[ ignore]
26
- fn test_invalid_when_11_digits ( ) {
27
- assert_eq ! ( phone:: number( "21234567890" ) , None ) ;
23
+ fn test_cleans_numbers_with_multiple_spaces ( ) {
24
+ assert_eq ! (
25
+ phone:: number( "223 456 7890 " ) ,
26
+ to_some_string( "2234567890" )
27
+ ) ;
28
28
}
29
29
30
30
#[ test]
@@ -35,60 +35,51 @@ fn test_invalid_when_9_digits() {
35
35
36
36
#[ test]
37
37
#[ ignore]
38
- fn test_invalid_when_empty ( ) {
39
- assert_eq ! ( phone:: number( "" ) , None ) ;
40
- }
41
-
42
- #[ test]
43
- #[ ignore]
44
- fn test_invalid_when_no_digits_present ( ) {
45
- assert_eq ! ( phone:: number( " (-) " ) , None ) ;
46
- }
47
-
48
- #[ test]
49
- #[ ignore]
50
- fn test_valid_with_leading_characters ( ) {
51
- assert_eq ! ( phone:: number( "my number is 123 456 7890" ) , to_some_string( "1234567890" ) ) ;
38
+ fn test_invalid_when_11_digits_does_not_start_with_a_1 ( ) {
39
+ assert_eq ! ( phone:: number( "22234567890" ) , None ) ;
52
40
}
53
41
54
42
#[ test]
55
43
#[ ignore]
56
- fn test_valid_with_trailing_characters ( ) {
57
- assert_eq ! ( phone:: number( "123 456 7890 - bob " ) , to_some_string( "1234567890 " ) ) ;
44
+ fn test_valid_when_11_digits_and_starting_with_1 ( ) {
45
+ assert_eq ! ( phone:: number( "12234567890 " ) , to_some_string( "2234567890 " ) ) ;
58
46
}
59
47
60
48
#[ test]
61
49
#[ ignore]
62
- fn test_area_code ( ) {
63
- assert_eq ! ( phone:: area_code( "1234567890" ) , to_some_string( "123" ) ) ;
50
+ fn test_valid_when_11_digits_and_starting_with_1_even_with_punctuation ( ) {
51
+ assert_eq ! (
52
+ phone:: number( "+1 (223) 456-7890" ) ,
53
+ to_some_string( "2234567890" )
54
+ ) ;
64
55
}
65
56
66
57
#[ test]
67
58
#[ ignore]
68
- fn test_area_code_with_full_us_phone_number ( ) {
69
- assert_eq ! ( phone:: area_code ( "18234567890 ") , to_some_string ( "823" ) ) ;
59
+ fn test_invalid_when_more_than_11_digits ( ) {
60
+ assert_eq ! ( phone:: number ( "321234567890 ") , None ) ;
70
61
}
71
62
72
63
#[ test]
73
64
#[ ignore]
74
- fn test_area_code_with_invalid ( ) {
75
- assert_eq ! ( phone:: area_code ( "1234161567890 ") , None ) ;
65
+ fn test_invalid_with_letters ( ) {
66
+ assert_eq ! ( phone:: number ( "123-abc-7890 ") , None ) ;
76
67
}
77
68
78
69
#[ test]
79
70
#[ ignore]
80
- fn test_pretty_print ( ) {
81
- assert_eq ! ( phone:: pretty_print ( "1234567890" ) , "( 123) 456- 7890") ;
71
+ fn test_invalid_with_punctuations ( ) {
72
+ assert_eq ! ( phone:: number ( " 123-@:!- 7890") , None ) ;
82
73
}
83
74
84
75
#[ test]
85
76
#[ ignore]
86
- fn test_pretty_print_with_full_us_phone_number ( ) {
87
- assert_eq ! ( phone:: pretty_print ( "11234567890" ) , " (123) 456-7890") ;
77
+ fn test_invalid_if_area_code_does_not_start_with_2_9 ( ) {
78
+ assert_eq ! ( phone:: number ( " (123) 456-7890") , None ) ;
88
79
}
89
80
90
81
#[ test]
91
82
#[ ignore]
92
- fn test_pretty_print_with_invalid ( ) {
93
- assert_eq ! ( phone:: pretty_print ( "1186234567890 ") , "invalid" ) ;
83
+ fn test_invalid_if_exchange_code_does_not_start_with_2_9 ( ) {
84
+ assert_eq ! ( phone:: number ( "(223) 056-7890 ") , None ) ;
94
85
}
0 commit comments