diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-12-13 20:08:16 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-12-13 20:08:16 +0100 |
commit | fe97a9451e6e9f08f893c27dac1cf16a9f75eaa9 (patch) | |
tree | b990aed07b8dc37131ad5ba8f88c63bf6ca55826 | |
parent | d25bfe3cfb6b798b388c0f8bd865377ed2f14b56 (diff) | |
download | rnl-fe97a9451e6e9f08f893c27dac1cf16a9f75eaa9.tar.gz rnl-fe97a9451e6e9f08f893c27dac1cf16a9f75eaa9.tar.xz rnl-fe97a9451e6e9f08f893c27dac1cf16a9f75eaa9.zip |
add tests
-rw-r--r-- | Makefile | 3 | ||||
-rwxr-xr-x | t/0.t | 63 | ||||
-rwxr-xr-x | t/1.t | 76 | ||||
-rwxr-xr-x | t/s.t | 78 |
4 files changed, 220 insertions, 0 deletions
diff --git a/Makefile b/Makefile index ec1a17c..a259481 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,9 @@ README: rnl.1 clean: FRC rm -f $(ALL) +check: FRC all + prove -v + install: FRC all mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1 install -m0755 $(ALL) $(DESTDIR)$(BINDIR) diff --git a/t/0.t b/t/0.t new file mode 100755 index 0000000..c6e999c --- /dev/null +++ b/t/0.t @@ -0,0 +1,63 @@ +#!/bin/sh + +export "PATH=.:$PATH" + +printf '1..11\n' +printf '# error handling\n' + +tap3 '-0 on a pipe, no newlines' <<'EOF' +printf foo | rnl -0 | wc -c +>>>/3/ +EOF + +tap3 '-0 on a pipe, one newline' <<'EOF' +printf 'foo\n' | rnl -0 | wc -c +>>>/3/ +EOF + +tap3 '-0 on a pipe, two newlines' <<'EOF' +printf 'foo\nbar\n\n' | rnl -0 | wc -c +>>>/7/ +EOF + +tap3 '-0 on a pipe, three newlines' <<'EOF' +printf 'foo\n\nbar\n\n\n' | rnl -0 | wc -c +>>>/8/ +EOF + +tap3 '-0 on a pipe, 9999 newlines' <<'EOF' +( printf 'foo'; yes '' | sed 10000q ) | rnl -0 | wc -c +>>>/3/ +EOF + + + +tap3 '-0 on a file, no newlines' <<'EOF' +printf foo > TMP; rnl -0 TMP; wc -c <TMP; rm TMP +>>>/3/ +EOF + +tap3 '-0 on a file, one newline' <<'EOF' +printf 'foo\n' > TMP; rnl -0 TMP; wc -c <TMP; rm TMP +>>>/3/ +EOF + +tap3 '-0 on a file, two newlines' <<'EOF' +printf 'foo\nbar\n\n' > TMP; rnl -0 TMP; wc -c <TMP; rm TMP +>>>/7/ +EOF + +tap3 '-0 on a file, three newlines' <<'EOF' +printf 'foo\n\nbar\n\n\n' > TMP; rnl -0 TMP; wc -c <TMP; rm TMP +>>>/8/ +EOF + +tap3 '-0 on a file, 9999 newlines' <<'EOF' +( printf 'foo'; yes '' | sed 10000q ) > TMP; rnl -0 TMP; wc -c <TMP; rm TMP +>>>/3/ +EOF + +tap3 '-0 on a biggish file, 9999 newlines' <<'EOF' +( yes 'foo' | sed 10000q; yes '' | sed 10000q ) > TMP; rnl -0 TMP; wc -c <TMP; rm TMP +>>>/39999/ +EOF diff --git a/t/1.t b/t/1.t new file mode 100755 index 0000000..34611af --- /dev/null +++ b/t/1.t @@ -0,0 +1,76 @@ +#!/bin/sh + +export "PATH=.:$PATH" + +printf '1..11\n' +printf '# error handling\n' + +tap3 '-1 on a pipe, no newlines' <<'EOF' +printf foo | rnl -1 +>>>/foo/ +EOF + +tap3 '-1 on a pipe, one newline' <<'EOF' +printf 'foo\n' | rnl -1 | wc -c +>>>/3/ +EOF + +tap3 '-1 on a pipe, two newlines' <<'EOF' +printf 'foo\nbar\n\n' | rnl -1 +>>> +foo +bar +EOF + +tap3 '-1 on a pipe, three newlines' <<'EOF' +printf 'foo\n\nbar\n\n\n' | rnl -1 +>>> +foo + +bar + +EOF + +tap3 '-1 on a pipe, 9999 newlines' <<'EOF' +( printf 'foo'; yes '' | sed 10000q ) | rnl -1 | wc -l +>>>/9999/ +EOF + + + +tap3 '-1 on a file, no newlines' <<'EOF' +printf foo > TMP; rnl -1 TMP; cat TMP; rm TMP +>>>/foo/ +EOF + +tap3 '-1 on a file, one newline' <<'EOF' +printf 'foo\n' > TMP; rnl -1 TMP; wc -c TMP; rm TMP +>>>/3/ +EOF + +tap3 '-1 on a file, two newlines' <<'EOF' +printf 'foo\nbar\n\n' > TMP; rnl -1 TMP; cat TMP; rm TMP +>>> +foo +bar +EOF + +tap3 '-1 on a file, three newlines' <<'EOF' +printf 'foo\n\nbar\n\n\n' > TMP; rnl -1 TMP; cat TMP; rm TMP +>>> +foo + +bar + +EOF + +tap3 '-1 on a file, 9999 newlines' <<'EOF' +( printf 'foo'; yes '' | sed 10000q ) > TMP; rnl -1 TMP; wc -l TMP; rm TMP +>>>/9999/ +EOF + + +tap3 '-1 on a biggish file, 9999 newlines' <<'EOF' +( yes 'foo' | sed 10000q; yes '' | sed 10000q ) > TMP; rnl -1 TMP; wc -l < TMP; rm TMP +>>>/19999/ +EOF diff --git a/t/s.t b/t/s.t new file mode 100755 index 0000000..4017647 --- /dev/null +++ b/t/s.t @@ -0,0 +1,78 @@ +#!/bin/sh + +export "PATH=.:$PATH" + +printf '1..11\n' +printf '# error handling\n' + +tap3 '-s on a pipe, no newlines' <<'EOF' +printf foo | rnl +>>>/foo/ +EOF + +tap3 '-s on a pipe, one newline' <<'EOF' +printf 'foo\n' | rnl +>>> +foo +EOF + +tap3 '-s on a pipe, two newlines' <<'EOF' +printf 'foo\nbar\n\n' | rnl +>>> +foo +bar +EOF + +tap3 '-s on a pipe, three newlines' <<'EOF' +printf 'foo\n\nbar\n\n\n' | rnl +>>> +foo + +bar +EOF + +tap3 '-s on a pipe, 9999 newlines' <<'EOF' +( printf 'foo'; yes '' | sed 10000q ) | rnl +>>> +foo +EOF + + + +tap3 '-s on a file, no newlines' <<'EOF' +printf foo > TMP; rnl TMP; cat TMP; rm TMP +>>>/foo/ +EOF + +tap3 '-s on a file, one newline' <<'EOF' +printf 'foo\n' > TMP; rnl TMP; cat TMP; rm TMP +>>> +foo +EOF + +tap3 '-s on a file, two newlines' <<'EOF' +printf 'foo\nbar\n\n' > TMP; rnl TMP; cat TMP; rm TMP +>>> +foo +bar +EOF + +tap3 '-s on a file, three newlines' <<'EOF' +printf 'foo\n\nbar\n\n\n' > TMP; rnl TMP; cat TMP; rm TMP +>>> +foo + +bar +EOF + +tap3 '-s on a file, 9999 newlines' <<'EOF' +( printf 'foo'; yes '' | sed 10000q ) > TMP; rnl TMP; cat TMP; rm TMP +>>> +foo +EOF + + +tap3 '-s on a biggish file, 9999 newlines' <<'EOF' +( yes 'foo' | sed 10000q; yes '' | sed 10000q ) > TMP; rnl TMP; wc -l < TMP; rm TMP +>>>/10000/ +EOF |