@@ -28,6 +28,49 @@ StdMapTestSuite.test("init") {
2828 expectTrue ( m. empty ( ) )
2929}
3030
31+ StdMapTestSuite . test ( " Map.init(_: Dictionary<Int, Int>) " ) {
32+ let swiftDict : [ Int32 : Int32 ] = [ - 1 : 2 , 2 : 3 , 33 : 44 ]
33+ let m = Map ( swiftDict)
34+ expectEqual ( m. size ( ) , 3 )
35+
36+ expectEqual ( m [ - 1 ] , 2 )
37+ expectEqual ( m [ 2 ] , 3 )
38+ expectEqual ( m [ 33 ] , 44 )
39+
40+ let emptySwiftDict : [ Int32 : Int32 ] = [ : ]
41+ let emptyM = Map ( emptySwiftDict)
42+ expectEqual ( emptyM. size ( ) , 0 )
43+ }
44+
45+ /// Same as above, but for std::unordered_map.
46+ StdMapTestSuite . test ( " UnorderedMap.init(_: Dictionary<Int, Int>) " ) {
47+ let swiftDict : [ Int32 : Int32 ] = [ - 1 : 2 , 2 : 3 , 33 : 44 ]
48+ let m = UnorderedMap ( swiftDict)
49+ expectEqual ( m. size ( ) , 3 )
50+
51+ expectEqual ( m [ - 1 ] , 2 )
52+ expectEqual ( m [ 2 ] , 3 )
53+ expectEqual ( m [ 33 ] , 44 )
54+
55+ let emptySwiftDict : [ Int32 : Int32 ] = [ : ]
56+ let emptyM = UnorderedMap ( emptySwiftDict)
57+ expectEqual ( emptyM. size ( ) , 0 )
58+ }
59+
60+ StdMapTestSuite . test ( " MapStrings.init(_: Dictionary<std.string, std.string>) " ) {
61+ let swiftDict = [ std. string ( " abc " ) : std. string ( " 123 " ) ,
62+ std. string ( ) : std. string ( " empty " ) ]
63+ let m = MapStrings ( swiftDict)
64+ expectEqual ( m. size ( ) , 2 )
65+
66+ expectEqual ( m [ std. string ( " abc " ) ] , std. string ( " 123 " ) )
67+ expectEqual ( m [ std. string ( ) ] , std. string ( " empty " ) )
68+
69+ let emptySwiftDict : [ std . string : std . string ] = [ : ]
70+ let emptyM = MapStrings ( emptySwiftDict)
71+ expectEqual ( emptyM. size ( ) , 0 )
72+ }
73+
3174StdMapTestSuite . test ( " Map.subscript " ) {
3275 // This relies on the `std::map` conformance to `CxxDictionary` protocol.
3376 var m = initMap ( )
0 commit comments