mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
Refactored types test.
This commit is contained in:
parent
2f9c4f85b7
commit
93641eb2d6
@ -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)
|
||||
SET(TESTS t_nc tst_small tst_misc tst_norm tst_names tst_nofill tst_nofill2 tst_nofill3 tst_meta tst_inq_type)
|
||||
|
||||
IF(NOT HAVE_BASH)
|
||||
SET(TESTS ${TESTS} tst_atts3)
|
||||
|
@ -14,12 +14,12 @@ 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
|
||||
unlim.nc tst_inq_type.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_meta tst_inq_type
|
||||
|
||||
if USE_NETCDF4
|
||||
TESTPROGRAMS += tst_atts tst_put_vars
|
||||
@ -93,7 +93,7 @@ EXTRA_DIST = test_get.m4 test_put.m4 run_valgrind_tests.sh \
|
||||
run_diskless.sh run_diskless2.sh run_mmap.sh run_pnetcdf_test.sh
|
||||
|
||||
# ref_tst_diskless2.cdl is for diff comparison and to produce tst_diskless2.c
|
||||
EXTRA_DIST += ref_tst_diskless2.cdl CMakeLists.txt
|
||||
EXTRA_DIST += ref_tst_diskless2.cdl CMakeLists.txt tst_types.c
|
||||
|
||||
# Only clean these on mainatiner-clean, because they require m4 to
|
||||
# regenerate.
|
||||
|
52
nc_test/tst_inq_type.c
Normal file
52
nc_test/tst_inq_type.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* This is part of the netCDF package. Copyright 2016 University
|
||||
Corporation for Atmospheric Research/Unidata See COPYRIGHT file for
|
||||
conditions of use. See www.unidata.ucar.edu for more info.
|
||||
|
||||
Test nc_inq_type
|
||||
|
||||
Added in support of https://github.com/Unidata/netcdf/issues/240
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
#include <nc_tests.h>
|
||||
#include <netcdf.h>
|
||||
|
||||
#ifdef USE_PNETCDF
|
||||
#include <netcdf_par.h>
|
||||
#endif
|
||||
|
||||
#define FILE_NAME "tst_inq_type.nc"
|
||||
|
||||
void
|
||||
check_err(const int stat, const int line, const char *file) {
|
||||
if (stat != NC_NOERR) {
|
||||
(void)fprintf(stderr,"line %d of %s: %s\n", line, file, nc_strerror(stat));
|
||||
fflush(stderr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int ncid=0;
|
||||
|
||||
printf("\n* Testing nc_inq_type\n");
|
||||
|
||||
if(nc_create(FILE_NAME,NC_WRITE,&ncid)) ERR;
|
||||
|
||||
printf("\t* Testing NC_INT:\t");
|
||||
if(nc_inq_type(0,NC_INT,NULL,NULL))ERR;
|
||||
else printf("success.\n");
|
||||
|
||||
printf("\t* Testing NC_INT64:\t");
|
||||
if(nc_inq_type(0,NC_INT64,NULL,NULL))ERR;
|
||||
else printf("success.\n");
|
||||
|
||||
printf("* Finished.\n");
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user