Skip to content

Commit 9ad0048

Browse files
Robert PietaRobert Pieta
authored andcommitted
Test case for NSSet.isSubset
1 parent 53e0987 commit 9ad0048

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

TestFoundation/TestNSSet.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class TestNSSet : XCTestCase {
2525
("test_CountedSetRemoveObject", test_CountedSetRemoveObject),
2626
("test_CountedSetCopying", test_CountedSetCopying),
2727
("test_mutablesetWithDictionary", test_mutablesetWithDictionary),
28+
("test_Subsets", test_Subsets)
2829
]
2930
}
3031

@@ -224,4 +225,16 @@ class TestNSSet : XCTestCase {
224225
dictionary.setObject(aSet, forKey: key)
225226
XCTAssertNotNil(dictionary.description) //should not crash
226227
}
228+
229+
func test_Subsets() {
230+
let set = NSSet(array: ["foo", "bar", "baz"])
231+
let otherSet = NSSet(array: ["foo", "bar"])
232+
let otherOtherSet = Set<AnyHashable>(["foo", "bar", "baz", "123"])
233+
let newSet = Set<AnyHashable>(["foo", "bin"])
234+
XCTAssert(otherSet.isSubset(of: set as! Set<AnyHashable>))
235+
XCTAssertFalse(set.isSubset(of: otherSet as! Set<AnyHashable>))
236+
XCTAssert(set.isSubset(of: otherOtherSet))
237+
XCTAssert(otherSet.isSubset(of: otherOtherSet))
238+
XCTAssertFalse(newSet.isSubset(of: otherSet as! Set<AnyHashable>))
239+
}
227240
}

0 commit comments

Comments
 (0)