Changeset 8bce750 for dict.c


Ignore:
Timestamp:
Aug 17, 2009, 9:52:16 PM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
e30ed92
Parents:
a2b3289
git-author:
Nelson Elhage <nelhage@mit.edu> (08/17/09 21:51:29)
git-committer:
Nelson Elhage <nelhage@mit.edu> (08/17/09 21:52:16)
Message:
Move all regression tests into tester.c.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • dict.c

    r636b137 r8bce750  
    143143}
    144144
    145 
    146 
    147 /************* REGRESSION TESTS **************/
    148 #ifdef OWL_INCLUDE_REG_TESTS
    149 
    150 #include "test.h"
    151 
    152 int owl_dict_regtest(void) {
    153   owl_dict d;
    154   owl_list l;
    155   int numfailed=0;
    156   char *av="aval", *bv="bval", *cv="cval", *dv="dval";
    157 
    158   printf("# BEGIN testing owl_dict\n");
    159   FAIL_UNLESS("create", 0==owl_dict_create(&d));
    160   FAIL_UNLESS("insert b", 0==owl_dict_insert_element(&d, "b", bv, owl_dict_noop_free));
    161   FAIL_UNLESS("insert d", 0==owl_dict_insert_element(&d, "d", dv, owl_dict_noop_free));
    162   FAIL_UNLESS("insert a", 0==owl_dict_insert_element(&d, "a", av, owl_dict_noop_free));
    163   FAIL_UNLESS("insert c", 0==owl_dict_insert_element(&d, "c", cv, owl_dict_noop_free));
    164   FAIL_UNLESS("reinsert d (no replace)", -2==owl_dict_insert_element(&d, "d", dv, 0));
    165   FAIL_UNLESS("find a", av==owl_dict_find_element(&d, "a"));
    166   FAIL_UNLESS("find b", bv==owl_dict_find_element(&d, "b"));
    167   FAIL_UNLESS("find c", cv==owl_dict_find_element(&d, "c"));
    168   FAIL_UNLESS("find d", dv==owl_dict_find_element(&d, "d"));
    169   FAIL_UNLESS("find e (non-existent)", NULL==owl_dict_find_element(&d, "e"));
    170   FAIL_UNLESS("remove d", dv==owl_dict_remove_element(&d, "d"));
    171   FAIL_UNLESS("find d (post-removal)", NULL==owl_dict_find_element(&d, "d"));
    172 
    173   FAIL_UNLESS("get_size", 3==owl_dict_get_size(&d));
    174   FAIL_UNLESS("get_keys", 0==owl_dict_get_keys(&d, &l));
    175   FAIL_UNLESS("get_keys result size", 3==owl_list_get_size(&l));
    176  
    177   /* these assume the returned keys are sorted */
    178   FAIL_UNLESS("get_keys result val",0==strcmp("a",owl_list_get_element(&l,0)));
    179   FAIL_UNLESS("get_keys result val",0==strcmp("b",owl_list_get_element(&l,1)));
    180   FAIL_UNLESS("get_keys result val",0==strcmp("c",owl_list_get_element(&l,2)));
    181 
    182   owl_list_free_all(&l, owl_free);
    183   owl_dict_free_all(&d, NULL);
    184 
    185   /*  if (numfailed) printf("*** WARNING: failures encountered with owl_dict\n"); */
    186   printf("# END testing owl_dict (%d failures)\n", numfailed);
    187   return(numfailed);
    188 }
    189 
    190 #endif /* OWL_INCLUDE_REG_TESTS */
Note: See TracChangeset for help on using the changeset viewer.