File: tst_elatefill.c

package info (click to toggle)
netcdf 1%3A4.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 104,952 kB
  • sloc: ansic: 228,683; sh: 10,980; yacc: 2,561; makefile: 1,319; lex: 1,173; xml: 173; awk: 2
file content (44 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* This is part of the netCDF package. Copyright 2018 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 <stdio.h>
#include <netcdf.h>

#define FILE_NAME "tst_elatefill.nc"

#define ERR_CHK {if(err!=NC_NOERR)printf("Error at line %d: %s\n",__LINE__,nc_strerror(err));}

int
main(int argc, char **argv)
{
    int ncid, dimid, varid, err;
    int fillv;

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

    err = nc_redef(ncid); ERR_CHK;

    /* 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_CHK;
    return 0;
}