- Timestamp:
- Oct 23, 2009, 11:01:30 PM (15 years ago)
- Branches:
- master, release-1.10, 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tester.c
rdd6af02 r23fddad 194 194 195 195 int owl_filter_test_string(const char * filt, const owl_message *m, int shouldmatch) /* noproto */ { 196 owl_filter f;196 owl_filter *f; 197 197 int ok; 198 198 int failed = 0; 199 if (owl_filter_init_fromstring(&f, "test-filter", filt)) {199 if ((f = owl_filter_new_fromstring("test-filter", filt)) == NULL) { 200 200 printf("not ok can't parse %s\n", filt); 201 201 failed = 1; 202 202 goto out; 203 203 } 204 ok = owl_filter_message_match( &f, m);204 ok = owl_filter_message_match(f, m); 205 205 if((shouldmatch && !ok) || (!shouldmatch && ok)) { 206 206 printf("not ok match %s (got %d, expected %d)\n", filt, ok, shouldmatch); … … 208 208 } 209 209 out: 210 owl_filter_ free(&f);210 owl_filter_delete(f); 211 211 if(!failed) { 212 212 printf("ok %s %s\n", shouldmatch ? "matches" : "doesn't match", filt); … … 218 218 int numfailed=0; 219 219 owl_message m; 220 owl_filter f1, f2, f3, f4,f5;220 owl_filter *f1, *f2, *f3, *f4, *f5; 221 221 222 222 owl_list_create(&(g.filterlist)); … … 260 260 TEST_FILTER("true and false or false", 0); 261 261 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); 264 264 TEST_FILTER("filter f1", 1); 265 owl_global_remove_filter(&g, "f1"); 265 266 266 267 /* 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); 268 270 269 271 /* 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); 273 277 274 278 /* 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); 276 281 277 282 return 0;
Note: See TracChangeset
for help on using the changeset viewer.