File: tst_files5.c

package info (click to toggle)
netcdf-parallel 1%3A4.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 101,668 kB
  • sloc: ansic: 200,241; sh: 10,807; yacc: 2,522; makefile: 1,306; lex: 1,153; xml: 173; awk: 2
file content (58 lines) | stat: -rw-r--r-- 1,739 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* This is part of the netCDF package.
   Copyright 2010 University Corporation for Atmospheric Research/Unidata
   See COPYRIGHT file for conditions of use.

   Test netcdf files a bit.
*/

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

#define FILE_NAME "tst_files5.nc"

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;
}