Skip to content

Commit 475c209

Browse files
committed
[stdlib] Improve unit test coverage of Set.Set
Systematically test also set algebra: * with empty sets on both sides * inverse operation
1 parent f5ba89d commit 475c209

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

validation-test/stdlib/Set.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,7 +2861,9 @@ SetTestSuite.test("isSubsetOf.Set.Set") {
28612861
let s2 = Set([1010, 2020, 3030])
28622862
expectTrue(Set<Int>().isSubset(of: s1))
28632863
expectFalse(s1.isSubset(of: Set<Int>()))
2864+
expectTrue(Set<Int>().isSubset(of: Set<Int>()))
28642865
expectTrue(s1.isSubset(of: s1))
2866+
expectFalse(s1.isSubset(of: s2))
28652867
expectTrue(s2.isSubset(of: s1))
28662868
}
28672869

@@ -2874,9 +2876,13 @@ SetTestSuite.test("isSubsetOf.Set.Sequence") {
28742876

28752877
SetTestSuite.test("isStrictSubsetOf.Set.Set") {
28762878
let s1 = Set([1010, 2020, 3030, 4040, 5050, 6060])
2879+
let s2 = Set([1010, 2020, 3030])
28772880
expectTrue(Set<Int>().isStrictSubset(of: s1))
28782881
expectFalse(s1.isStrictSubset(of: Set<Int>()))
2882+
expectFalse(Set<Int>().isStrictSubset(of: Set<Int>()))
28792883
expectFalse(s1.isStrictSubset(of: s1))
2884+
expectFalse(s1.isStrictSubset(of: s2))
2885+
expectTrue(s2.isStrictSubset(of: s1))
28802886
}
28812887

28822888
SetTestSuite.test("isStrictSubsetOf.Set.Sequence") {
@@ -2891,9 +2897,10 @@ SetTestSuite.test("isSupersetOf.Set.Set") {
28912897
let s2 = Set([1010, 2020, 3030])
28922898
expectTrue(s1.isSuperset(of: Set<Int>()))
28932899
expectFalse(Set<Int>().isSuperset(of: s1))
2900+
expectTrue(Set<Int>().isSuperset(of: Set<Int>()))
28942901
expectTrue(s1.isSuperset(of: s1))
28952902
expectTrue(s1.isSuperset(of: s2))
2896-
expectFalse(Set<Int>().isSuperset(of: s1))
2903+
expectFalse(s2.isSuperset(of: s1))
28972904
}
28982905

28992906
SetTestSuite.test("isSupersetOf.Set.Sequence") {
@@ -2906,13 +2913,15 @@ SetTestSuite.test("isSupersetOf.Set.Sequence") {
29062913
expectFalse(Set<Int>().isSuperset(of: s1))
29072914
}
29082915

2909-
SetTestSuite.test("strictSuperset.Set.Set") {
2916+
SetTestSuite.test("isStrictSuperset.Set.Set") {
29102917
let s1 = Set([1010, 2020, 3030, 4040, 5050, 6060])
29112918
let s2 = Set([1010, 2020, 3030])
29122919
expectTrue(s1.isStrictSuperset(of: Set<Int>()))
29132920
expectFalse(Set<Int>().isStrictSuperset(of: s1))
2921+
expectFalse(Set<Int>().isStrictSuperset(of: Set<Int>()))
29142922
expectFalse(s1.isStrictSuperset(of: s1))
29152923
expectTrue(s1.isStrictSuperset(of: s2))
2924+
expectFalse(s2.isStrictSuperset(of: s1))
29162925
}
29172926

29182927
SetTestSuite.test("strictSuperset.Set.Sequence") {

0 commit comments

Comments
 (0)