diff --git a/include/nc_tests.h b/include/nc_tests.h index 731123616..8675bb91d 100644 --- a/include/nc_tests.h +++ b/include/nc_tests.h @@ -36,7 +36,6 @@ fflush(stdout); /* Make sure our stdout is synced with stderr. */ \ err++; \ fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \ __FILE__, __LINE__); \ -abort(); \ } while (0) /* This macro prints an error message with line number and name of diff --git a/libsrc/dim.c b/libsrc/dim.c index 523f2cb88..9968dba96 100644 --- a/libsrc/dim.c +++ b/libsrc/dim.c @@ -396,7 +396,8 @@ NC3_inq_dimid(int ncid, const char *name, int *dimid_ptr) if(dimid == -1) return NC_EBADDIM; - *dimid_ptr = dimid; + if (dimid_ptr) + *dimid_ptr = dimid; return NC_NOERR; } diff --git a/nctest/tst_rename.c b/nctest/tst_rename.c index 0e42c2bbf..afaa0ab9a 100644 --- a/nctest/tst_rename.c +++ b/nctest/tst_rename.c @@ -206,15 +206,13 @@ int main(int argc, char **argv) { printf("\n*** Testing v3/v4 API versions of some v2 tests.\n"); -#ifdef EXTRA_TESTS printf("*** testing simple dim rename..."); { #define PP1 "pp" #define PP1_SIZE 7 #define P1_NAME "p" - int ncid, pp_dimid, qq_dimid, dimid_in; - char name_in[NC_MAX_NAME + 1]; + int ncid, pp_dimid, dimid_in; /* Create a file with one dimension. */ if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR; @@ -228,40 +226,40 @@ main(int argc, char **argv) if (nc_close(ncid)) ERR; } SUMMARIZE_ERR; -#endif /* EXTRA_TESTS */ -/* printf("*** testing dim rename from nctest..."); */ -/* { */ -/* #define PP "pp" */ -/* #define PP_SIZE 7 */ -/* #define QQ "qq" */ -/* #define QQ_SIZE 10 */ -/* #define NEW_NAME "new_name" */ -/* #define ANOTHER_NAME "another_name" */ -/* #define P_NAME "p" */ + printf("*** testing dim rename from nctest..."); + { +#define PP "pp" +#define PP_SIZE 7 +#define QQ "qq" +#define QQ_SIZE 10 +#define NEW_NAME "new_name" +#define ANOTHER_NAME "another_name" +#define P_NAME "p" -/* int ncid, pp_dimid, qq_dimid, dimid_in; */ -/* char name_in[NC_MAX_NAME + 1]; */ + int ncid, pp_dimid, qq_dimid, dimid_in; + char name_in[NC_MAX_NAME + 1]; -/* /\* Create the same file as nctest.c does. *\/ */ -/* if (create_file()) ERR; */ + /* Create the same file as nctest.c does. */ + if (create_file()) ERR; -/* /\* Open it and test renames of dimensions. *\/ */ -/* if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; */ -/* if (nc_redef(ncid)) ERR; */ -/* if (nc_def_dim(ncid, PP, PP_SIZE, &pp_dimid)) ERR; */ -/* if (nc_def_dim(ncid, QQ, QQ_SIZE, &qq_dimid)) ERR; */ -/* if (nc_rename_dim(ncid, pp_dimid, NEW_NAME)) ERR; */ -/* if (nc_inq_dimname(ncid, pp_dimid, name_in)) ERR; */ -/* if (strcmp(NEW_NAME, name_in)) ERR; */ -/* if (nc_rename_dim(ncid, pp_dimid, QQ) != NC_ENAMEINUSE) ERR; */ -/* if (nc_rename_dim(ncid, -1, ANOTHER_NAME) != NC_EBADDIM) ERR; */ -/* if (nc_rename_dim(ncid, 12, ANOTHER_NAME) != NC_EBADDIM) ERR; */ -/* if (nc_enddef(ncid)) ERR; */ -/* if (nc_rename_dim(ncid, pp_dimid, P_NAME)) ERR; */ -/* if (nc_inq_dimid(ncid, P_NAME, dimid_in)) ERR; */ -/* if (dimid_in != pp_dimid) ERR; */ -/* if (nc_close(ncid)) ERR; */ -/* } */ -/* SUMMARIZE_ERR; */ + /* Open it and test renames of dimensions. */ + if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR; + if (nc_redef(ncid)) ERR; + if (nc_def_dim(ncid, PP, PP_SIZE, &pp_dimid)) ERR; + if (nc_def_dim(ncid, QQ, QQ_SIZE, &qq_dimid)) ERR; + if (nc_rename_dim(ncid, pp_dimid, NEW_NAME)) ERR; + if (nc_inq_dimname(ncid, pp_dimid, name_in)) ERR; + if (strcmp(NEW_NAME, name_in)) ERR; + if (nc_rename_dim(ncid, pp_dimid, QQ) != NC_ENAMEINUSE) ERR; + if (nc_rename_dim(ncid, -1, ANOTHER_NAME) != NC_EBADDIM) ERR; + if (nc_rename_dim(ncid, 12, ANOTHER_NAME) != NC_EBADDIM) ERR; + if (nc_enddef(ncid)) ERR; + if (nc_rename_dim(ncid, pp_dimid, P_NAME)) ERR; + if (nc_inq_dimid(ncid, P_NAME, &dimid_in)) ERR; + if (dimid_in != pp_dimid) ERR; + if (nc_inq_dimid(ncid, P_NAME, NULL)) ERR; + if (nc_close(ncid)) ERR; + } + SUMMARIZE_ERR; FINAL_RESULTS; }