Skip to content

Commit 1a5999a

Browse files
committed
TestNSDictionary: Add encoding and decoding test for NSCoding
1 parent 7db2d82 commit 1a5999a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

TestFoundation/TestNSDictionary.swift

+8
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ class TestNSDictionary : XCTestCase {
255255
XCTAssertEqual(dictionary[3 as NSNumber] as? String, "k")
256256
}
257257

258+
func test_NSCoding() {
259+
let original: NSDictionary = ["foo": "bar"]
260+
let encodedData = NSKeyedArchiver.archivedData(withRootObject: original)
261+
let decoded = NSKeyedUnarchiver.unarchiveObject(with: encodedData) as! NSDictionary
262+
XCTAssertEqual(original, decoded, "Archived then unarchived `NSDictionary` must be equal.")
263+
}
264+
258265
static var allTests: [(String, (TestNSDictionary) -> () throws -> Void)] {
259266
return [
260267
("test_BasicConstruction", test_BasicConstruction),
@@ -270,6 +277,7 @@ class TestNSDictionary : XCTestCase {
270277
("test_valueForKey", test_valueForKey),
271278
("test_valueForKeyWithNestedDict", test_valueForKeyWithNestedDict),
272279
("test_sharedKeySets", test_sharedKeySets),
280+
("test_NSCoding", test_NSCoding),
273281
]
274282
}
275283
}

0 commit comments

Comments
 (0)