-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathSubscriptAmbiguityTests.swift
35 lines (24 loc) · 1.04 KB
/
SubscriptAmbiguityTests.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
import Foundation
import OrderedDictionary
import XCTest
// See #49
class SubscriptAmbiguityTests: XCTestCase {
func testAccess() {
let orderedDictionary: OrderedDictionary<Int, String> = [1: "a", 2: "b", 3: "c"]
let valueForKey = orderedDictionary[1] as String?
let elementAtIndex = orderedDictionary[1] as (key: Int, value: String)
XCTAssertEqual(valueForKey, "a")
XCTAssertEqual(elementAtIndex.key, 2)
XCTAssertEqual(elementAtIndex.value, "b")
}
func testIndexBasedUpdate() {
var orderedDictionary: OrderedDictionary<Int, String> = [1: "a", 2: "b", 3: "c"]
orderedDictionary[1] = (key: 2, value: "x")
XCTAssertEqual(orderedDictionary, [1: "a", 2: "x", 3: "c"])
}
func testKeyBasedUpdate() {
var orderedDictionary: OrderedDictionary<Int, String> = [1: "a", 2: "b", 3: "c"]
orderedDictionary[1] = "x"
XCTAssertEqual(orderedDictionary, [1: "x", 2: "b", 3: "c"])
}
}