usr/kevin/code/develop/ffs_tree_node.c
int ffs_tree_node_selftest(void) {

  int nfail = 0;

  ffs_tree_node_t * head;
  ffs_tree_node_t * node;
  ffs_tree_node_t * p;

  ffs_tree_node_data_t * data;
  ffs_tree_node_data_t * pdata;

  if (ffs_tree_node_nallocated() != 0) ++nfail;

  head = ffs_tree_node_create();
  if (ffs_tree_node_nallocated() != 1) ++ nfail;
  if (ffs_tree_node_id(head) != FFS_STATE_NULL) ++nfail;

  p = ffs_tree_node_leftchild(head);
  if (p != NULL) ++nfail;

  p = ffs_tree_node_nextsibling(head);
  if (p != NULL) ++nfail;

  p = ffs_tree_node_parent(head);
  if (p != NULL) ++nfail;

  if (ffs_tree_node_level_count(head, 0, 0) != 1) nfail++;
  if (ffs_tree_node_level_count(head, 1, 0) != 0) nfail++;
  if (ffs_tree_node_level_count(head, 0, 1) != 0) nfail++;

  node = ffs_tree_node_create();
  ffs_tree_node_leftchild_set(head, node);
  ffs_tree_node_parent_set(node, head);

  p = ffs_tree_node_parent(node);
  if (p != head) ++nfail;

  node = ffs_tree_node_create();
  ffs_tree_node_nextsibling_set(head, node);

  node = ffs_tree_node_create();
  ffs_tree_node_sibling_add(head, node);

  if (ffs_tree_node_level_count(head, 0, 0) != 3) ++nfail;
  if (ffs_tree_node_level_count(head, 1, 0) != 1) ++nfail;

  /* Check data attachment */

  data = ffs_tree_node_data_create();
  ffs_tree_node_data_set(head, data);

  pdata = ffs_tree_node_data(head);
  if (pdata != data) ++nfail;
  ffs_tree_node_data_set(head, NULL);
  pdata = NULL;
  ffs_tree_node_data_remove(data);

  ffs_tree_node_remove(head);
  if (ffs_tree_node_nallocated() != 0) ++nfail;

  /* Test child add */

  head = ffs_tree_node_create();
  node = ffs_tree_node_create();

  ffs_tree_node_child_add(head, node);

  p = ffs_tree_node_leftchild(head);
  if (p != node) ++nfail;

  p = ffs_tree_node_parent(node);
  if (p != head) ++nfail;

  p = ffs_tree_node_create();
  ffs_tree_node_child_add(head, p);
  if (ffs_tree_node_parent(p) != head) ++nfail;

  if (ffs_tree_node_nextsibling(node) != p) ++nfail;

  ffs_tree_node_remove(head);
  if (ffs_tree_node_nallocated() != 0) ++nfail;

  return nfail;
}
/*****************************************************************************
 *
 *  ffs_tree_node_selftest
 *
 *  Build the following simple tree with four nodes to check
 *  public interface is operating correctly:
 *
 *       1 -> 3 -> 4
 *       |
 *       2
 *
 *****************************************************************************/
ffs_tree_node_selftest
Build the following simple tree with four nodes to check
public interface is operating correctly.


