summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCarlo Marcelo Arenas Belón <carenas@gmail.com>2021-11-09 17:02:39 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2021-11-10 18:24:17 -0800
commitf585b6bb3b7f95abfe7a4f4981e12e0e2c47fb6f (patch)
tree41fd23505158c64f6033baab372907004785410e /tests
parentb3a85a1a8a816f4f6f9c01399c16efe92a86ca06 (diff)
downloadgrep-f585b6bb3b7f95abfe7a4f4981e12e0e2c47fb6f.tar.gz
tests: fix test logic for pcre-context
Included in the original bug #20957, but corrupted somehow in transit as the required NUL characters are missing. Add a simpler version of the test case that uses plain characters and match the -z data and output to show the equivalence. Note the output is still not correct as it is missing the expected LF characters, but a full fix will have to wait until PCRE2. Fixes Bug#51735.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/pcre-context40
1 files changed, 22 insertions, 18 deletions
diff --git a/tests/pcre-context b/tests/pcre-context
index b910a205..77cb8638 100755
--- a/tests/pcre-context
+++ b/tests/pcre-context
@@ -4,29 +4,33 @@
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.
+b0
+ab1
+aab2
+aaab3
+aaaab4
+EOF
+test $? -eq 0 || framework_failure_
+cat >exp <<'EOF'
+b3
+ab4
EOF
test $? -eq 0 || framework_failure_
+grep -Po '(?<=aaa).*' in >out || fail_ 'grep -Po failed'
+compare exp out || fail=1
+
+printf 'NUL preceded by 0 empty lines.\0' >in &&
+printf '\nNUL preceded by 1 empty line.\0' >>in &&
+printf '\n\nNUL preceded by 2 empty lines.\0' >>in &&
+printf '\n\n\nNUL preceded by 3 empty lines.\0' >>in &&
+printf '\n\n\n\nNUL preceded by 4 empty lines.\0' >>in &&
+printf '\n' >>in || framework_failure_
+
printf '%s\0' \
- 'Preceded by 2 empty lines.' \
- 'Preceded by 3 empty lines.' \
- 'Preceded by 4 empty lines.' >exp || framework_failure_
+ 'NUL preceded by 3 empty lines.' \
+ 'NUL preceded by 4 empty lines.' >exp || framework_failure_
fail=0