Skip to content

Commit 7453ef8

Browse files
PraneethJainbarche
authored andcommitted
test: StdUpperBound, StdLowerBound and StdBinarySearch
1 parent 3e537d5 commit 7453ef8

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

test/stdlib.jl

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ end
614614
@static if isdefined(StdLib, :HAS_RANGES)
615615

616616
@testset "STL algorithms" begin
617-
@testset "fill StdList" begin
617+
@testset "StdFill" begin
618618
v = StdList{Int64}()
619619
for x in 1:10
620620
push!(v, x)
@@ -623,9 +623,7 @@ end
623623
for x in v
624624
@test x == 1
625625
end
626-
end
627-
628-
@testset "fill StdForwardList" begin
626+
629627
v = StdForwardList{Int64}()
630628
for x in 1:10
631629
pushfirst!(v, x)
@@ -635,6 +633,37 @@ end
635633
@test x == 1
636634
end
637635
end
636+
637+
@testset "StdUpperBound and StdLowerBound" begin
638+
containers = (StdSet{Int64}(), StdMultiset{Int64}(), StdList{Int64}())
639+
for container in containers
640+
for i in 1:2:11
641+
push!(container, i)
642+
end
643+
end
644+
645+
for container in containers
646+
for val in container
647+
@test StdLib.iterator_value(StdLowerBound(container, val)) == val
648+
@test StdLib.iterator_value(StdUpperBound(container, val - 1)) == val
649+
end
650+
end
651+
end
652+
653+
@testset "StdBinarySearch" begin
654+
containers = (StdVector{Int64}(), StdDeque{Int64}(), StdSet{Int64}(), StdMultiset{Int64}(), StdList{Int64}())
655+
for container in containers
656+
for i in 1:2:11
657+
push!(container, i)
658+
end
659+
end
660+
661+
for container in containers
662+
for i in 1:11
663+
@test StdBinarySearch(container, i) == isodd(i)
664+
end
665+
end
666+
end
638667
end
639668

640669
end

0 commit comments

Comments
 (0)