- Timestamp:
- Jan 20, 2011, 7:59:38 PM (12 years ago)
- Branches:
- master, release-1.8, release-1.9
- Children:
- 443dcfa
- Parents:
- c7fe23e
- git-author:
- David Benjamin <davidben@mit.edu> (01/02/11 20:44:44)
- git-committer:
- David Benjamin <davidben@mit.edu> (01/20/11 19:59:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tester.c
r2bc6ad35 rb31252d 22 22 int owl_editwin_regtest(void); 23 23 int owl_fmtext_regtest(void); 24 int owl_smartfilter_regtest(void); 24 25 25 26 extern void owl_perl_xs_init(pTHX); … … 108 109 numfailures += owl_editwin_regtest(); 109 110 numfailures += owl_fmtext_regtest(); 111 numfailures += owl_smartfilter_regtest(); 110 112 if (numfailures) { 111 113 fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures); … … 651 653 return numfailed; 652 654 } 655 656 static int owl_smartfilter_test_equals(const char *filtname, const char *expected) { 657 owl_filter *f = NULL; 658 char *filtstr = NULL; 659 int failed = 0; 660 f = owl_global_get_filter(&g, filtname); 661 if (f == NULL) { 662 printf("not ok filter missing: %s\n", filtname); 663 failed = 1; 664 goto out; 665 } 666 667 /* TODO: Come up with a better way to test this. */ 668 filtstr = owl_filter_print(f); 669 if (strcmp(expected, filtstr)) { 670 printf("not ok filter incorrect: |%s| instead of |%s|\n", 671 filtstr, expected); 672 failed = 1; 673 goto out; 674 } 675 676 out: 677 owl_free(filtstr); 678 return failed; 679 } 680 681 static int owl_classinstfilt_test(const char *c, const char *i, int related, const char *expected) { 682 char *filtname = NULL; 683 int failed = 0; 684 685 filtname = owl_function_classinstfilt(c, i, related); 686 if (filtname == NULL) { 687 printf("not ok null filtname: %s %s %s\n", c, i ? i : "(null)", 688 related ? "related" : "not related"); 689 failed = 1; 690 goto out; 691 } 692 if (owl_smartfilter_test_equals(filtname, expected)) { 693 failed = 1; 694 goto out; 695 } 696 out: 697 if (!failed) { 698 printf("ok %s\n", filtname); 699 } 700 if (filtname) 701 owl_global_remove_filter(&g, filtname); 702 owl_free(filtname); 703 return failed; 704 } 705 706 int owl_smartfilter_regtest(void) { 707 int numfailed = 0; 708 709 printf("# BEGIN testing owl_smartfilter\n"); 710 711 /* Check classinst making. */ 712 713 #define TEST_CLASSINSTFILT(c, i, r, e) do { \ 714 numtests++; \ 715 numfailed += owl_classinstfilt_test(c, i, r, e); \ 716 } while (0) 717 TEST_CLASSINSTFILT("message", NULL, false, 718 "class ^message$\n"); 719 TEST_CLASSINSTFILT("message", NULL, true, 720 "class ^(un)*message(\\.d)*$\n"); 721 TEST_CLASSINSTFILT("message", "personal", false, 722 "class ^message$ and instance ^personal$\n"); 723 TEST_CLASSINSTFILT("message", "personal", true, 724 "class ^(un)*message(\\.d)*$ and ( instance ^(un)*personal(\\.d)*$ )\n"); 725 726 TEST_CLASSINSTFILT("message", "evil\tinstance", false, 727 "class ^message$ and instance '^evil\tinstance$'\n"); 728 TEST_CLASSINSTFILT("message", "evil instance", false, 729 "class ^message$ and instance '^evil instance$'\n"); 730 TEST_CLASSINSTFILT("message", "evil'instance", false, 731 "class ^message$ and instance \"^evil'instance$\"\n"); 732 TEST_CLASSINSTFILT("message", "evil\"instance", false, 733 "class ^message$ and instance '^evil\"instance$'\n"); 734 TEST_CLASSINSTFILT("message", "evil$instance", false, 735 "class ^message$ and instance ^evil\\$instance$\n"); 736 737 738 printf("# END testing owl_smartfilter (%d failures)\n", numfailed); 739 740 return numfailed; 741 }
Note: See TracChangeset
for help on using the changeset viewer.