mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This fixes the automatic `std::unordered_map` conformance to CxxDictionary on Linux. Previously `std::unordered_map::const_iterator` was not auto-conformed to UnsafeCxxInputIterator because its `operator==` is defined on a templated base class of `const_iterator`. rdar://105220600
43 lines
943 B
Swift
43 lines
943 B
Swift
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
|
|
//
|
|
// REQUIRES: executable_test
|
|
//
|
|
// REQUIRES: OS=macosx || OS=linux-gnu
|
|
|
|
import StdlibUnittest
|
|
import StdMap
|
|
import CxxStdlib
|
|
import Cxx
|
|
|
|
var StdMapTestSuite = TestSuite("StdMap")
|
|
|
|
StdMapTestSuite.test("init") {
|
|
let m = Map()
|
|
expectEqual(m.size(), 0)
|
|
expectTrue(m.empty())
|
|
}
|
|
|
|
StdMapTestSuite.test("Map.subscript") {
|
|
// This relies on the `std::map` conformance to `CxxDictionary` protocol.
|
|
var m = initMap()
|
|
let at1 = m[1]
|
|
expectNotNil(at1)
|
|
expectEqual(at1, 3)
|
|
expectEqual(m[2], 2)
|
|
expectEqual(m[3], 3)
|
|
expectNil(m[-1])
|
|
expectNil(m[5])
|
|
}
|
|
|
|
StdMapTestSuite.test("UnorderedMap.subscript") {
|
|
// This relies on the `std::unordered_map` conformance to `CxxDictionary` protocol.
|
|
var m = initUnorderedMap()
|
|
expectEqual(m[1], 3)
|
|
expectEqual(m[2], 2)
|
|
expectEqual(m[3], 3)
|
|
expectNil(m[-1])
|
|
expectNil(m[5])
|
|
}
|
|
|
|
runAllTests()
|