-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
184 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
|
||
use lib 't/inc'; | ||
use fatalwarnings; | ||
|
||
use Number::Phone::Lib; | ||
use Test::More; | ||
|
||
END { done_testing(); } | ||
|
||
{ | ||
my $np = Number::Phone::Lib->new('AR', '3715 65 4320'); | ||
ok($np->is_fixed_line, '3715 65 4320 is a fixed line without national prefix...'); | ||
ok(!$np->is_mobile, '...it is not a mobile...'); | ||
is($np->format, '+54 3715 65 4320', '...its international format is correct'); | ||
is($np->format_using('National'), '03715 65-4320', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('AR', '0 3715 65 4320'); | ||
ok($np->is_fixed_line, '03715 65 4320 is a fixed line with a national prefix...'); | ||
ok(!$np->is_mobile, '...it is not a mobile...'); | ||
is($np->format, '+54 3715 65 4320', '...its international format is correct'); | ||
is($np->format_using('National'), '03715 65-4320', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('AR', '3715 15 65 4320'); | ||
ok($np->is_mobile, '3715 15 65 4320 is a mobile with a national prefix...'); | ||
ok(!$np->is_fixed_line, '...it is not a fixed line...'); | ||
is($np->format, '+54 9 3715 65 4320', '...its international format is correct'); | ||
is($np->format_using('National'), '03715 15-65-4320', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('AR', '0 3715 15 65 4320'); | ||
ok($np->is_mobile, '03715 15 65 4320 is a mobile with a national prefix...'); | ||
ok(!$np->is_fixed_line, '...it is not a fixed line...'); | ||
is($np->format, '+54 9 3715 65 4320', '...its international format is correct'); | ||
is($np->format_using('National'), '03715 15-65-4320', '...as is its national format'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
|
||
use lib 't/inc'; | ||
use fatalwarnings; | ||
|
||
use Number::Phone::Lib; | ||
use Test::More; | ||
|
||
END { done_testing(); } | ||
|
||
{ | ||
my $np = Number::Phone::Lib->new('MX', '81 1234 5678'); | ||
ok($np->is_fixed_line, '81 1234 5678 is a fixed line without national prefix...'); | ||
ok(!$np->is_mobile, '...it is not a mobile...'); | ||
is($np->format, '+52 81 1234 5678', '...its international format is correct'); | ||
is($np->format_using('National'), '01 81 1234 5678', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('MX', '01 81 1234 5678'); | ||
ok($np->is_fixed_line, '01 81 1234 5678 is a fixed line with domestic dialling prefix...'); | ||
ok(!$np->is_mobile, '...it is not a mobile...'); | ||
is($np->format, '+52 81 1234 5678', '...its international format is correct'); | ||
is($np->format_using('National'), '01 81 1234 5678', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('MX', '044 81 1234 5678'); | ||
ok($np->is_mobile, '044 81 1234 5678 is a local mobile as called from a fixed line...'); | ||
ok(!$np->is_fixed_line, '...it is not a fixed line...'); | ||
is($np->format, '+52 1 81 1234 5678', '...its international format is correct'); | ||
is($np->format_using('National'), '044 81 1234 5678', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('MX', '045 81 1234 5678'); | ||
ok($np->is_mobile, '045 81 1234 5678 is a domestic mobile as called from a fixed line...'); | ||
ok(!$np->is_fixed_line, '...it is not a fixed line...'); | ||
is($np->format, '+52 1 81 1234 5678', '...its international format is correct'); | ||
# 045 is the prefix used when dialling a mobile number from a fix line, | ||
# where the mobile and the fixed line share the same area code. 045 is | ||
# the code used when the area codes differ. The area code of the caller is | ||
# not known, so libphonenumber always uses 044. | ||
is($np->format_using('National'), '044 81 1234 5678', '...as is its national format (045 becomes 044)'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
|
||
use lib 't/inc'; | ||
use fatalwarnings; | ||
|
||
use Number::Phone::Lib; | ||
use Test::More; | ||
|
||
END { done_testing(); } | ||
|
||
{ | ||
my $np = Number::Phone::Lib->new('SM', '912345'); | ||
ok($np->is_fixed_line, '912345 is a fixed line without the 0549 prefix...'); | ||
ok(!$np->is_mobile, '...it is not a mobile...'); | ||
is($np->format, '+378 0549 912345', '...its international format is correct'); | ||
is($np->format_using('National'), '(0549) 912345', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('SM', '0549 912345'); | ||
ok($np->is_fixed_line, '0549 912345 is a fixed line without the 0549 prefix...'); | ||
ok(!$np->is_mobile, '...it is not a mobile...'); | ||
is($np->format, '+378 0549 912345', '...its international format is correct'); | ||
is($np->format_using('National'), '(0549) 912345', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('SM', '66661212'); | ||
ok($np->is_mobile, '044 81 1234 5678 is a mobile...'); | ||
ok(!$np->is_fixed_line, '...it is not a fixed line...'); | ||
is($np->format, '+378 66 66 12 12', '...its international format is correct'); | ||
is($np->format_using('National'), '66 66 12 12', '...as is its national format'); | ||
} | ||
{ | ||
my $np = Number::Phone::Lib->new('MX', '0549 66661212'); | ||
ok(!defined $np, '0549 66661212 is a mobile with the 0549 prefix, which is not valid'); | ||
} |