@@ -107,6 +107,8 @@ class TestNSKeyedArchiver : XCTestCase {
107
107
( " test_archive_uuid_bvref " , test_archive_uuid_byref) ,
108
108
( " test_archive_uuid_byvalue " , test_archive_uuid_byvalue) ,
109
109
( " test_archive_unhashable " , test_archive_unhashable) ,
110
+ ( " test_archiveRootObject_String " , test_archiveRootObject_String) ,
111
+ ( " test_archiveRootObject_URLRequest() " , test_archiveRootObject_URLRequest) ,
110
112
]
111
113
}
112
114
@@ -345,4 +347,29 @@ class TestNSKeyedArchiver : XCTestCase {
345
347
XCTFail ( " test_archive_unhashable, de-serialization error \( error) " )
346
348
}
347
349
}
350
+
351
+ func test_archiveRootObject_String( ) {
352
+ let filePath = NSTemporaryDirectory ( ) + " testdir \( NSUUID ( ) . uuidString) "
353
+ let result = NSKeyedArchiver . archiveRootObject ( " Hello " , toFile: filePath)
354
+ XCTAssertTrue ( result)
355
+ do {
356
+ try FileManager . default. removeItem ( atPath: filePath)
357
+ } catch {
358
+ XCTFail ( " Failed to clean up file " )
359
+ }
360
+ }
361
+
362
+ func test_archiveRootObject_URLRequest( ) {
363
+ let filePath = NSTemporaryDirectory ( ) + " testdir \( NSUUID ( ) . uuidString) "
364
+ let url = URL ( string: " http://swift.org " ) !
365
+ let request = URLRequest ( url: url) . _bridgeToObjectiveC ( )
366
+ let result = NSKeyedArchiver . archiveRootObject ( request, toFile: filePath)
367
+ XCTAssertTrue ( result)
368
+ do {
369
+ try FileManager . default. removeItem ( atPath: filePath)
370
+ } catch {
371
+ XCTFail ( " Failed to clean up file " )
372
+ }
373
+ }
374
+
348
375
}
0 commit comments