Skip to content

Commit

Permalink
Adding test in support of #384
Browse files Browse the repository at this point in the history
  • Loading branch information
WardF committed Mar 29, 2017
1 parent 4736444 commit 6b036cf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nc_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TARGET_LINK_LIBRARIES(nc_test
)

# Some extra stand-alone tests
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type)
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type tst_elatefill)

IF(NOT HAVE_BASH)
SET(TESTS ${TESTS} tst_atts3)
Expand Down
4 changes: 2 additions & 2 deletions nc_test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ tst_*.nc t_nc.nc large_files.nc quick_large_files.nc \
tst_diskless.nc tst_diskless2.nc \
tst_diskless3.nc tst_diskless3_file.cdl tst_diskless3_memory.cdl \
tst_diskless4.cdl tst_diskless4.nc tst_formatx.nc nc_test_cdf5.nc \
unlim.nc tst_inq_type.nc
unlim.nc tst_inq_type.nc tst_elatefill.nc

# These are the tests which are always run.
TESTPROGRAMS = t_nc tst_small nc_test tst_misc tst_norm \
tst_names tst_nofill tst_nofill2 tst_nofill3 tst_atts3 \
tst_meta tst_inq_type tst_utf8_validate tst_utf8_phrases

if USE_NETCDF4
TESTPROGRAMS += tst_atts tst_put_vars
TESTPROGRAMS += tst_atts tst_put_vars tst_elatefill
endif

if USE_PNETCDF
Expand Down
43 changes: 43 additions & 0 deletions nc_test/tst_elatefill.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* This is part of the netCDF package. Copyright 2017 University
Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
conditions of use. See www.unidata.ucar.edu for more info.
Test proper elatefill return when fillvalue is assigned outside of
the initial define.
Contributed by wkliao, see the following for more information:
* https://github.com/Unidata/netcdf-c/issues/384
* https://github.com/Unidata/netcdf-c/pull/387
* https://github.com/Unidata/netcdf-c/issues/390
*/

#include "config.h"
#include <nc_tests.h>
#include "err_macros.h"
#include <stdio.h>
#include <netcdf.h>

#define FILE_NAME "tst_elatefill.nc"

int
main(int argc, char **argv)
{
int ncid, dimid, varid, err;
int no_fill, fillv, buf[10];

err = nc_create(FILE_NAME, NC_NETCDF4, &ncid); ERR;
err = nc_def_dim(ncid, "dim", 10, &dimid); ERR;
err = nc_def_var(ncid, "var", NC_INT, 1, &dimid, &varid); ERR;
err = nc_enddef(ncid); ERR;

err = nc_redef(ncid); ERR;

/* try put attribute _FillValue and expect NC_ELATEFILL */
fillv = 9;
err = nc_put_att_int(ncid, varid, _FillValue, NC_INT, 1, &fillv);
if (err != NC_ELATEFILL)
printf("line %d expecting NC_ELATEFILL but got %d\n",__LINE__,err);
err = nc_close(ncid); ERR;
return 0;
}

0 comments on commit 6b036cf

Please sign in to comment.