@@ -9,21 +9,23 @@ final class DefaultTests: XCTestCase {
99 private struct Thing : Codable , Equatable {
1010 var name : String
1111
12- @Default < Empty >
13- var description : String
14-
15- @Default < True >
16- var isFoo : Bool
17-
18- @Default < FirstCase >
19- var type : ThingType
20-
21- @Default < ZeroDouble >
22- var floatingPoint : Double
23-
24- init ( name: String , description: String = " " , isFoo: Bool = true , type: ThingType = . foo, floatingPoint: Double = 0 ) {
12+ @Default < Empty > var description : String
13+ @Default < EmptyDictionary > var entities : [ String : String ]
14+ @Default < True > var isFoo : Bool
15+ @Default < FirstCase > var type : ThingType
16+ @Default < ZeroDouble > var floatingPoint : Double
17+
18+ init (
19+ name: String ,
20+ description: String = " " ,
21+ entities: [ String : String ] = [ : ] ,
22+ isFoo: Bool = true ,
23+ type: ThingType = . foo,
24+ floatingPoint: Double = 0
25+ ) {
2526 self . name = name
2627 self . description = description
28+ self . entities = entities
2729 self . isFoo = isFoo
2830 self . type = type
2931 self . floatingPoint = floatingPoint
@@ -36,6 +38,9 @@ final class DefaultTests: XCTestCase {
3638 {
3739 " name " : " Any name " ,
3840 " description " : " Any description " ,
41+ " entities " : {
42+ " foo " : " bar "
43+ },
3944 " isFoo " : false,
4045 " type " : " baz " ,
4146 " floatingPoint " : 12.34
@@ -47,6 +52,7 @@ final class DefaultTests: XCTestCase {
4752
4853 // then
4954 XCTAssertEqual ( " Any description " , result. description)
55+ XCTAssertEqual ( [ " foo " : " bar " ] , result. entities)
5056 XCTAssertFalse ( result. isFoo)
5157 XCTAssertEqual ( ThingType . baz, result. type)
5258 XCTAssertEqual ( result. floatingPoint, 12.34 )
@@ -58,6 +64,7 @@ final class DefaultTests: XCTestCase {
5864 {
5965 " name " : " Any name " ,
6066 " description " : null,
67+ " entities " : null,
6168 " isFoo " : null,
6269 " type " : null,
6370 " floatingPoint " : null
@@ -69,6 +76,7 @@ final class DefaultTests: XCTestCase {
6976
7077 // then
7178 XCTAssertEqual ( " " , result. description)
79+ XCTAssertEqual ( [ : ] , result. entities)
7280 XCTAssertTrue ( result. isFoo)
7381 XCTAssertEqual ( ThingType . foo, result. type)
7482 XCTAssertEqual ( result. floatingPoint, 0 )
@@ -87,6 +95,7 @@ final class DefaultTests: XCTestCase {
8795
8896 // then
8997 XCTAssertEqual ( " " , result. description)
98+ XCTAssertEqual ( [ : ] , result. entities)
9099 XCTAssertTrue ( result. isFoo)
91100 XCTAssertEqual ( ThingType . foo, result. type)
92101 XCTAssertEqual ( result. floatingPoint, 0 )
@@ -111,10 +120,20 @@ final class DefaultTests: XCTestCase {
111120 @available ( OSX 10 . 13 , iOS 11 . 0 , watchOS 4 . 0 , tvOS 11 . 0 , * )
112121 func testValueEncodesToActualValue( ) throws {
113122 // given
114- let thing = Thing ( name: " Any name " , description: " Any description " , isFoo: false , type: . baz, floatingPoint: 12.34 )
123+ let thing = Thing (
124+ name: " Any name " ,
125+ description: " Any description " ,
126+ entities: [ " foo " : " bar " ] ,
127+ isFoo: false ,
128+ type: . baz,
129+ floatingPoint: 12.34
130+ )
115131 let expected = """
116132 {
117133 " description " : " Any description " ,
134+ " entities " : {
135+ " foo " : " bar "
136+ },
118137 " floatingPoint " : 12.34,
119138 " isFoo " : false,
120139 " name " : " Any name " ,
0 commit comments