ncdf4a13/libsrc4/tst_lists.c File Reference

#include <netcdf.h>
#include <nc.h>
#include "nc4internal.h"
#include <nc_tests.h>

Include dependency graph for tst_lists.c:

Go to the source code of this file.

Defines

#define NAME   "lalala"
#define TYPE_NAME1   "crazy"
#define TYPE_NAME2   "silly"
#define TYPE_NAME1   "crazy"
#define TYPE_NAME2   "silly"

Functions

int main (int argc, char **argv)

Variables

NC_FILE_INFO_Tnc_file


Define Documentation

#define NAME   "lalala"
 

Definition at line 16 of file tst_lists.c.

Referenced by main().

#define TYPE_NAME1   "crazy"
 

#define TYPE_NAME1   "crazy"
 

#define TYPE_NAME2   "silly"
 

#define TYPE_NAME2   "silly"
 


Function Documentation

int main int  argc,
char **  argv
 

Definition at line 19 of file tst_lists.c.

References att_list_add(), att_list_del(), NC_GRP_INFO::children, ERR, file_list_add(), file_list_add_netcdf4(), file_list_del(), find_nc_file(), NAME, nc4_grp_list_add(), NC_FILE_INFO::nc4_info, nc_exit, nc_free, NC_GRP_INFO::nc_grpid, NC_MAX_NAME, NC_NETCDF4, NC_GRP_INFO::next, NC_GRP_INFO::parent, NC_HDF5_FILE_INFO_T::path, rec_find_grp(), rec_grp_del(), NC_HDF5_FILE_INFO_T::root_grp, SUMMARIZE_ERR, and total_err.

00020 {
00021    printf("\n*** Testing netcdf-4 internal list code.\n");
00022    printf("*** testing group list code...");
00023    {
00024       NC_GRP_INFO_T *g = NULL, *g1;
00025       NC_FILE_INFO_T *nc = NULL;
00026 
00027       /*nc_set_log_level(6);*/
00028 
00029       /* Add a file, then delete it. */
00030       if (file_list_add(0x00010000)) ERR;
00031       if (!(nc = find_nc_file(0x00010000))) ERR;
00032       file_list_del(nc);
00033       nc_exit();
00034 
00035       /* Add netcdf-4 structs, including the root group, then delete
00036        * them all. */
00037       if (file_list_add(0x00010000)) ERR;
00038       if (!(nc = find_nc_file(0x00010000))) ERR;
00039       if (file_list_add_netcdf4(nc, NAME, NC_NETCDF4)) ERR;
00040       if (!nc->nc4_info) ERR;
00041       if (strcmp(NAME, nc->nc4_info->path)) ERR;
00042       rec_grp_del(&nc->nc4_info->root_grp, nc->nc4_info->root_grp);
00043       nc_free(nc->nc4_info);
00044       file_list_del(nc);
00045       nc_exit();
00046 
00047       /* Add a child group to the root group. */
00048       if (file_list_add(0x00010000)) ERR;
00049       if (!(nc = find_nc_file(0x00010000))) ERR;
00050       if (file_list_add_netcdf4(nc, NAME, NC_NETCDF4)) ERR;
00051       if (nc4_grp_list_add(&nc->nc4_info->root_grp->children, 1, nc->nc4_info->root_grp, 
00052                            nc, "hohoho", &g1)) ERR;
00053       if (!(g = rec_find_grp(nc->nc4_info->root_grp, 1))) ERR;
00054       if (g->nc_grpid != 1) ERR;
00055       rec_grp_del(&nc->nc4_info->root_grp, nc->nc4_info->root_grp);
00056       nc_free(nc->nc4_info);
00057       file_list_del(nc);
00058       nc_exit();
00059    }
00060 
00061    SUMMARIZE_ERR;
00062    printf("*** testing file list code...");
00063 
00064    {
00065       NC_FILE_INFO_T *nc;
00066 
00067       if (find_nc_file(0)) ERR; 
00068       if (file_list_add(0x00000000)) ERR;
00069       if (file_list_add(0x00010000)) ERR;
00070       if (file_list_add(0x00020000)) ERR;
00071       if (!(nc = find_nc_file(0x00010000))) ERR;
00072       file_list_del(nc);
00073       if (find_nc_file(0x00010000)) ERR;
00074       if (!(nc = find_nc_file(0x00020000))) ERR;
00075       file_list_del(nc);
00076       if (find_nc_file(0x00020000)) ERR;
00077       if (!(nc = find_nc_file(0))) ERR;
00078       if (file_list_add_netcdf4(nc, NAME, NC_NETCDF4)) ERR;
00079       if (!nc->nc4_info) ERR;
00080       if (strncmp(NAME, nc->nc4_info->path, NC_MAX_NAME)) ERR;
00081       if (!nc->nc4_info->root_grp) ERR;
00082       if (nc->nc4_info->root_grp->children) ERR;
00083       if (nc->nc4_info->root_grp->next) ERR;
00084       if (nc->nc4_info->root_grp->parent) ERR;
00085       if (!(nc = find_nc_file(0x00000000))) ERR;
00086       rec_grp_del(&nc->nc4_info->root_grp, nc->nc4_info->root_grp);
00087       nc_free(nc->nc4_info);
00088       file_list_del(nc);
00089       nc_exit();
00090    }
00091 
00092    SUMMARIZE_ERR;
00093    printf("*** testing attribute list code...");
00094 
00095 #define TYPE_NAME1 "crazy"
00096 #define TYPE_NAME2 "silly"   
00097 
00098    {
00099       NC_ATT_INFO_T *att = NULL, **attlist = &att;
00100 
00101       if (att_list_add(attlist)) ERR;
00102       att_list_del(attlist, *attlist);
00103       nc_exit();
00104    }
00105 
00106    SUMMARIZE_ERR;
00107    printf("*** testing type list code...");
00108 
00109 #define TYPE_NAME1 "crazy"
00110 #define TYPE_NAME2 "silly"   
00111 
00112    {
00113 /*      NC_TYPE_INFO_T *typelist = NULL, *type;*/
00114 
00115 /*      if (nc4_type_list_add(&typelist, 1, 4, TYPE_NAME1)) ERR;
00116       if (find_type(typelist, 1, &type)) ERR;
00117       if (strcmp(type->name, TYPE_NAME1) || type->nc_typeid != 1) ERR;
00118       type_list_del(&typelist, type);
00119       if (nc4_type_list_add(&typelist, 2, 4, TYPE_NAME2)) ERR;
00120       if (find_type(typelist, 2, &type)) ERR;
00121       if (strcmp(type->name, TYPE_NAME2) || type->nc_typeid != 2) ERR;
00122       type_list_del(&typelist, type);*/
00123    }
00124 
00125    SUMMARIZE_ERR;
00126 
00127    /* Print out our number of errors, if any, and exit badly. */
00128    if (total_err)
00129    {
00130       printf("%d errors detected! Sorry!\n", total_err);
00131       return 2;
00132    }
00133    
00134    printf("*** Tests successful!\n");
00135    return 0;
00136 }


Variable Documentation

NC_FILE_INFO_T* nc_file
 

Definition at line 23 of file nc4internal.c.


Generated on Thu Mar 16 18:11:51 2006 for nco by  doxygen 1.4.4