cvs: Rebuild without gnuregex library
[dragonfly.git] / gnu / lib / libregex / test / test.h
CommitLineData
984263bc
MD
1/* test.h: for Regex testing. */
2
3#ifndef TEST_H
4#define TEST_H
5
6#include <stdio.h>
7#include <assert.h>
8
9#include <sys/types.h>
10#include "regex.h"
11
12
13/* A strlen that works even on a null pointer. */
14#define SAFE_STRLEN(s) (s == NULL ? 0 : strlen (s))
15
16typedef enum { false = 0, true = 1 } boolean;
17
18extern boolean test_should_match;
19extern boolean omit_register_tests;
20extern void *xmalloc ();
21
22/* Defined in upcase.c. */
23extern char upcase[];
24
25typedef enum
26{
27 all_test,
28 other_test,
29 posix_basic_test,
30 posix_extended_test,
31 posix_interface_test,
32 regress_test
33} test_type;
34
35extern test_type t;
36
37
38#if __STDC__
39
40extern char *concat (char *, char *);
41
42extern void general_test (unsigned pattern_should_be_valid,
43 unsigned match_whole_string,
44 const char *pat, char *str1, char *str2,
45 int start, int range, int end,
46 char *correct_fastmap,
47 struct re_registers *correct_regs, int can_be_null);
48
49
50extern void init_pattern_buffer (regex_t *pattern_buffer_ptr);
51
52extern void test_compile (unsigned valid_pattern, int error_code_expected,
53 const char *pattern, regex_t *pattern_buffer_ptr,
54 int cflags);
55
56extern char *delimiter_to_ops (char *source, char left_delimiter,
57 char right_delimiter);
58
59
60extern void test_search_return (int, const char *, char *);
61
62extern void test_berk_search (const char *pattern, char *string);
63
64extern void test_fastmap (const char *pat, char *fastmap_string, unsigned invert,
65 unsigned match_newline);
66
67extern void test_fastmap_search (const char *pat, char *str, char *fastmap_string,
68 unsigned invert, unsigned match_newline,
69 int can_be_null, int start0, int end0);
70
71extern void test_all_registers (char *pat, char *str1, char *str2,
72 int start0, int end0, int start1, int end1,
73 int start2, int end2, int start3, int end3,
74 int start4, int end4, int start5, int end5,
75 int start6, int end6, int start7, int end7,
76 int start8, int end8, int start9, int end9);
77
78extern void print_pattern_info (const char *pattern, regex_t *pattern_buffer_ptr);
79extern void compile_and_print_pattern (char *pattern);
80
81extern void test_case_fold (const char *pattern, char* string);
82
83extern void test_posix_generic ();
84
85extern void test_grouping ();
86
87extern void invalid_pattern (int error_code_expected, char *pattern);
88extern void valid_nonposix_pattern (char *pattern);
89extern void valid_pattern (char *pattern);
90
91extern void test_match_2 (const char *pat, char *str1, char *str2);
92extern void test_match (const char *pat, char *str);
93
94#endif /* __STDC__ */
95
96
97#define TEST_REGISTERS_2(pat, str1, str2, start0, end0, start1, end1, start2, end2)\
98 if (!omit_register_tests) \
99 test_all_registers (pat, str1, str2, start0, end0, start1, end1, \
100 start2, end2, -1, -1, -1, -1, -1, -1, -1, -1,\
101 -1, -1, -1, -1, -1, -1) \
102
103
104#define TEST_REGISTERS(pat, str, start0, end0, start1, end1, start2, end2) \
105 TEST_REGISTERS_2 (pat, str, NULL, start0, end0, start1, end1, start2, end2)\
106
107#define BRACES_TO_OPS(string) ((char *) delimiters_to_ops (string, '{', '}'))
108#define PARENS_TO_OPS(string) ((char *) delimiters_to_ops (string, '(', ')'))
109
110#define INVALID_PATTERN(pat) \
111 general_test (0, 0, pat, NULL, NULL, -1, 0, -1, NULL, 0, -1)
112
113
114#define MATCH_SELF(p) test_match (p, p)
115
116#define TEST_POSITIONED_MATCH(pat, str, start) \
117 general_test (1, 0, pat, str, NULL, start, 1, SAFE_STRLEN (str), \
118 NULL, 0, -1)
119
120#define TEST_TRUNCATED_MATCH(pat, str, end) \
121 general_test (1, 0, pat, str, NULL, 0, 1, end, NULL, 0, -1)
122
123#define TEST_SEARCH_2(pat, str1, str2, start, range, one_past_end) \
124 general_test (1, 0, pat, str1, str2, start, range, one_past_end, \
125 NULL, 0, -1)
126
127#define TEST_SEARCH(pat, str, start, range) \
128 { \
129 TEST_SEARCH_2 (pat, str, NULL, start, range, SAFE_STRLEN (str)); \
130 TEST_SEARCH_2 (pat, NULL, str, start, range, SAFE_STRLEN (str)); \
131 }
132
133#endif /* TEST_H */
134\f
135/*
136Local variables:
137make-backup-files: t
138version-control: t
139trim-versions-without-asking: nil
140End:
141*/