-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathTestNSIndexPath.swift
57 lines (45 loc) · 1.41 KB
/
TestNSIndexPath.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
#if DEPLOYMENT_RUNTIME_OBJC || os(Linux)
import Foundation
import XCTest
#else
import SwiftFoundation
import SwiftXCTest
#endif
class TestNSIndexPath: XCTestCase {
static var allTests: [(String, (TestNSIndexPath) -> () throws -> Void)] {
return [
("test_BasicConstruction", test_BasicConstruction)
]
}
func test_BasicConstruction() {
// Test `init()`
do {
let path = IndexPath()
XCTAssertEqual(path.count, 0)
}
// Test `init(index:)`
do {
let path = IndexPath(index: 8)
XCTAssertEqual(path.count, 1)
let index0 = path[0]
XCTAssertEqual(index0, 8)
}
// Test `init(indexes:)`
do {
let path = IndexPath(indexes: [1, 2])
XCTAssertEqual(path.count, 2)
let index0 = path[0]
XCTAssertEqual(index0, 1)
let index1 = path[1]
XCTAssertEqual(index1, 2)
}
}
}