aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2017-12-23 23:44:04 -0800
committerRob Landley <rob@landley.net>2017-12-24 11:21:12 -0600
commit4335501bf3269ac86b7bfdf236aa763d380327e2 (patch)
tree7dc5a0742fd40bba26efb628e77757434755c986 /tests
parent17bcad9d44600d3f9f62d88e5a53cd037c8dec13 (diff)
downloadtoybox-4335501bf3269ac86b7bfdf236aa763d380327e2.tar.gz
Add fmt.
A very simple implementation of fmt, good enough for my daily use of !!fmt in vi to reflow checkin comments like this.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/fmt.test21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/fmt.test b/tests/fmt.test
new file mode 100755
index 00000000..0d5c5bd4
--- /dev/null
+++ b/tests/fmt.test
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+echo "hello world " > en.txt
+echo "this is some text " >> en.txt
+# https://en.wikipedia.org/wiki/Aegukga
+echo "동해물과 백두산이 마르고 닳도록" > kr.txt
+echo "하나님이 보우하사 우리나라 만세." >> kr.txt
+
+#testing "name" "command" "result" "infile" "stdin"
+
+testing "join" "fmt en.txt" "hello world this is some text\n" "" ""
+testing "split" "fmt -w 10 en.txt" "hello\nworld\nthis is\nsome text\n" "" ""
+testing "no room" "echo 'hello world' | fmt -w 1" "hello\nworld\n" "" ""
+testing "blank line" "echo -e 'first paragraph of text\n\nand another' | fmt -w 10" "first\nparagraph\nof text\n\nand\nanother\n" "" ""
+testing "ws-only line" "echo -e 'hello\n \nworld' | fmt -w 10" "hello\n\nworld\n" "" ""
+testing "leading space" "echo ' hello world' | fmt -w 5" " hello\n world\n" "" ""
+testing "utf8" "fmt -w 10 kr.txt" "동해물과\n백두산이\n마르고\n닳도록\n하나님이\n보우하사\n우리나라\n만세.\n" "" ""
+
+rm en.txt kr.txt