Skip to content

Commit

Permalink
Merge pull request #34 from 4rakcheev/master
Browse files Browse the repository at this point in the history
China + Kosovo update
  • Loading branch information
Dongri Jin authored Aug 2, 2023
2 parents 9e2d448 + d777c18 commit 300a6e9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
12 changes: 10 additions & 2 deletions iso3166.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func GetISO3166() []ISO3166 {
i.CountryCode = "86"
i.CountryName = "China"
i.MobileBeginWith = []string{"13", "14", "15", "16", "17", "18"}
i.PhoneNumberLengths = []int{11}
i.PhoneNumberLengths = []int{10, 11}
iso3166Datas = append(iso3166Datas, i)

i.Alpha2 = "CI"
Expand Down Expand Up @@ -1333,7 +1333,7 @@ func GetISO3166() []ISO3166 {
i.CountryCode = "51"
i.CountryName = "Peru"
i.MobileBeginWith = []string{"9"}
i.PhoneNumberLengths = []int{9}
i.PhoneNumberLengths = []int{8, 9}
iso3166Datas = append(iso3166Datas, i)

i.Alpha2 = "PH"
Expand Down Expand Up @@ -1832,6 +1832,14 @@ func GetISO3166() []ISO3166 {
i.PhoneNumberLengths = []int{7}
iso3166Datas = append(iso3166Datas, i)

i.Alpha2 = "XK"
i.Alpha3 = "XKX"
i.CountryCode = "383"
i.CountryName = "Kosovo"
i.MobileBeginWith = []string{"3", "4", "6"}
i.PhoneNumberLengths = []int{8}
iso3166Datas = append(iso3166Datas, i)

i.Alpha2 = "YE"
i.Alpha3 = "YEM"
i.CountryCode = "967"
Expand Down
24 changes: 24 additions & 0 deletions phonenumber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ var mobFormatTests = []struct {
{"(817) 569-8900", "USA", "18175698900"},
{"+371 25 641 580", "LV", "37125641580"},
{"+62 895349866066", "ID", "62895349866066"},
{"+51 912 640 074", "PE", "51912640074"},
{"+86 18 855 512 329", "CN", "8618855512329"},
{"+383 4 555 4999", "XK", "38345554999"},
}

func TestFormatMobile(t *testing.T) {
Expand All @@ -41,6 +44,10 @@ var mobFormatTestsNegative = []struct {
{"7499 709 88 33", "RU"},
{"+48 22 (483) 53-34", "PL"},
{"4970523743", "DE"},
{"51926474", "PE"},
{"519264112", "PE"},
{"86178555123", "CN"},
{"383 9 3334999", "XK"},
}

func TestFormatForLandLineIsEmpty(t *testing.T) {
Expand All @@ -67,13 +74,20 @@ var mobWithLLFormatTests = []struct {
{"7499 709 88 33", "RU", "74997098833"},
{"22 (483) 53-34", "PL", "48224835334"},
{"48224835334", "PL", "48224835334"},
{"+51 (1) 706-19-70", "PE", "5117061970"},
{"+86 21 85-512-329", "CN", "862185512329"},
{"+383 9 1234999", "XK", "38391234999"},

// Mobile numbers
{"090 6135 3368", "JP", "819061353368"},
{"+8615948692360", "CN", "8615948692360"},
{"008615948692360", "CN", "8615948692360"},
{"(817) 569-8900", "USA", "18175698900"},
{"+371 25 641 580", "LV", "37125641580"},
{"00371 25 641 580", "LV", "37125641580"},
{"+51 999 400 500", "PE", "51999400500"},
{"+86 (16) 855-512-329", "CN", "8616855512329"},
{"+383 4 1234999", "XK", "38341234999"},
}

func TestFormatWithLandLine(t *testing.T) {
Expand All @@ -98,12 +112,19 @@ var mobWithLLCountryTests = []struct {
{"14378869667", "CA"},
{"12836907618", "US"},
{"13406407159", "VI"},
{"5117061970", "PE"},
{"862185551232", "CN"},
{"38391234999", "XK"},

// Mobile numbers
{"39339638066", "IT"},
{"37125641580", "LV"},
{"43663242739", "AT"},
{"21655886170", "TN"},
{"3197010280754", "NL"},
{"51999400500", "PE"},
{"8614855512329", "CN"},
{"38342224999", "XK"},
}

func TestGetCountryForMobileNumberWithLandLine(t *testing.T) {
Expand Down Expand Up @@ -265,6 +286,9 @@ var mobCountryTests = []struct {
{"97366622125", "BH", true},
{"59160136560", "BO", true},
{"59168295570", "BO", true},
{"51907061970", "PE", true},
{"8613855512329", "CN", true},
{"38361234999", "XK", true},
}

func TestGetCountryForMobileNumber(t *testing.T) {
Expand Down

0 comments on commit 300a6e9

Please sign in to comment.