[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] tests: include UTF-8 testcases for grep -P
From: |
Paolo Bonzini |
Subject: |
[PATCH 2/2] tests: include UTF-8 testcases for grep -P |
Date: |
Wed, 3 Oct 2012 11:20:30 +0200 |
* tests/Makefile.am (TESTS): Add pcre-utf8.
* tests/pcre-utf8: New file.
---
tests/Makefile.am | 1 +
tests/pcre-utf8 | 33 +++++++++++++++++++++++++++++++++
2 file modificati, 34 inserzioni(+)
create mode 100755 tests/pcre-utf8
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 58deaa2..2f99a69 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -75,6 +75,7 @@ TESTS = \
options \
pcre \
pcre-abort \
+ pcre-utf8 \
pcre-z \
prefix-of-multibyte \
r-dot \
diff --git a/tests/pcre-utf8 b/tests/pcre-utf8
new file mode 100755
index 0000000..b86b114
--- /dev/null
+++ b/tests/pcre-utf8
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Ensure that, with -P, Unicode \p{} symbols are correctly matched.
+#
+# Copyright (C) 2001, 2006, 2009-2012 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+require_pcre_
+require_en_utf8_locale_
+
+fail=0
+
+echo '$' | LC_ALL=en_US.UTF-8 grep -qP '\p{S}' || exit 77
+
+euro='\xe2\x82\xac euro'
+printf "$euro\\n" > in || framework_failure_
+
+LC_ALL=en_US.UTF-8 grep -P '^\p{S}' in > out || fail=1
+compare out in || fail=1
+
+LC_ALL=en_US.UTF-8 grep -P '^. euro$' in > out2 || fail=1
+compare out2 in || fail=1
+
+LC_ALL=en_US.UTF-8 grep -oP '. euro' in > out3 || fail=1
+compare out3 in || fail=1
+
+LC_ALL=en_US.UTF-8 grep -P '^\P{S}' in > out4
+compare out4 /dev/null || fail=1
+
+Exit $fail
--
1.7.12.1