Files
swift-collections/Tests/PersistentCollectionsTests/PersistentDictionary.Values Tests.swift
T
Karoy Lorentey 84356e58c7 [PersistentCollection] Back out BidirectionalCollection conformance
BidirectionalCollection has the connotation that the ordering
of elements is meaningful, which isn’t the case for PersistentSet
and PersistentDictionary.
2022-10-27 18:08:27 -07:00

42 lines
1.2 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2022 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
//
//===----------------------------------------------------------------------===//
import XCTest
import _CollectionsTestSupport
import PersistentCollections
class PersistentDictionaryValuesTests: CollectionTestCase {
func test_BidirectionalCollection_fixtures() {
withEachFixture { fixture in
withLifetimeTracking { tracker in
let (d, ref) = tracker.persistentDictionary(for: fixture)
let v = ref.map { $0.value }
checkCollection(d.values, expectedContents: v, by: ==)
_checkBidirectionalCollection_indexOffsetBy(
d.values, expectedContents: v, by: ==)
}
}
}
func test_descriptions() {
let d: PersistentDictionary = [
"a": 1,
"b": 2
]
if d.first!.key == "a" {
expectEqual(d.values.description, "[1, 2]")
} else {
expectEqual(d.values.description, "[2, 1]")
}
}
}