Debian Codegraph @

testsuite/pdfgrep.tests/regex.exp

raw
1 set test "Match line after double match"
2
3 clear_pdfdir
4 set pdf [mkpdf regex {
5 foofoo\\
6 foo test
7 }]
8
9 pdfgrep_expect foo $pdf \
10 "foofoo
11 foo test"
12
13 set test "Match line after double match -- fixed string"
14
15 pdfgrep_expect -F foo $pdf \
16 "foofoo
17 foo test"
18
19 set test "Match line after double match -- PCRE"
20
21 set requires_pcre_support true
22
23 pdfgrep_expect -P foo $pdf \
24 "foofoo
25 foo test"
26
27 ######################################################################
28
29 # This behaviour of repeating the same line over and over again is clearly not
30 # optimal, but it's better than an infinite loop!
31
32 set test "Empty pattern"
33
34 set empty [mkpdf empty {
35 abc
36 }]
37
38 set timeout 2
39 pdfgrep_expect "" $empty \
40 "abc"
41
42 set test "Empty pattern -- fixed string"
43
44 set timeout 2
45 pdfgrep_expect -F "" $empty \
46 "abc"
47
48 set test "Empty pattern -- PCRE"
49
50 set requires_pcre_support true
51
52 set timeout 2
53 pdfgrep_expect -P "" $empty \
54 "abc"
55
56 ######################################################################
57
58 set test "Case insensitive search"
59
60 clear_pdfdir
61 set pdf [mkpdf icase "FoObAr"]
62
63 pdfgrep_expect -i "foobar" $pdf \
64 "FoObAr"
65
66
67 set test "Case insensitive search -- fixed string"
68
69 clear_pdfdir
70 set pdf [mkpdf icase "FoObAr"]
71
72 pdfgrep_expect -Fi "foobar" $pdf \
73 "FoObAr"
74
75
76 set test "Case insensitive search -- PCRE"
77
78 set requires_pcre_support true
79
80 clear_pdfdir
81 set pdf [mkpdf icase "FoObAr"]
82
83 pdfgrep_expect -Pi "foobar" $pdf \
84 "FoObAr"
85
86 ######################################################################
87
88 set test "Multiple fixed strings"
89
90 clear_pdfdir
91 set pdf [mkpdf lines {
92 line one\\
93 line two\\
94 line three
95 }]
96
97 pdfgrep_expect -F "one\ntwo\nthree" $pdf \
98 "line one
99 line two
100 line three"
101
102 ######################################################################
103
104 set test "Multiple fixed strings in wrong order"
105
106 set multifixed [mkpdf multifixed {
107 one two
108 }]
109
110 pdfgrep_expect -o -F "two\none" $multifixed \
111 "one
112 two"
113
114 ######################################################################
115
116 # Not sure if this should be the expected behavior.
117 #
118 # The feature to match multiline strings is often being requested, though
119
120 set test "Multiline with PCRE"
121
122 set requires_pcre_support true
123
124 set multiline [mkpdf multiline {
125 line one\\
126 line two
127 }]
128
129 pdfgrep_expect -P "one\nline" $multiline \
130 "line one
131 line two"
132
133 ######################################################################
134
135 set test "Empty page"
136
137 clear_pdfdir
138 set pdf [mkpdf empty {
139 page1\\\\
140 still page 1
141 \newpage\mbox{}\newpage
142 page2
143 }]
144
145 pdfgrep_expect -n "^$" $pdf \
146 "2:"
147
148 ######################################################################
149
150 set test "Empty page -- PCRE"
151
152 set requires_pcre_support true
153
154 pdfgrep_expect -P -n "^$" $pdf \
155 "2:"
156
157 ######################################################################
158
159 set test "Page beginning is actually page beginning"
160
161 pdfgrep_expect -n --only-match "p|^age" $pdf \
162 "1:p
163 1:p
164 3:p"
165
166 ######################################################################
167
168 set test "Page beginning is actually page beginning -- PCRE"
169
170 set requires_pcre_support true
171
172 pdfgrep_expect -P -n --only-match "p|^age" $pdf \
173 "1:p
174 1:p
175 3:p"
176
177 ######################################################################
178
179 set test "Invalid regex"
180
181 pdfgrep_expect_error -r "(" .
182
183 expect_exit_status 2
184
185 ######################################################################
186
187 set test "Invalid regex -- PCRE"
188
189 pdfgrep_expect_error -Pr "(" .
190
191 expect_exit_status 2
192
193 ######################################################################
194
195 clear_pdfdir
196 set pdf [mkpdf empty {
197 line1\\\\
198 line2
199 }]
200
201 set test "^ only matches the beginning of a page"
202
203 pdfgrep_expect "^line" $pdf "line1"
204
205 ######################################################################
206
207 set test "^ only matches the beginning of a page -- PCRE"
208
209 set requires_pcre_support true
210
211 pdfgrep_expect -P "^line" $pdf "line1"
212
213 ######################################################################
214
215 set test "\$ only matches the end of a page"
216
217 pdfgrep_expect "line.\$" $pdf "line2"
218
219 ######################################################################
220
221 set test "\$ only matches the end of a page -- PCRE"
222
223 set requires_pcre_support true
224
225 pdfgrep_expect -P "line.\$" $pdf "line2"