summaryrefslogtreecommitdiff
path: root/tests/misc/join.pl
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2013-02-14 15:29:08 -0500
committerPádraig Brady <P@draigBrady.com>2013-02-28 01:49:56 +0000
commit6eb51ce29e962bc13586261bd0e1de4780c269ff (patch)
tree737687e0f2bb181a1eff21700ffbe848be1f1da7 /tests/misc/join.pl
parent551128ebd71d1216ccc807eccee91190d6b21462 (diff)
downloadcoreutils-6eb51ce29e962bc13586261bd0e1de4780c269ff.tar.xz
join: Add the -z, --zero-terminated option
* NEWS: Mention join's new option: --zero-terminated (-z). * src/join.c: Add new option, --zero-terminated (-z), to make join use the NUL byte as separator/delimiter rather than newline. (get_line): Use readlinebuffer_delim in place of readlinebuffer. (main): Handle the new option. (usage): Describe new option the same way sort does. * doc/coreutils.texi (join invocation): Describe the new option. * tests/misc/join.pl: add tests for -z option.
Diffstat (limited to 'tests/misc/join.pl')
-rwxr-xr-xtests/misc/join.pl20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/misc/join.pl b/tests/misc/join.pl
index 9b93794d9..7e06f1e6c 100755
--- a/tests/misc/join.pl
+++ b/tests/misc/join.pl
@@ -275,6 +275,26 @@ my @tv = (
[ "ID1 Name\n1 A\n", ""],
"ID1 Name\n1 A\n", 0],
+# Zero-terminated lines
+['z1', '-z',
+ ["a\0c\0e\0", "a\0b\0c\0"], "a\0c\0", 0],
+
+# not zero-terminated, but related to the code change:
+# the old readlinebuffer() auto-added '\n' to the last line.
+# the new readlinebuffer_delim() does not.
+# Ensure it doesn't matter.
+['z2', '',
+ ["a\nc\ne\n", "a\nb\nc"], "a\nc\n", 0],
+['z3', '',
+ ["a\nc\ne", "a\nb\nc"], "a\nc\n", 0],
+# missing last NUL at the end of the last line (=end of file)
+['z4', '-z',
+ ["a\0c\0e", "a\0b\0c"], "a\0c\0", 0],
+# edge-case: the embedded newlines should treated as
+# part of the nul-terminated line
+['z5', '-z -a1 -a2',
+ ["a\n1\0c 3\0","b\n8\0c 9\0"], "a\n1\0b\n8\0c 3 9\0"],
+
);
# Convert the above old-style test vectors to the newer