Skip to content

Commit

Permalink
Additional formatting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marmelroy committed Nov 6, 2015
1 parent 2e1a8e8 commit 9cddfd4
Showing 1 changed file with 52 additions and 28 deletions.
80 changes: 52 additions & 28 deletions PhoneNumberKitTests/PhoneNumberKitParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,28 @@ class PhoneNumberKitParsingTests: XCTestCase {
do {
let phoneNumber1 = try PhoneNumber(rawNumber: "0291 12345678", region: "DE")
XCTAssertNotNil(phoneNumber1)
let phoneNumber2 = try PhoneNumber(rawNumber: "+49 291 12345678", region: "DE")
let phoneNumberInternationalFormat1 = phoneNumber1.toInternational()
XCTAssertTrue(phoneNumberInternationalFormat1 == "+49 291 12345678")
let phoneNumberNationalFormat1 = phoneNumber1.toNational()
XCTAssertTrue(phoneNumberNationalFormat1 == "0291 12345678")
let phoneNumberE164Format1 = phoneNumber1.toE164()
XCTAssertTrue(phoneNumberE164Format1 == "+4929112345678")
let phoneNumber2 = try PhoneNumber(rawNumber: "04134 1234", region: "DE")
XCTAssertNotNil(phoneNumber2)
let phoneNumber3 = try PhoneNumber(rawNumber: "04134 1234", region: "DE")
let phoneNumberInternationalFormat2 = phoneNumber2.toInternational()
XCTAssertTrue(phoneNumberInternationalFormat2 == "+49 4134 1234")
let phoneNumberNationalFormat2 = phoneNumber2.toNational()
XCTAssertTrue(phoneNumberNationalFormat2 == "04134 1234")
let phoneNumberE164Format2 = phoneNumber2.toE164()
XCTAssertTrue(phoneNumberE164Format2 == "+4941341234")
let phoneNumber3 = try PhoneNumber(rawNumber: "+49 8021 2345", region: "DE")
XCTAssertNotNil(phoneNumber3)
let phoneNumber4 = try PhoneNumber(rawNumber: "09123 12345", region: "DE")
XCTAssertNotNil(phoneNumber4)
let phoneNumber5 = try PhoneNumber(rawNumber: "+49 8021 2345", region: "DE")
XCTAssertNotNil(phoneNumber5)
let phoneNumberInternationalFormat3 = phoneNumber3.toInternational()
XCTAssertTrue(phoneNumberInternationalFormat3 == "+49 8021 2345")
let phoneNumberNationalFormat3 = phoneNumber3.toNational()
XCTAssertTrue(phoneNumberNationalFormat3 == "08021 2345")
let phoneNumberE164Format3 = phoneNumber3.toE164()
XCTAssertTrue(phoneNumberE164Format3 == "+4980212345")
}
catch {
XCTFail()
Expand All @@ -125,10 +139,12 @@ class PhoneNumberKitParsingTests: XCTestCase {
do {
let phoneNumber1 = try PhoneNumber(rawNumber: "02 3661 8300", region: "IT")
XCTAssertNotNil(phoneNumber1)
let phoneNumber2 = try PhoneNumber(rawNumber: "+39 02 3661 8300", region: "IT")
XCTAssertNotNil(phoneNumber2)
let phoneNumber3 = try PhoneNumber(rawNumber: "+390236618300", region: "IT")
XCTAssertNotNil(phoneNumber3)
let phoneNumberInternationalFormat1 = phoneNumber1.toInternational()
XCTAssertTrue(phoneNumberInternationalFormat1 == "+39 02 3661 8300")
let phoneNumberNationalFormat1 = phoneNumber1.toNational()
XCTAssertTrue(phoneNumberNationalFormat1 == "02 3661 8300")
let phoneNumberE164Format1 = phoneNumber1.toE164()
XCTAssertTrue(phoneNumberE164Format1 == "+390236618300")
}
catch {
XCTFail()
Expand All @@ -139,16 +155,20 @@ class PhoneNumberKitParsingTests: XCTestCase {
do {
let phoneNumber1 = try PhoneNumber(rawNumber: "02 3661 8300", region: "AU")
XCTAssertNotNil(phoneNumber1)
let phoneNumber2 = try PhoneNumber(rawNumber: "+61 2 3661 8300", region: "AU")
let phoneNumberInternationalFormat1 = phoneNumber1.toInternational()
XCTAssertTrue(phoneNumberInternationalFormat1 == "+61 2 3661 8300")
let phoneNumberNationalFormat1 = phoneNumber1.toNational()
XCTAssertTrue(phoneNumberNationalFormat1 == "(02) 3661 8300")
let phoneNumberE164Format1 = phoneNumber1.toE164()
XCTAssertTrue(phoneNumberE164Format1 == "+61236618300")
let phoneNumber2 = try PhoneNumber(rawNumber: "+61 1800 123 456", region: "AU")
XCTAssertNotNil(phoneNumber2)
let phoneNumber3 = try PhoneNumber(rawNumber: "+61236618300", region: "AU")
XCTAssertNotNil(phoneNumber3)
let phoneNumber4 = try PhoneNumber(rawNumber: "1800 123 456", region: "AU")
XCTAssertNotNil(phoneNumber4)
let phoneNumber5 = try PhoneNumber(rawNumber: "+61 1800 123 456", region: "AU")
XCTAssertNotNil(phoneNumber5)
let phoneNumber6 = try PhoneNumber(rawNumber: "+611800123456", region: "AU")
XCTAssertNotNil(phoneNumber6)
let phoneNumberInternationalFormat2 = phoneNumber2.toInternational()
XCTAssertTrue(phoneNumberInternationalFormat2 == "+61 1800 123 456")
let phoneNumberNationalFormat2 = phoneNumber2.toNational()
XCTAssertTrue(phoneNumberNationalFormat2 == "1800 123 456")
let phoneNumberE164Format2 = phoneNumber2.toE164()
XCTAssertTrue(phoneNumberE164Format2 == "+611800123456")
}
catch {
XCTFail()
Expand All @@ -159,16 +179,20 @@ class PhoneNumberKitParsingTests: XCTestCase {
do {
let phoneNumber1 = try PhoneNumber(rawNumber: "011 8765-4321", region: "AR")
XCTAssertNotNil(phoneNumber1)
let phoneNumber2 = try PhoneNumber(rawNumber: "+54 11 8765-4321", region: "AR")
let phoneNumberInternationalFormat1 = phoneNumber1.toInternational()
XCTAssertTrue(phoneNumberInternationalFormat1 == "+54 11 8765-4321")
let phoneNumberNationalFormat1 = phoneNumber1.toNational()
XCTAssertTrue(phoneNumberNationalFormat1 == "011 8765-4321")
let phoneNumberE164Format1 = phoneNumber1.toE164()
XCTAssertTrue(phoneNumberE164Format1 == "+541187654321")
let phoneNumber2 = try PhoneNumber(rawNumber: "011 15 8765-4321", region: "AR")
XCTAssertNotNil(phoneNumber2)
let phoneNumber3 = try PhoneNumber(rawNumber: "+541187654321", region: "AR")
XCTAssertNotNil(phoneNumber3)
let phoneNumber4 = try PhoneNumber(rawNumber: "011 15 8765-4321", region: "AR")
XCTAssertNotNil(phoneNumber4)
let phoneNumber5 = try PhoneNumber(rawNumber: "+54 9 11 8765 4321", region: "AR")
XCTAssertNotNil(phoneNumber5)
let phoneNumber6 = try PhoneNumber(rawNumber: "+5491187654321", region: "AR")
XCTAssertNotNil(phoneNumber6)
let phoneNumberInternationalFormat2 = phoneNumber2.toInternational()
XCTAssertTrue(phoneNumberInternationalFormat2 == "+54 9 11 8765-4321")
let phoneNumberNationalFormat2 = phoneNumber2.toNational()
XCTAssertTrue(phoneNumberNationalFormat2 == "011 15-8765-4321")
let phoneNumberE164Format2 = phoneNumber2.toE164()
XCTAssertTrue(phoneNumberE164Format2 == "+5491187654321")
}
catch {
XCTFail()
Expand Down

0 comments on commit 9cddfd4

Please sign in to comment.