|
149 | 149 | assert_in_interval(reverse(x), interval) |
150 | 150 | end |
151 | 151 | end |
| 152 | + |
| 153 | + @testset "searchsorted" begin |
| 154 | + x = [-10, 0, 1, 1 + eps(), 1.2, 1.5, 1.9, 2 - eps(), 2] |
| 155 | + @test searchsorted_interval(x, -Inf..Inf) == 1:9 |
| 156 | + i = Interval{:closed, :closed}(1, 2) |
| 157 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 3:9 |
| 158 | + i = Interval{:open , :closed}(1, 2) |
| 159 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 4:9 |
| 160 | + i = Interval{:closed, :open }(1, 2) |
| 161 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 3:8 |
| 162 | + i = Interval{:open , :open }(1, 2) |
| 163 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 4:8 |
| 164 | + i = Interval{:closed, :closed}(1, 1) |
| 165 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 3:3 |
| 166 | + i = Interval{:open , :closed}(1, 1) |
| 167 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 3:2 |
| 168 | + i = Interval{:closed, :open }(1, 1) |
| 169 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 3:2 |
| 170 | + i = Interval{:open , :open }(1, 1) |
| 171 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 3:2 |
| 172 | + i = Interval{:closed, :closed}(2, 1) |
| 173 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 9:8 |
| 174 | + i = Interval{:open , :closed}(2, 1) |
| 175 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 9:8 |
| 176 | + i = Interval{:closed, :open }(2, 1) |
| 177 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 9:8 |
| 178 | + i = Interval{:open , :open }(2, 1) |
| 179 | + @test searchsorted_interval(x, i) == findall(in(i),x) == 9:8 |
| 180 | + end |
152 | 181 | end |
0 commit comments