2011-03-15 18:19:08 +08:00
|
|
|
/* This is part of the netCDF package.
|
2018-12-07 06:27:32 +08:00
|
|
|
Copyright 2018 University Corporation for Atmospheric Research/Unidata
|
2011-03-15 18:19:08 +08:00
|
|
|
See COPYRIGHT file for conditions of use.
|
|
|
|
|
2016-10-22 03:24:40 +08:00
|
|
|
Test netcdf files a bit.
|
2011-03-15 18:19:08 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <nc_tests.h>
|
2016-10-22 03:24:40 +08:00
|
|
|
#include "err_macros.h"
|
2011-03-15 18:19:08 +08:00
|
|
|
#include "netcdf.h"
|
|
|
|
|
2017-11-09 22:21:00 +08:00
|
|
|
#define FILE_NAME "tst_files5.nc"
|
2011-03-15 18:19:08 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
printf("\n*** Testing netcdf file functions.\n");
|
|
|
|
printf("*** Checking the new inq_path function...");
|
|
|
|
{
|
|
|
|
int ncid;
|
|
|
|
size_t path_len;
|
|
|
|
char path_in[NC_MAX_NAME + 1] = "";
|
|
|
|
|
|
|
|
/* Test with classic file create. */
|
|
|
|
if (nc_create(FILE_NAME, 0, &ncid)) ERR;
|
|
|
|
if (nc_inq_path(ncid, &path_len, path_in)) ERR;
|
|
|
|
if (path_len != strlen(FILE_NAME) || strcmp(path_in, FILE_NAME)) ERR;
|
|
|
|
if (nc_close(ncid)) ERR;
|
|
|
|
strcpy(path_in, "");
|
|
|
|
path_len = 0;
|
|
|
|
|
|
|
|
/* Test with classic file open. */
|
|
|
|
if (nc_open(FILE_NAME, 0, &ncid)) ERR;
|
|
|
|
if (nc_inq_path(ncid, &path_len, path_in)) ERR;
|
|
|
|
if (path_len != strlen(FILE_NAME) || strcmp(path_in, FILE_NAME)) ERR;
|
|
|
|
if (nc_close(ncid)) ERR;
|
|
|
|
strcpy(path_in, "");
|
|
|
|
|
|
|
|
/* Test with netCDF-4 create. */
|
|
|
|
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
|
|
|
if (nc_inq_path(ncid, &path_len, path_in)) ERR;
|
|
|
|
if (path_len != strlen(FILE_NAME) || strcmp(path_in, FILE_NAME)) ERR;
|
|
|
|
if (nc_close(ncid)) ERR;
|
|
|
|
strcpy(path_in, "");
|
|
|
|
path_len = 0;
|
|
|
|
|
|
|
|
/* Test with classic file open. */
|
|
|
|
if (nc_open(FILE_NAME, 0, &ncid)) ERR;
|
|
|
|
if (nc_inq_path(ncid, &path_len, path_in)) ERR;
|
|
|
|
if (path_len != strlen(FILE_NAME) || strcmp(path_in, FILE_NAME)) ERR;
|
|
|
|
if (nc_close(ncid)) ERR;
|
|
|
|
strcpy(path_in, "");
|
|
|
|
path_len = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
SUMMARIZE_ERR;
|
|
|
|
FINAL_RESULTS;
|
|
|
|
}
|