summaryrefslogtreecommitdiff
path: root/tests/pcre-context
blob: b910a2051d20654b564b3a9a0fdc991fe9906621 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# Test Perl regex with context
. "${srcdir=.}/init.sh"; path_prepend_ ../src
require_pcre_

cat >in <<'EOF'
Preceded by 0 empty lines.

Preceded by 1 empty line.


Preceded by 2 empty lines.



Preceded by 3 empty lines.




Preceded by 4 empty lines.

EOF
test $? -eq 0 || framework_failure_

printf '%s\0' \
       'Preceded by 2 empty lines.' \
       'Preceded by 3 empty lines.' \
       'Preceded by 4 empty lines.' >exp || framework_failure_

fail=0

grep -Pzo '(?<=\n\n\n).*' in >out || fail_ 'grep -Pzo failed'
compare exp out || fail=1

Exit $fail