File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import Foundation
12import MetaCodable
23import Testing
34
@@ -124,6 +125,17 @@ struct IgnoreInitializedTests {
124125 case multi( _ variable: Bool , val: Int , String = " text " )
125126 }
126127
128+ @Test func coding( ) async throws {
129+ let encoded = try JSONEncoder ( ) . encode ( SomeEnum . bool ( false ) )
130+ let expected = try JSONSerialization . data ( withJSONObject: [ " bool " : [ : ] ] )
131+ #expect( encoded == expected)
132+ let decoded = try JSONDecoder ( ) . decode ( SomeEnum . self, from: encoded)
133+ switch decoded {
134+ case SomeEnum . bool ( true ) : break
135+ default : Issue . record ( " Incorrect default value " )
136+ }
137+ }
138+
127139 @Test
128140 func expansion( ) throws {
129141 assertMacroExpansion (
@@ -234,6 +246,17 @@ struct IgnoreInitializedTests {
234246 case multi( _ variable: Bool , val: Int , String = " text " )
235247 }
236248
249+ @Test func coding( ) async throws {
250+ let encoded = try JSONEncoder ( ) . encode ( SomeEnum . int ( val: 0 ) )
251+ let expected = try JSONSerialization . data ( withJSONObject: [ " altInt " : [ : ] ] )
252+ #expect( encoded == expected)
253+ let decoded = try JSONDecoder ( ) . decode ( SomeEnum . self, from: encoded)
254+ switch decoded {
255+ case SomeEnum . int ( 6 ) : break
256+ default : Issue . record ( " Incorrect default value " )
257+ }
258+ }
259+
237260 @Test
238261 func expansion( ) throws {
239262 assertMacroExpansion (
You can’t perform that action at this time.
0 commit comments