source: tester.c @ cb769bb

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since cb769bb was cb769bb, checked in by Nelson Elhage <nelhage@mit.edu>, 18 years ago
r15874@phanatique: nelhage | 2006-12-24 18:25:33 -0500 Don't quit if we can't contact the hostmaster. r15884@phanatique: nelhage | 2006-12-24 18:56:03 -0500 Respect the displayoutgoing variable r15885@phanatique: nelhage | 2006-12-24 20:10:44 -0500 You can now write filters based off arbitrary message attributes r15887@phanatique: nelhage | 2006-12-24 22:59:39 -0500 r15886@phanatique (orig r476): nelhage | 2006-12-24 22:59:10 -0500 r24493@heretique: nelhage | 2006-12-24 22:59:02 -0500 Moving zephyr initialization later, so that zephyr works again r15891@phanatique: nelhage | 2006-12-25 14:40:08 -0500 * perl messages hashes use `private', not `isprivate' * get rid of a perl warning if login fails r15900@phanatique: nelhage | 2006-12-25 21:04:15 -0500 Merging in filter regression tests from my local branch. r15926@phanatique: nelhage | 2006-12-26 00:57:07 -0500 r15901@phanatique: nelhage | 2006-12-25 21:08:47 -0500 Base framework for the filter rewrite system. Only understands regexes and true/false so far. r15927@phanatique: nelhage | 2006-12-26 00:57:08 -0500 r15902@phanatique: nelhage | 2006-12-25 23:03:33 -0500 support for negation and parentheses r15928@phanatique: nelhage | 2006-12-26 00:57:08 -0500 r15924@phanatique: nelhage | 2006-12-26 00:16:30 -0500 Now passing all tests except for recursion detection r15929@phanatique: nelhage | 2006-12-26 00:57:08 -0500 r15925@phanatique: nelhage | 2006-12-26 00:52:09 -0500 Checking for filter recursion loops
  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include "owl.h"
2#include <unistd.h>
3#include <stdlib.h>
4
5static const char fileIdent[] = "$Id$";
6
7owl_global g;
8
9void screeninit()
10{
11  char buff[1024];
12 
13  sprintf(buff, "TERMINFO=%s", TERMINFO);
14  putenv(buff);
15
16  initscr();
17  start_color();
18  /* cbreak(); */
19  raw();
20  noecho();
21  intrflush(stdscr,FALSE);
22  keypad(stdscr,TRUE);
23  nodelay(stdscr,1);
24  clear();
25  refresh();
26  meta(stdscr, TRUE);
27}
28
29void test1()
30{
31  int j;
32  owl_editwin e;
33
34  screeninit();
35
36  owl_editwin_init(&e, stdscr, LINES, COLS, OWL_EDITWIN_STYLE_MULTILINE, NULL);
37  /* owl_editwin_set_locktext(&e, "Here is some locktext:\n");*/
38  doupdate();
39  while (1) {
40    usleep(50);
41
42    j=getch();
43
44    if (j==ERR) continue;
45
46    if (j==3) break;
47
48    if (j==27) {
49      j=getch();
50      if (j==ERR) continue;
51      owl_editwin_process_char(&e, j);
52      doupdate();
53    } else {
54      owl_editwin_process_char(&e, j);
55      doupdate();
56    }
57  }
58  endwin();
59  printf("Had:\n%s", owl_editwin_get_text(&e));
60}
61
62void test2(char *in)
63{
64  owl_fmtext t;
65
66  screeninit();
67
68  owl_fmtext_init_null(&t);
69  owl_fmtext_append_ztext(&t, in);
70  owl_fmtext_curs_waddstr(&t, stdscr);
71  wrefresh(stdscr);
72  sleep(5000);
73  endwin();
74}
75
76void test3()
77{
78  ZNotice_t *n;
79
80  printf("%i\n", sizeof(n->z_uid.zuid_addr));
81  /* gethostbyaddr((char *) &(n->z_uid.zuid_addr), sizeof(n->z_uid.zuid_addr), AF_INET); */
82}
83
84void colorinfo()
85{
86  char buff[1024];
87 
88  screeninit();
89  sprintf(buff, "Have %i COLOR_PAIRS\n", COLOR_PAIRS);
90  addstr(buff);
91  refresh();
92  sleep(10);
93  endwin(); 
94}
95
96void test4()
97{
98  int j;
99  char buff[1024];
100
101  screeninit();
102 
103  while (1) {
104    usleep(100);
105
106    j=getch();
107
108    if (j==ERR) continue;
109
110    if (j==3) break;
111    sprintf(buff, "%o\n", j);
112    addstr(buff);
113  }
114  endwin();
115}
116
117void test_keypress()
118{
119  int j, rev;
120  char buff[1024], buff2[64];
121
122  screeninit();
123 
124  while (1) {
125    usleep(100);
126
127    j=wgetch(stdscr);
128
129    if (j==ERR) continue;
130
131    if (j==3) break;
132    if (0 == owl_keypress_tostring(j, 0, buff2, 1000)) {
133      rev = owl_keypress_fromstring(buff2);
134      sprintf(buff, "%s : 0x%x 0%o %d %d %s\n", buff2, j, j, j, rev,
135              (j==rev?"matches":"*** WARNING: Does Not Reverse"));
136    } else {
137      sprintf(buff, "UNKNOWN : 0x%x 0%o %d\n", j, j, j);
138    }
139      addstr(buff);
140  }
141  endwin();
142}
143
144
145int main(int argc, char **argv, char **env)
146{
147  int numfailures=0;
148  if (argc==2 && 0==strcmp(argv[1],"reg")) {
149    numfailures += owl_util_regtest();
150    numfailures += owl_dict_regtest();
151    numfailures += owl_variable_regtest();
152    numfailures += owl_filter_regtest();
153    if (numfailures) {
154      fprintf(stderr, "*** WARNING: %d failures total\n", numfailures);
155    }
156    return(numfailures);
157  } else if (argc==2 && 0==strcmp(argv[1],"test1")) {
158    test1();
159  } else if (argc==2 && 0==strcmp(argv[1],"colorinfo")) {
160    colorinfo();
161  } else if (argc==2 && 0==strcmp(argv[1],"test4")) {
162    test4();
163  } else if (argc==2 && 0==strcmp(argv[1],"keypress")) {
164    test_keypress();
165  } else {
166    fprintf(stderr, "No test specified.  Current options are: reg test1\n");
167  }
168  return(0);
169}
Note: See TracBrowser for help on using the repository browser.