toybox/tests/fmt.test
<<
>>
Prefs
   1#!/bin/bash
   2
   3[ -f testing.sh ] && . testing.sh
   4
   5echo "hello world " > en.txt
   6echo "this is some text    " >> en.txt
   7# https://en.wikipedia.org/wiki/Aegukga
   8echo "동해물과 백두산이 마르고 닳도록" > kr.txt
   9echo "하나님이 보우하사 우리나라 만세." >> kr.txt
  10
  11#testing "name" "command" "result" "infile" "stdin"
  12
  13testing "join" "fmt en.txt" "hello world this is some text\n" "" ""
  14testing "split" "fmt -w 10 en.txt" "hello\nworld\nthis is\nsome text\n" "" ""
  15testing "no room" "echo 'hello world' | fmt -w 1" "hello\nworld\n" "" ""
  16testing "blank line" "echo -e 'first paragraph of text\n\nand another' | fmt -w 10" "first\nparagraph\nof text\n\nand\nanother\n" "" ""
  17testing "ws-only line" "echo -e 'hello\n  \nworld' | fmt -w 10" "hello\n\nworld\n" "" ""
  18testing "leading space" "echo '  hello world' | fmt -w 5" "  hello\n  world\n" "" ""
  19testing "utf8" "fmt -w 10 kr.txt" "동해물과\n백두산이\n마르고\n닳도록\n하나님이\n보우하사\n우리나라\n만세.\n" "" ""
  20
  21rm en.txt kr.txt
  22