2019-08-09 23:31:24 +08:00
|
|
|
/* This is part of the netCDF package. Copyright 2005-2019 University
|
|
|
|
Corporation for Atmospheric Research/Unidata. See COPYRIGHT file
|
|
|
|
for conditions of use.
|
|
|
|
|
|
|
|
Test list functions in nclistmgr.c.
|
|
|
|
|
|
|
|
Ed Hartnett, 8/10/19
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <nc_tests.h>
|
2019-08-09 23:38:40 +08:00
|
|
|
#include "nc.h"
|
2019-08-10 03:37:54 +08:00
|
|
|
#include "ncdispatch.h"
|
2019-08-09 23:31:24 +08:00
|
|
|
#include "err_macros.h"
|
|
|
|
|
2019-08-10 03:49:52 +08:00
|
|
|
/* An integer value to use in testing. */
|
|
|
|
#define TEST_VAL_42 42
|
|
|
|
|
2019-08-09 23:31:24 +08:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2019-08-10 01:13:55 +08:00
|
|
|
printf("\n*** Testing netcdf internal NC list functions.\n");
|
|
|
|
printf("Testing NC list functions with no open files...");
|
|
|
|
{
|
|
|
|
/* These are cases where there are no files, or NULL
|
|
|
|
* params. */
|
|
|
|
if (count_NCList()) ERR;
|
|
|
|
free_NCList();
|
|
|
|
if (find_in_NCList_by_name("nope")) ERR;
|
|
|
|
if (iterate_NCList(0, NULL)) ERR;
|
|
|
|
}
|
|
|
|
SUMMARIZE_ERR;
|
|
|
|
printf("Testing adding to NC list...");
|
|
|
|
{
|
2019-08-10 03:49:52 +08:00
|
|
|
/* int ncid; */
|
|
|
|
NC *ncp, *ncp2;
|
2019-08-10 03:37:54 +08:00
|
|
|
int mode = 0;
|
|
|
|
NCmodel model;
|
|
|
|
char path[] = {"file.nc"};
|
|
|
|
int ret;
|
2019-08-09 23:31:24 +08:00
|
|
|
|
2019-08-10 03:37:54 +08:00
|
|
|
/* Create the NC* instance and insert its dispatcher and model. */
|
|
|
|
if ((ret = new_NC(NULL, path, mode, &model, &ncp))) ERR;
|
2019-08-10 01:13:55 +08:00
|
|
|
|
2019-08-10 03:37:54 +08:00
|
|
|
/* Add to list of known open files and define ext_ncid. */
|
|
|
|
add_to_NCList(ncp);
|
|
|
|
|
2019-08-10 03:49:52 +08:00
|
|
|
/* These won't work! */
|
|
|
|
if (find_in_NCList(TEST_VAL_42)) ERR;
|
|
|
|
if (find_in_NCList_by_name("nope")) ERR;
|
|
|
|
if ((ret = iterate_NCList(2, &ncp2))) ERR;
|
|
|
|
|
|
|
|
/* Find it in the list. */
|
|
|
|
if (!(ncp2 = find_in_NCList(ncp->ext_ncid))) ERR;
|
|
|
|
if (!(ncp2 = find_in_NCList_by_name(path))) ERR;
|
|
|
|
if ((ret = iterate_NCList(1, &ncp2))) ERR;
|
|
|
|
if (count_NCList() != 1) ERR;
|
|
|
|
|
|
|
|
/* Delete it. */
|
|
|
|
/* ncid = ncp->ext_ncid; */
|
|
|
|
/* free_NC(ncp); */
|
|
|
|
/* del_from_NCList(ncp); */
|
|
|
|
/* if (find_in_NCList(ncid)) ERR; */
|
|
|
|
|
2019-08-10 03:37:54 +08:00
|
|
|
/* Where is the allocated memory being freed? */
|
2019-08-10 01:13:55 +08:00
|
|
|
}
|
|
|
|
SUMMARIZE_ERR;
|
|
|
|
FINAL_RESULTS;
|
2019-08-09 23:31:24 +08:00
|
|
|
}
|