Changeset 23fddad for tester.c


Ignore:
Timestamp:
Oct 23, 2009, 11:01:30 PM (12 years ago)
Author:
Karl Ramm <kcr@1ts.org>
Branches:
master, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
8590774
Parents:
52761cc
git-author:
Karl Ramm <kcr@1ts.org> (09/30/09 10:12:27)
git-committer:
Karl Ramm <kcr@1ts.org> (10/23/09 23:01:30)
Message:
refactor & rename filter creation & storage management

filter_init_fromstring -> filter_new_fromstring
filter_init -> filter_new
filter_free -> filter_delete

Every time owl_filter_init and owl_filter_init_fromstring were called,
there was a call to malloc right above them;  Conversely, after every
owl_filter_free there needed to be a call to owl_free (and sometimes
there wasn't).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester.c

    rdd6af02 r23fddad  
    194194
    195195int owl_filter_test_string(const char * filt, const owl_message *m, int shouldmatch) /* noproto */ {
    196   owl_filter f;
     196  owl_filter *f;
    197197  int ok;
    198198  int failed = 0;
    199   if(owl_filter_init_fromstring(&f, "test-filter", filt)) {
     199  if ((f = owl_filter_new_fromstring("test-filter", filt)) == NULL) {
    200200    printf("not ok can't parse %s\n", filt);
    201201    failed = 1;
    202202    goto out;
    203203  }
    204   ok = owl_filter_message_match(&f, m);
     204  ok = owl_filter_message_match(f, m);
    205205  if((shouldmatch && !ok) || (!shouldmatch && ok)) {
    206206    printf("not ok match %s (got %d, expected %d)\n", filt, ok, shouldmatch);
     
    208208  }
    209209 out:
    210   owl_filter_free(&f);
     210  owl_filter_delete(f);
    211211  if(!failed) {
    212212    printf("ok %s %s\n", shouldmatch ? "matches" : "doesn't match", filt);
     
    218218  int numfailed=0;
    219219  owl_message m;
    220   owl_filter f1, f2, f3, f4, f5;
     220  owl_filter *f1, *f2, *f3, *f4, *f5;
    221221
    222222  owl_list_create(&(g.filterlist));
     
    260260  TEST_FILTER("true and false or false", 0);
    261261
    262   owl_filter_init_fromstring(&f1, "f1", "class owl");
    263   owl_global_add_filter(&g, &f1);
     262  f1 = owl_filter_new_fromstring("f1", "class owl");
     263  owl_global_add_filter(&g, f1);
    264264  TEST_FILTER("filter f1", 1);
     265  owl_global_remove_filter(&g, "f1");
    265266
    266267  /* Test recursion prevention */
    267   FAIL_UNLESS("self reference", owl_filter_init_fromstring(&f2, "test", "filter test"));
     268  FAIL_UNLESS("self reference", (f2 = owl_filter_new_fromstring("test", "filter test")) == NULL);
     269  owl_filter_delete(f2);
    268270
    269271  /* mutual recursion */
    270   owl_filter_init_fromstring(&f3, "f3", "filter f4");
    271   owl_global_add_filter(&g, &f3);
    272   FAIL_UNLESS("mutual recursion",   owl_filter_init_fromstring(&f4, "f4", "filter f3"));
     272  f3 = owl_filter_new_fromstring("f3", "filter f4");
     273  owl_global_add_filter(&g, f3);
     274  FAIL_UNLESS("mutual recursion", (f4 = owl_filter_new_fromstring("f4", "filter f3")) == NULL);
     275  owl_global_remove_filter(&g, "f3");
     276  owl_filter_delete(f4);
    273277
    274278  /* support referencing a filter several times */
    275   FAIL_UNLESS("DAG", !owl_filter_init_fromstring(&f5, "dag", "filter f1 or filter f1"));
     279  FAIL_UNLESS("DAG", (f5 = owl_filter_new_fromstring("dag", "filter f1 or filter f1")) != NULL);
     280  owl_filter_delete(f5);
    276281
    277282  return 0;
Note: See TracChangeset for help on using the changeset viewer.