Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Base.copy(::Properties) #995

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function Base.close(obj::Properties)
end

Base.isvalid(obj::Properties) = obj.id != -1 && API.h5i_is_valid(obj)
Base.copy(obj::P) where {P <: Properties} = P(HDF5.API.h5p_copy(obj.id))

# By default, properties objects are only initialized lazily
function init!(prop::P) where {P<:Properties}
Expand Down
8 changes: 8 additions & 0 deletions test/properties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,20 @@ h5open(fn, "w";

@test acpl.char_encoding == :utf8

# Test auto-initialization of property lists on get
dcpl2 = HDF5.DatasetCreateProperties() # uninitialized
@test dcpl2.id < 1 # 0 or -1
@test !isvalid(dcpl2)
@test dcpl2.alloc_time == :late
@test isvalid(dcpl2)

# Test H5Pcopy
dapl2 = copy(dapl)
@test dapl2.id != dapl.id
@test dapl2.virtual_prefix == dapl.virtual_prefix
dapl2.virtual_prefix = "somewhere_else"
@test dapl2.virtual_prefix != dapl.virtual_prefix

nothing
end

Expand Down