Skip to content

Commit

Permalink
add missing test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed May 26, 2018
1 parent 6a53c65 commit 1d78f79
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/test_corner_cases.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Base.Test
fname = tempname()

# known quirks

NCDatasets.Dataset(fname,"c") do ds

ds.attrib["single_element"] = [1]

ds.attrib["vector_of_chars"] = ['a','b','c']

ds.attrib["single_char"] = 'a'

# issue 12
str = "some_string_with_null\0"
ccall((:nc_put_att,NCDatasets.libnetcdf),Cint,
(Cint,Cint,Cstring,NCDatasets.nc_type,Csize_t,Ptr{Void}),
ds.ncid,NCDatasets.NC_GLOBAL,"attrib",NCDatasets.NC_CHAR,length(str),pointer.(str))

end

NCDatasets.Dataset(fname,"r") do ds
# same behaviour in python netCDF4 1.3.1
@test ds.attrib["single_element"] == 1

# no chars in python and numpy.charray are not supported
@test ds.attrib["vector_of_chars"] == "abc"

# all chars are strings in python
@test ds.attrib["single_char"] == "a"

# issue 12
@test ds.attrib["attrib"] == "some_string_with_null"
end

0 comments on commit 1d78f79

Please sign in to comment.