ffs_tree_node_selftest Build the following simple tree with four nodes to check public interface is operating correctly .
int ffs_tree_node_selftest(void) {
  int nfail = 0;
  ffs_tree_node_t * head;
  ffs_tree_node_t * node;
  ffs_tree_node_t * p;
  ffs_tree_node_data_t * data;
  ffs_tree_node_data_t * pdata;
  if (ffs_tree_node_nallocated() != 0) ++nfail;
  head = ffs_tree_node_create();
  if (ffs_tree_node_nallocated() != 1) ++ nfail;
  if (ffs_tree_node_id(head) != FFS_STATE_NULL) ++nfail;
  p = ffs_tree_node_leftchild(head);
  if (p != NULL) ++nfail;
  p = ffs_tree_node_nextsibling(head);
  if (p != NULL) ++nfail;
  p = ffs_tree_node_parent(head);
  if (p != NULL) ++nfail;
  if (ffs_tree_node_level_count(head, 0, 0) != 1) nfail++;
  if (ffs_tree_node_level_count(head, 1, 0) != 0) nfail++;
  if (ffs_tree_node_level_count(head, 0, 1) != 0) nfail++;
  node = ffs_tree_node_create();
  ffs_tree_node_leftchild_set(head, node);
  ffs_tree_node_parent_set(node, head);
  p = ffs_tree_node_parent(node);
  if (p != head) ++nfail;
  node = ffs_tree_node_create();
  ffs_tree_node_nextsibling_set(head, node);
  node = ffs_tree_node_create();
  ffs_tree_node_sibling_add(head, node);
  if (ffs_tree_node_level_count(head, 0, 0) != 3) ++nfail;
  if (ffs_tree_node_level_count(head, 1, 0) != 1) ++nfail;
  data = ffs_tree_node_data_create();
  ffs_tree_node_data_set(head, data);
  pdata = ffs_tree_node_data(head);
  if (pdata != data) ++nfail;
  ffs_tree_node_data_set(head, NULL);
  pdata = NULL;
  ffs_tree_node_data_remove(data);
  ffs_tree_node_remove(head);
  if (ffs_tree_node_nallocated() != 0) ++nfail;
  head = ffs_tree_node_create();
  node = ffs_tree_node_create();
  ffs_tree_node_child_add(head, node);
  p = ffs_tree_node_leftchild(head);
  if (p != node) ++nfail;
  p = ffs_tree_node_parent(node);
  if (p != head) ++nfail;
  p = ffs_tree_node_create();
  ffs_tree_node_child_add(head, p);
  if (ffs_tree_node_parent(p) != head) ++nfail;
  if (ffs_tree_node_nextsibling(node) != p) ++nfail;
  ffs_tree_node_remove(head);
  if (ffs_tree_node_nallocated() != 0) ++nfail;
  return nfail;
}
int ffs_tree_node_selftest ( void ) { int nfail = 0 ; ffs_tree_node_t * head ; ffs_tree_node_t * node ; ffs_tree_node_t * p ; ffs_tree_node_data_t * data ; ffs_tree_node_data_t * pdata ; if ( ffs_tree_node_nallocated ( ) != 0 ) ++ nfail ; head = ffs_tree_node_create ( ) ; if ( ffs_tree_node_nallocated ( ) != 1 ) ++ nfail ; if ( ffs_tree_node_id ( head ) != FFS_STATE_NULL ) ++ nfail ; p = ffs_tree_node_leftchild ( head ) ; if ( p != NULL ) ++ nfail ; p = ffs_tree_node_nextsibling ( head ) ; if ( p != NULL ) ++ nfail ; p = ffs_tree_node_parent ( head ) ; if ( p != NULL ) ++ nfail ; if ( ffs_tree_node_level_count ( head , 0 , 0 ) != 1 ) nfail ++ ; if ( ffs_tree_node_level_count ( head , 1 , 0 ) != 0 ) nfail ++ ; if ( ffs_tree_node_level_count ( head , 0 , 1 ) != 0 ) nfail ++ ; node = ffs_tree_node_create ( ) ; ffs_tree_node_leftchild_set ( head , node ) ; ffs_tree_node_parent_set ( node , head ) ; p = ffs_tree_node_parent ( node ) ; if ( p != head ) ++ nfail ; node = ffs_tree_node_create ( ) ; ffs_tree_node_nextsibling_set ( head , node ) ; node = ffs_tree_node_create ( ) ; ffs_tree_node_sibling_add ( head , node ) ; if ( ffs_tree_node_level_count ( head , 0 , 0 ) != 3 ) ++ nfail ; if ( ffs_tree_node_level_count ( head , 1 , 0 ) != 1 ) ++ nfail ; data = ffs_tree_node_data_create ( ) ; ffs_tree_node_data_set ( head , data ) ; pdata = ffs_tree_node_data ( head ) ; if ( pdata != data ) ++ nfail ; ffs_tree_node_data_set ( head , NULL ) ; pdata = NULL ; ffs_tree_node_data_remove ( data ) ; ffs_tree_node_remove ( head ) ; if ( ffs_tree_node_nallocated ( ) != 0 ) ++ nfail ; head = ffs_tree_node_create ( ) ; node = ffs_tree_node_create ( ) ; ffs_tree_node_child_add ( head , node ) ; p = ffs_tree_node_leftchild ( head ) ; if ( p != node ) ++ nfail ; p = ffs_tree_node_parent ( node ) ; if ( p != head ) ++ nfail ; p = ffs_tree_node_create ( ) ; ffs_tree_node_child_add ( head , p ) ; if ( ffs_tree_node_parent ( p ) != head ) ++ nfail ; if ( ffs_tree_node_nextsibling ( node ) != p ) ++ nfail ; ffs_tree_node_remove ( head ) ; if ( ffs_tree_node_nallocated ( ) != 0 ) ++ nfail ; return nfail ; }
ffs_tree_node_selftest
  Build the following simple tree with four nodes to check
  public interface is operating correctly:
ffs_tree_node_selftest Build the following simple tree with four nodes to check public interface is operating correctly :
/* Check data attachment */ /* Test child add */