Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    r4123da1 r3f6555d  
    1616int main(int argc, char **argv, char **env)
    1717{
    18   owl_errqueue_init(owl_global_get_errqueue(&g));
    19   owl_obarray_init(&(g.obarray));
    20   g.context_stack = NULL;
    21   owl_global_push_context(&g, OWL_CTX_STARTUP, NULL, NULL);
     18  /* initialize a fake ncurses, detached from std{in,out} */
     19  FILE *rnull = fopen("/dev/null", "r");
     20  FILE *wnull = fopen("/dev/null", "w");
     21  newterm("xterm", wnull, rnull);
     22  /* initialize global structures */
     23  owl_global_init(&g);
    2224
    2325  numtests = 0;
     
    3133  numfailures += owl_variable_regtest();
    3234  numfailures += owl_filter_regtest();
    33   numfailures += owl_obarray_regtest();
    3435  numfailures += owl_editwin_regtest();
    3536  if (numfailures) {
     
    3738  }
    3839  printf("1..%d\n", numtests);
     40
     41  /* probably not necessary, but tear down the screen */
     42  endwin();
     43  fclose(rnull);
     44  fclose(wnull);
     45
    3946  return(numfailures);
    4047}
     
    293300}
    294301
    295 
    296 int owl_obarray_regtest(void) {
    297   int numfailed = 0;
    298   const char *p,*p2;
    299 
    300   owl_obarray oa;
    301   owl_obarray_init(&oa);
    302 
    303   printf("# BEGIN testing owl_obarray\n");
    304 
    305   p = owl_obarray_insert(&oa, "test");
    306   FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test"));
    307   p2 = owl_obarray_insert(&oa, "test");
    308   FAIL_UNLESS("returned string is equal", p2 && !strcmp(p2, "test"));
    309   FAIL_UNLESS("returned the same string", p2 && p == p2);
    310 
    311   p = owl_obarray_insert(&oa, "test2");
    312   FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test2"));
    313   p2 = owl_obarray_find(&oa, "test2");
    314   FAIL_UNLESS("returned the same string", p2 && !strcmp(p2, "test2"));
    315 
    316   p = owl_obarray_find(&oa, "nothere");
    317   FAIL_UNLESS("Didn't find a string that isn't there", p == NULL);
    318 
    319   printf("# END testing owl_obarray (%d failures)\n", numfailed);
    320 
    321   return numfailed;
    322 }
    323 
    324302int owl_editwin_regtest(void) {
    325303  int numfailed = 0;
Note: See TracChangeset for help on using the changeset viewer.