|
245 | 245 | @test typeof(rred) == typeof(r)
|
246 | 246 | @test length(rred) == 1
|
247 | 247 | @test first(rred) == first(r)
|
| 248 | + |
| 249 | + @testset "conversion to AbstractUnitRange" begin |
| 250 | + r = IdOffsetRange(1:2) |
| 251 | + @test AbstractUnitRange{Int}(r) === r |
| 252 | + r2 = IdOffsetRange(big(1):big(2)) |
| 253 | + @test AbstractUnitRange{Int}(r2) === r |
| 254 | + @test AbstractUnitRange{BigInt}(r2) === r2 |
| 255 | + |
| 256 | + if v"1.5" < VERSION |
| 257 | + @test OrdinalRange{Int,Int}(r2) === r |
| 258 | + @test OrdinalRange{BigInt,BigInt}(r2) === r2 |
| 259 | + end |
| 260 | + end |
248 | 261 | end
|
249 | 262 |
|
250 | 263 | # used in testing the constructor
|
@@ -395,12 +408,20 @@ Base.convert(::Type{Int}, a::WeirdInteger) = a
|
395 | 408 | @test_throws OverflowError OffsetArray(ao, (-2, )) # convinient constructor accumulate offsets
|
396 | 409 | @test_throws OverflowError OffsetVector(1:0, typemax(Int))
|
397 | 410 | @test_throws OverflowError OffsetVector(OffsetVector(1:0, 0), typemax(Int))
|
| 411 | + @test_throws OverflowError OffsetArray(zeros(Int, typemax(Int):typemax(Int)), 2) |
398 | 412 |
|
399 | 413 | @testset "OffsetRange" begin
|
400 |
| - local r = 1:100 |
401 |
| - local a = OffsetVector(r, 4) |
402 |
| - @test first(r) in a |
403 |
| - @test !(last(r) + 1 in a) |
| 414 | + for r in Any[1:100, big(1):big(2)] |
| 415 | + a = OffsetVector(r, 4) |
| 416 | + @test first(r) in a |
| 417 | + @test !(last(r) + 1 in a) |
| 418 | + end |
| 419 | + |
| 420 | + @testset "BigInt axes" begin |
| 421 | + r = OffsetArray(1:big(2)^65, 4000) |
| 422 | + @test eltype(r) === BigInt |
| 423 | + @test axes(r, 1) == (big(1):big(2)^65) .+ 4000 |
| 424 | + end |
404 | 425 | end
|
405 | 426 |
|
406 | 427 | # disallow OffsetVector(::Array{<:Any, N}, offsets) where N != 1
|
|
765 | 786 | @test eachindex(IndexLinear(), S) == eachindex(IndexLinear(), A0)
|
766 | 787 | A = ones(5:6)
|
767 | 788 | @test eachindex(IndexLinear(), A) === axes(A, 1)
|
| 789 | + |
| 790 | + A = OffsetArray(big(1):big(2), 1) |
| 791 | + B = OffsetArray(1:2, 1) |
| 792 | + @test CartesianIndices(A) == CartesianIndices(B) |
| 793 | + @test LinearIndices(A) == LinearIndices(B) |
| 794 | + @test eachindex(A) == eachindex(B) |
768 | 795 | end
|
769 | 796 |
|
770 | 797 | @testset "Scalar indexing" begin
|
|
0 commit comments