Skip to content

Commit

Permalink
Merge pull request #76 from jminutaglio/patch-3
Browse files Browse the repository at this point in the history
Fixes for iPad Air 5 hardware strings & add tests
  • Loading branch information
vincentneo committed Mar 19, 2022
2 parents b422d3a + 192860d commit 2f873e4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/DeviceModel.swift
Expand Up @@ -161,7 +161,7 @@ extension DeviceModel {
case (5, 3), (5, 4): return .iPadAir2
case (11, 3), (11, 4): return .iPadAir3
case (13, 1), (13, 2): return .iPadAir4
case (13, 17), (13, 18): return .iPadAir5
case (13, 16), (13, 17): return .iPadAir5
case (2, 5), (2, 6), (2, 7): return .iPadMini
case (4, 4), (4, 5), (4, 6): return .iPadMini2
case (4, 7), (4, 8), (4, 9): return .iPadMini3
Expand Down
8 changes: 4 additions & 4 deletions Sources/Identifier.swift
Expand Up @@ -167,7 +167,7 @@ extension Identifier: CustomStringConvertible {
case (14, 5):
return "iPhone 13"
case (14, 6):
return "iPhone SE (3nd Gen)"
return "iPhone SE (3rd Gen)"

default:
return "unknown"
Expand Down Expand Up @@ -315,10 +315,10 @@ extension Identifier: CustomStringConvertible {
return "3rd Gen iPad Air (Wi-Fi+LTE)"
case (13, 1):
return "4th Gen iPad Air (Wi-Fi)"
case (13, 17):
case (13, 16):
return "5th Gen iPad Air (Wi-Fi)"
case (13, 18):
return "5th Gen iPad Air (Wi-Fi+LTE)"
case (13, 17):
return "5th Gen iPad Air (Wi-Fi+5G)"
case (13, 2):
return "4th Gen iPad Air (Wi-Fi+LTE)"
case (11, 6):
Expand Down
11 changes: 11 additions & 0 deletions Tests/DeviceModelTests.swift
Expand Up @@ -192,6 +192,11 @@ class DeviceModelTests: XCTestCase {
}

func testDeviceModelIPhone13ProMax() {
let deviceModel = DeviceModel(identifier: Identifier("iPhone14,6"))
XCTAssert(deviceModel == .iPhoneSE3 , "DeviceModel - .iPhoneSE3 is failing")
}

func testDeviceModelIPhoneSE3() {
let deviceModel = DeviceModel(identifier: Identifier("iPhone14,3"))
XCTAssert(deviceModel == .iPhone13ProMax , "DeviceModel - .iPhone13ProMax is failing")
}
Expand Down Expand Up @@ -392,6 +397,12 @@ class DeviceModelTests: XCTestCase {
XCTAssert(deviceModel1 == .iPadAir3 && deviceModel2 == .iPadAir3 , "DeviceModel - .iPadAir3 is failing")
}

func testDeviceModelIPadAir5() {
let deviceModel1 = DeviceModel(identifier: Identifier("iPad13,16"))
let deviceModel2 = DeviceModel(identifier: Identifier("iPad13,17"))
XCTAssert(deviceModel1 == .iPadAir5 && deviceModel2 == .iPadAir5 , "DeviceModel - .iPadAir5 is failing")
}

// MARK: - iPod Device Model tests

func testDeviceModelIPodTouchFirstGen() {
Expand Down
12 changes: 12 additions & 0 deletions Tests/IdentifierTests.swift
Expand Up @@ -66,6 +66,10 @@ class IdentifierTests: XCTestCase {

// MARK: - iPhone String Description tests

func testDisplayStringiPhone14v6() {
XCTAssert(Identifier("iPhone14,6").description == "iPhone SE (3rd Gen)", "iPhone14,6 is failing to produce a common device model string")
}

func testDisplayStringiPhone14v5() {
XCTAssert(Identifier("iPhone14,5").description == "iPhone 13", "iPhone14,5 is failing to produce a common device model string")
}
Expand Down Expand Up @@ -286,6 +290,14 @@ class IdentifierTests: XCTestCase {
func testDisplayStringiPad14v1() {
XCTAssert(Identifier("iPad14,1").description == "6th Gen iPad mini (8.3 inch, Wi-Fi)", "iPad14,1 is failing to produce a common device model string")
}

func testDisplayStringiPad13v16() {
XCTAssert(Identifier("iPad13,16").description == "5th Gen iPad Air (Wi-Fi)", "iPad13,16 is failing to produce a common device model string")
}
func testDisplayStringiPad13v17() {
XCTAssert(Identifier("iPad13,17").description == "5th Gen iPad Air (Wi-Fi+5G)", "iPad13,17 is failing to produce a common device model string")
}

func testDisplayStringiPad13v11() {
XCTAssert(Identifier("iPad13,11").description == "5th Gen iPad Pro (12.9 inch, Wi-Fi+5G, 16GB RAM)", "iPad13,11 is failing to produce a common device model string")
}
Expand Down

0 comments on commit 2f873e4

Please sign in to comment.