more test

This commit is contained in:
Ed Hartnett 2017-12-02 15:43:40 -07:00
parent ea63ff526f
commit 1cf8177f45
2 changed files with 51 additions and 7 deletions

View File

@ -1263,7 +1263,7 @@ nc_inq_var_chunking_ints(int ncid, int varid, int *contiguousp, int *chunksizesp
NULL, NULL, NULL, NULL, NULL);
/* Copy from size_t array. */
if (*contiguousp == NC_CHUNKED)
if (chunksizesp && var->contiguous == NC_CHUNKED)
for (i = 0; i < var->ndims; i++)
{
chunksizesp[i] = (int)cs[i];

View File

@ -13,6 +13,7 @@
#define FILE_NAME "tst_vars2.nc"
#define NUM_DIMS 1
#define NUM_VARS 2
#define DIM1_LEN NC_UNLIMITED
#define DIM1_NAME "Hoplites_Engaged"
#define VAR_NAME "Battle_of_Marathon"
@ -25,7 +26,7 @@ main(int argc, char **argv)
{
int ncid, dimids[NUM_DIMS];
int varid;
int nvars_in, varids_in[NUM_DIMS];
int nvars_in, varids_in[NUM_VARS];
signed char fill_value = 42, fill_value_in;
nc_type xtype_in;
size_t len_in;
@ -736,6 +737,7 @@ main(int argc, char **argv)
#define NDIMS5 1
#define DIM5_NAME "D5"
#define VAR_NAME5 "V5"
#define VAR_NAME5_1 "V5_1"
#define DIM5_LEN 1000
#define CACHE_SIZE 32000000
#define CACHE_NELEMS 1009
@ -745,7 +747,7 @@ main(int argc, char **argv)
#define CACHE_PREEMPTION2 .50
int dimids[NDIMS5], dimids_in[NDIMS5];
int varid;
int varid, varid1;
int ndims, nvars, natts, unlimdimid;
nc_type xtype_in;
char name_in[NC_MAX_NAME + 1];
@ -753,6 +755,8 @@ main(int argc, char **argv)
size_t chunksize[NDIMS5] = {5};
size_t bad_chunksize[NDIMS5] = {-5};
size_t chunksize_in[NDIMS5];
int chunksize_int[NDIMS5];
int chunksize_int_in[NDIMS5];
int storage_in;
size_t cache_size_in, cache_nelems_in;
float cache_preemption_in;
@ -830,6 +834,46 @@ main(int argc, char **argv)
if (data[i] != data_in[i])
ERR_RET;
/* These will not work due to bad paramters. */
if (nc_inq_var_chunking_ints(ncid + MILLION, 0, &storage_in,
chunksize_int_in) != NC_EBADID) ERR;
if (nc_inq_var_chunking_ints(ncid + TEST_VAL_42, 0, &storage_in,
chunksize_int_in) != NC_EBADID) ERR;
if (nc_inq_var_chunking_ints(ncid, -1, &storage_in,
chunksize_int_in) != NC_ENOTVAR) ERR;
if (nc_inq_var_chunking_ints(ncid, varid1 + 1, &storage_in,
chunksize_int_in) != NC_ENOTVAR) ERR;
if (nc_inq_var_chunking_ints(ncid, varid1 + TEST_VAL_42, &storage_in,
chunksize_int_in) != NC_ENOTVAR) ERR;
/* Now check with the fortran versions of the var_chunking. */
if (nc_inq_var_chunking_ints(ncid, 0, &storage_in, chunksize_int_in)) ERR;
for (d = 0; d < NDIMS5; d++)
if (chunksize_int_in[d] != chunksize[d]) ERR;
for (d = 0; d < NDIMS5; d++)
chunksize_int[d] = chunksize[d] * 2;
/* Check that some bad parameter values are rejected properly. */
if (nc_def_var_chunking_ints(ncid + MILLION, varid1, NC_CHUNKED,
chunksize_int) != NC_EBADID) ERR;
if (nc_def_var_chunking_ints(ncid + TEST_VAL_42, varid1, NC_CHUNKED,
chunksize_int) != NC_EBADID) ERR;
if (nc_def_var_chunking_ints(ncid, -1, NC_CHUNKED,
chunksize_int) != NC_ENOTVAR) ERR;
if (nc_def_var_chunking_ints(ncid, varid + 1, NC_CHUNKED,
chunksize_int) != NC_ENOTVAR) ERR;
if (nc_def_var_chunking_ints(ncid, varid + TEST_VAL_42, NC_CHUNKED,
chunksize_int) != NC_ENOTVAR) ERR;
if (nc_def_var_chunking_ints(ncid, varid, NC_CHUNKED, chunksize_int) != NC_ELATEDEF) ERR;
if (nc_redef(ncid)) ERR;
if (nc_def_var(ncid, VAR_NAME5_1, NC_INT, NDIMS5, dimids, &varid1)) ERR;
if (nc_def_var_chunking_ints(ncid, varid1, NC_CHUNKED, chunksize_int)) ERR;
if (nc_inq_var_chunking_ints(ncid, varid1, NULL, chunksize_int_in)) ERR;
for (d = 0; d < NDIMS5; d++)
if (chunksize_int_in[d] != chunksize[d] * 2) ERR;
if (nc_inq_var_chunking_ints(ncid, varid1, NULL, NULL)) ERR;
/* Check that some bad parameter values are rejected properly. */
if (nc_get_var_chunk_cache(ncid + MILLION, varid, &cache_size_in, &cache_nelems_in,
&cache_preemption_in) != NC_EBADID) ERR;
@ -837,7 +881,7 @@ main(int argc, char **argv)
&cache_preemption_in) != NC_EBADID) ERR;
if (nc_get_var_chunk_cache(ncid, varid + TEST_VAL_42, &cache_size_in, &cache_nelems_in,
&cache_preemption_in) != NC_ENOTVAR) ERR;
if (nc_get_var_chunk_cache(ncid, varid + 1, &cache_size_in, &cache_nelems_in,
if (nc_get_var_chunk_cache(ncid, varid1 + 1, &cache_size_in, &cache_nelems_in,
&cache_preemption_in) != NC_ENOTVAR) ERR;
if (nc_get_var_chunk_cache(ncid, -TEST_VAL_42, &cache_size_in, &cache_nelems_in,
&cache_preemption_in) != NC_ENOTVAR) ERR;
@ -866,11 +910,11 @@ main(int argc, char **argv)
/* Check stuff. */
if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
if (ndims != NDIMS5 || nvars != 1 || natts != 0 ||
if (ndims != NDIMS5 || nvars != 2 || natts != 0 ||
unlimdimid != -1) ERR;
if (nc_inq_varids(ncid, &nvars, varids_in)) ERR;
if (nvars != 1) ERR;
if (varids_in[0] != 0) ERR;
if (nvars != 2) ERR;
if (varids_in[0] != 0 || varids_in[1] != 1) ERR;
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims, dimids_in, &natts)) ERR;
if (strcmp(name_in, VAR_NAME5) || xtype_in != NC_INT || ndims != 1 || natts != 0 ||
dimids_in[0] != 0) ERR;