NMD
Functions
u2.c File Reference
#include <stdlib.h>
#include "nmd.h"
Include dependency graph for u2.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 different ways of creating a category

Definition at line 5 of file u2.c.

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

                               {
  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 = NMDObjectTryGetCategory
      (nmd,"cat1",&cat,&flg); NMD_ERR_RETURN(ierr);
    if (!flg) NMD_ERR_REPORT("category 1 should exist");

    ierr = NMDObjectAllocateNewCategory
      (nmd,"catthree",&cat); NMD_ERR_RETURN(ierr);
    ierr = NMDObjectTryGetCategory
      (nmd,"catthree",NULL,&flg); NMD_ERR_RETURN(ierr);
    if (!flg) NMD_ERR_REPORT("category three should exist");

    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: