forked from swiftlang/swift-corelibs-foundation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestProgress.swift
62 lines (55 loc) · 2.36 KB
/
TestProgress.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
58
59
60
61
62
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Foundation
import XCTest
class TestProgress : XCTestCase {
func testUserInfoConveniences() {
if #available(macOS 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
let p = Progress(parent:nil, userInfo: nil)
XCTAssertNil(p.userInfo[.throughputKey])
XCTAssertNil(p.throughput)
p.throughput = 50
XCTAssertEqual(p.throughput, 50)
XCTAssertNotNil(p.userInfo[.throughputKey])
XCTAssertNil(p.userInfo[.estimatedTimeRemainingKey])
XCTAssertNil(p.estimatedTimeRemaining)
p.estimatedTimeRemaining = 100
XCTAssertEqual(p.estimatedTimeRemaining, 100)
XCTAssertNotNil(p.userInfo[.estimatedTimeRemainingKey])
XCTAssertNil(p.userInfo[.fileTotalCountKey])
XCTAssertNil(p.fileTotalCount)
p.fileTotalCount = 42
XCTAssertEqual(p.fileTotalCount, 42)
XCTAssertNotNil(p.userInfo[.fileTotalCountKey])
XCTAssertNil(p.userInfo[.fileCompletedCountKey])
XCTAssertNil(p.fileCompletedCount)
p.fileCompletedCount = 24
XCTAssertEqual(p.fileCompletedCount, 24)
XCTAssertNotNil(p.userInfo[.fileCompletedCountKey])
}
}
func testPerformAsCurrent() {
if #available(macOS 10.11, iOS 8.0, *) {
// This test can be enabled once <rdar://problem/31867347> is in the SDK
/*
let p = Progress.discreteProgress(totalUnitCount: 10)
let r = p.performAsCurrent(withPendingUnitCount: 10) {
XCTAssertNotNil(Progress.current())
return 42
}
XCTAssertEqual(r, 42)
XCTAssertEqual(p.completedUnitCount, 10)
XCTAssertNil(Progress.current())
*/
}
}
}