Skip to content

Commit 4c84b0c

Browse files
authored
AbstractSet tests (#34619)
1 parent 3058112 commit 4c84b0c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/sets.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ end
151151
s = Set([1])
152152
@test isequal(sizehint!(s, 10), Set([1]))
153153
@test isequal(empty!(s), Set())
154+
s2 = GenericSet(s)
155+
sizehint!(s2, 10)
156+
@test s2 == GenericSet(s)
154157
end
155158
@testset "rehash!" begin
156159
# Use a pointer type to have defined behavior for uninitialized
@@ -213,6 +216,9 @@ end
213216
# union must uniquify
214217
@test union([1, 2, 1]) == union!([1, 2, 1]) == [1, 2]
215218
@test union([1, 2, 1], [2, 2]) == union!([1, 2, 1], [2, 2]) == [1, 2]
219+
s2 = Set([nothing])
220+
union!(s2, [nothing])
221+
@test s2 == Set([nothing])
216222
end
217223

218224
@testset "intersect" begin
@@ -369,6 +375,11 @@ end
369375
@test !issubset(d3, d2)
370376
@test issubset(d1, d3)
371377
@test issubset(d2, d3)
378+
379+
# no fast in, long enough container
380+
@test issubset(Set(Bool[]), rand(Bool, 100)) == true
381+
# neither has a fast in, right doesn't have a length
382+
@test isdisjoint([1, 3, 5, 7, 9], Iterators.filter(iseven, 1:10))
372383
end
373384

374385
@testset "unique" begin
@@ -653,6 +664,10 @@ end
653664
@test B > A
654665
end
655666
end
667+
# first doesn't have length
668+
@test issetequal(Iterators.filter(iseven, 1:10), [2, 4, 6, 8, 10])
669+
# both don't have length
670+
@test issetequal(Iterators.filter(iseven, 1:10), Iterators.filter(iseven, 1:10))
656671
end
657672

658673
@testset "optimized union! with max_values" begin

0 commit comments

Comments
 (0)