Skip to content

Commit 18f4d0a

Browse files
Jakob Nybo Andersenjakobnissen
authored andcommitted
Fixup: Tests
1 parent ca2a3c3 commit 18f4d0a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/basic.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ end
2424

2525
# Base.memoryindex exists in Julia 1.13 onwards.
2626
@static if VERSION < v"1.13"
27-
# Note: For zero-sized elements, this always returns 1:x.len, which may not be
28-
# the correct indices. However, the result is indistinguishable from the "correct"
29-
# result, so it doesn't matter
3027
function Base.parentindices(x::MemoryView)
3128
elz = Base.elsize(x)
3229
return if iszero(elz)

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ end
366366

367367
mem = MemoryView(view(Vector{String}(undef, 10), 5:7))
368368
@test parentindices(mem) == (5:7,)
369+
370+
mem = MemoryView(Vector{Nothing}(undef, 10))[4:7]
371+
@test parentindices(mem) == (4:7,)
372+
373+
struct ZeroSized end
374+
mem = MemoryView(Vector{ZeroSized}(undef, 8))[3:5]
375+
@test parentindices(mem) == (3:5,)
369376
end
370377

371378
@testset "Similar and empty" begin
@@ -755,6 +762,9 @@ end
755762
@test unsafe_from_parts(ref, 2) == [1, 3]
756763
@test isempty(unsafe_from_parts(ref, 0))
757764
@test mem isa MutableMemoryView{Int}
765+
766+
v2 = MemoryView([3, 1, 4])
767+
@test Base.cconvert(Ptr{Int}, v2) === v2.ref
758768
end
759769

760770
@testset "MemoryKind" begin

0 commit comments

Comments
 (0)