* tests/Makefile.am (TESTS): Add test case.
* tests/patch-pg: New test case.
---
 tests/Makefile.am |  1 +
 tests/patch-pg    | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
 create mode 100644 tests/patch-pg

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5ce000a31..0bc31ca44 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -53,6 +53,7 @@ TESTS = \
        need-filename \
        no-mode-change-git-diff \
        no-newline-triggers-assert \
+       patch-pg \
        preserve-c-function-names \
        preserve-mode-and-timestamp \
        quoted-filenames \
diff --git a/tests/patch-pg b/tests/patch-pg
new file mode 100644
index 000000000..506664bf2
--- /dev/null
+++ b/tests/patch-pg
@@ -0,0 +1,61 @@
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# in any medium, are permitted without royalty provided the copyright
+# notice and this notice are preserved.
+
+. $srcdir/test-lib.sh
+
+require cat
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > f.diff <<EOF
+--- a/a
++++ a/a
+@@ -1 +1,2 @@
+ aaa
++bbb
+EOF
+
+cat > g.diff <<EOF
+--- a/a
++++ a/a
+@@ -1,2 +1,3 @@
+ aaa
+ bbb
++ccc
+
+--- /dev/null
++++ a/b
+@@ -0,0 +1 @@
++aaa
+EOF
+
+echo aaa > a
+
+check 'patch -pg < f.diff' <<EOF
+patching file a
+EOF
+
+check 'cat a' <<EOF
+aaa
+bbb
+EOF
+
+check 'patch -pg < g.diff' <<EOF
+patching file a
+patching file b
+EOF
+
+check 'cat a' <<EOF
+aaa
+bbb
+ccc
+EOF
+
+check 'cat b' <<EOF
+aaa
+EOF
-- 
2.24.1


Reply via email to