-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathRangeReplaceable.swift.gyb
89 lines (73 loc) · 3.36 KB
/
RangeReplaceable.swift.gyb
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// -*- swift -*-
// RUN: rm -rf %t ; mkdir -p %t
// RUN: %S/../../utils/gyb %s -o %t/RangeReplaceable.swift
// RUN: %S/../../utils/line-directive %t/RangeReplaceable.swift -- %target-build-swift %t/RangeReplaceable.swift -o %t/a.out
// RUN: %S/../../utils/line-directive %t/RangeReplaceable.swift -- %target-run %t/a.out
// REQUIRES: executable_test
import StdlibUnittest
import StdlibCollectionUnittest
var RangeReplaceableTestSuite = TestSuite("RangeReplaceable")
RangeReplaceableTestSuite.test("append/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
tester.append(OpaqueValue(2))
expectCustomizable(tester, tester.log.append)
}
RangeReplaceableTestSuite.test("appendContentsOf/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
tester.append(contentsOf: [ 2, 3 ].map(OpaqueValue.init))
expectCustomizable(tester, tester.log.appendContentsOf)
}
RangeReplaceableTestSuite.test("insert/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
tester.insert(OpaqueValue(2), at: tester.base.startIndex)
expectCustomizable(tester, tester.log.insert)
}
RangeReplaceableTestSuite.test("insert(contentsOf:at:)/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
tester.insert(
contentsOf: [ 2, 3 ].map(OpaqueValue.init),
at: tester.base.endIndex)
expectCustomizable(tester, tester.log.insertContentsOf)
}
RangeReplaceableTestSuite.test("remove(at:)/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
tester.remove(at: tester.base.startIndex)
expectCustomizable(tester, tester.log.removeAt)
}
RangeReplaceableTestSuite.test("removeLast/whereIndexIsBidirectional/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
_ = tester.removeLast()
expectCustomizable(tester, tester.log._customRemoveLast)
}
RangeReplaceableTestSuite.test("removeLast(n: Int)/whereIndexIsBidirectional/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
_ = tester.removeLast(1)
expectCustomizable(tester, tester.log._customRemoveLastN)
}
RangeReplaceableTestSuite.test("removeSubrange/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester(
[ 1, 2, 3 ].map(OpaqueValue.init))
tester.removeSubrange(tester.base.startIndex..<tester.base.endIndex)
expectCustomizable(tester, tester.log.removeSubrange)
}
RangeReplaceableTestSuite.test("removeFirst/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
tester.removeFirst()
expectCustomizable(tester, tester.log.removeFirst)
}
RangeReplaceableTestSuite.test("removeFirst(n)/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
tester.removeFirst(1)
expectCustomizable(tester, tester.log.removeFirstN)
}
RangeReplaceableTestSuite.test("removeAll/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester([ OpaqueValue(1) ])
tester.removeAll(keepingCapacity: false)
expectCustomizable(tester, tester.log.removeAll)
}
RangeReplaceableTestSuite.test("reserveCapacity/dispatch") {
var tester = RangeReplaceableCollectionLog.dispatchTester(Array<Int>())
tester.reserveCapacity(10)
expectCustomizable(tester, tester.log.reserveCapacity)
}
runAllTests()