-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathCapacityTests.swift
43 lines (27 loc) · 1.23 KB
/
CapacityTests.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
import Foundation
import OrderedDictionary
import XCTest
class CapacityTests: XCTestCase {
func testCapacityReservationViaInit() {
let orderedDictionary = OrderedDictionary<String, Int>(minimumCapacity: 10)
XCTAssertGreaterThanOrEqual(orderedDictionary.capacity, 10)
}
func testCapacityReservationViaMethod() {
var orderedDictionary = OrderedDictionary<String, Int>()
XCTAssertEqual(orderedDictionary.capacity, 0)
orderedDictionary.reserveCapacity(10)
XCTAssertGreaterThanOrEqual(orderedDictionary.capacity, 10)
XCTAssertLessThan(orderedDictionary.capacity, 20)
orderedDictionary.reserveCapacity(20)
XCTAssertGreaterThanOrEqual(orderedDictionary.capacity, 20)
}
func testCapacityGrowForElementInsertion() {
var orderedDictionary = OrderedDictionary<String, Int>()
XCTAssertEqual(orderedDictionary.capacity, 0)
orderedDictionary["a"] = 1
XCTAssertEqual(orderedDictionary.capacity, 1)
orderedDictionary["b"] = 2
orderedDictionary["a"] = 3
XCTAssertEqual(orderedDictionary.capacity, 2)
}
}