File tree 2 files changed +16
-0
lines changed 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,14 @@ final class PrefixedTests: XCTestCase {
71
71
XCTAssertNoThrow ( try JSONDecoder ( ) . decode ( InsensitiveUser . self, from: data) )
72
72
}
73
73
74
+ func testDecodeWithInvalidTypeUUID( ) {
75
+ let data = """
76
+ { " id " : " user_ABCD " }
77
+ """ . data ( using: . utf8) !
78
+
79
+ XCTAssertThrowsError ( try JSONDecoder ( ) . decode ( User . self, from: data) )
80
+ }
81
+
74
82
func testEncode( ) throws {
75
83
let int = Int . random ( in: 0 ... 9999 )
76
84
let user = User ( id: Prefixed ( base: int) )
Original file line number Diff line number Diff line change @@ -67,6 +67,14 @@ final class PrefixedUUIDTests: XCTestCase {
67
67
XCTAssertNoThrow ( try JSONDecoder ( ) . decode ( InsensitiveUser . self, from: data) )
68
68
}
69
69
70
+ func testDecodeWithInvalidType( ) {
71
+ let data = """
72
+ { " id " : " user_56C68C54 " }
73
+ """ . data ( using: . utf8) !
74
+
75
+ XCTAssertThrowsError ( try JSONDecoder ( ) . decode ( User . self, from: data) )
76
+ }
77
+
70
78
func testEncode( ) throws {
71
79
let uuid = UUID ( )
72
80
let user = User ( id: PrefixedUUID ( uuid: uuid) )
You can’t perform that action at this time.
0 commit comments