NMD
Functions
u3.c File Reference
#include <stdlib.h>
#include "nmd.h"
Include dependency graph for u3.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Test removal of a category

Definition at line 5 of file u3.c.

References NMD_FREE, NMDCreateObject(), NMDDestroyObject(), NMDGetCategories(), NMDObjectAllocateNewCategory(), NMDObjectTryGetCategory(), and NMDRemoveCategory().

                               {
  NMD_metadata nmd; NMDErrorCode ierr;
  PetscFunctionBegin;
  PetscInitialize(&argc,&argv,0,0);
  ierr = NMDCreateObject(&nmd); NMD_ERR_RETURN(ierr);

  {
    NMD_metadata_category cat; char **cats; NMDTruth flg; int ncat;

    ierr = NMDObjectAllocateNewCategory
      (nmd,"cat1",NULL); NMD_ERR_RETURN(ierr);

    ierr = NMDObjectAllocateNewCategory
      (nmd,"cat2",&cat); NMD_ERR_RETURN(ierr);

    ierr = NMDObjectAllocateNewCategory
      (nmd,"catthree",&cat); NMD_ERR_RETURN(ierr);

    ierr = NMDRemoveCategory(nmd,"cat2"); NMD_ERR_RETURN(ierr);

    ierr = NMDObjectTryGetCategory
      (nmd,"cat2",NULL,&flg); NMD_ERR_RETURN(ierr);
    if (flg) NMD_ERR_REPORT("category was supposed to be removed");

    ierr = NMDGetCategories(nmd,&ncat,NULL); NMD_ERR_RETURN(ierr);
    if (ncat!=3) NMD_ERR_REPORTi("incorrect number of categories",ncat);
    ierr = NMDGetCategories(nmd,&ncat,&cats); NMD_ERR_RETURN(ierr);
    NMD_FREE(cats);
  }

  ierr = NMDDestroyObject(nmd); NMD_ERR_RETURN(ierr);
  PetscFinalize();
  PetscFunctionReturn(0);
}

Here is the call graph for this function: