1*cf5a6c84SAndroid Build Coastguard Worker#!/bin/bash 2*cf5a6c84SAndroid Build Coastguard Worker 3*cf5a6c84SAndroid Build Coastguard Worker[ -f testing.sh ] && . testing.sh 4*cf5a6c84SAndroid Build Coastguard Worker 5*cf5a6c84SAndroid Build Coastguard Worker#testing "name" "command" "result" "infile" "stdin" 6*cf5a6c84SAndroid Build Coastguard Worker 7*cf5a6c84SAndroid Build Coastguard Workertesting "nl" "nl" " 1\tone\n 2\ttwo\n 3\tthree\n" \ 8*cf5a6c84SAndroid Build Coastguard Worker "" "one\ntwo\nthree\n" 9*cf5a6c84SAndroid Build Coastguard Worker 10*cf5a6c84SAndroid Build Coastguard Workertesting "explicit defaults" "nl -nrn -b a" \ 11*cf5a6c84SAndroid Build Coastguard Worker " 1\tone\n 2\ttwo\n 3\tthree\n" "" "one\ntwo\nthree\n" 12*cf5a6c84SAndroid Build Coastguard Worker 13*cf5a6c84SAndroid Build Coastguard Worker# -n ln rn rz 14*cf5a6c84SAndroid Build Coastguard Worker 15*cf5a6c84SAndroid Build Coastguard Workertesting "-nln" "nl -nln" "1 \tone\n2 \ttwo\n3 \tthree\n" \ 16*cf5a6c84SAndroid Build Coastguard Worker "" "one\ntwo\nthree\n" 17*cf5a6c84SAndroid Build Coastguard Workertesting "-nln -w" "nl -nln -w 8" \ 18*cf5a6c84SAndroid Build Coastguard Worker "1 \tone\n2 \ttwo\n3 \tthree\n" "" "one\ntwo\nthree\n" 19*cf5a6c84SAndroid Build Coastguard Worker 20*cf5a6c84SAndroid Build Coastguard Workertesting "-nrz" "nl -nrz" "000001\tone\n000002\ttwo\n000003\tthree\n" \ 21*cf5a6c84SAndroid Build Coastguard Worker "" "one\ntwo\nthree\n" 22*cf5a6c84SAndroid Build Coastguard Worker 23*cf5a6c84SAndroid Build Coastguard Workertesting "-nrz -w" "nl -w3 -nrz" "001\tone\n002\ttwo\n003\tthree\n" \ 24*cf5a6c84SAndroid Build Coastguard Worker "" "one\ntwo\nthree\n" 25*cf5a6c84SAndroid Build Coastguard Worker 26*cf5a6c84SAndroid Build Coastguard Worker 27*cf5a6c84SAndroid Build Coastguard Worker# For non-matching lines the separator is "suppressed" meaning it... 28*cf5a6c84SAndroid Build Coastguard Worker# turns into spaces! And the tab turns into one space, and -d boom turns 29*cf5a6c84SAndroid Build Coastguard Worker# into 4 spaces, but these: 30*cf5a6c84SAndroid Build Coastguard Worker# nl -s"$(echo -e 'bo\tom')" -bpand README 31*cf5a6c84SAndroid Build Coastguard Worker# nl -w 3 -bpthe README 32*cf5a6c84SAndroid Build Coastguard Worker# Yeah. And I doubt utf8 fontmetrics are used either. 33*cf5a6c84SAndroid Build Coastguard Worker 34*cf5a6c84SAndroid Build Coastguard Workertesting "-b t" "nl -b t" " \n 1\tone\n \n 2\ttwo\n" \ 35*cf5a6c84SAndroid Build Coastguard Worker "" "\none\n\ntwo\n" 36*cf5a6c84SAndroid Build Coastguard Workertesting "-b n" "nl -b n" " one\n two\n three\n" \ 37*cf5a6c84SAndroid Build Coastguard Worker "" "one\ntwo\nthree\n" 38*cf5a6c84SAndroid Build Coastguard Workertesting "-sook -b p" "nl -sook -bpoing" \ 39*cf5a6c84SAndroid Build Coastguard Worker " one\n 1ookboing\n 2ooksproingy\n" \ 40*cf5a6c84SAndroid Build Coastguard Worker "" "one\nboing\nsproingy\n" 41*cf5a6c84SAndroid Build Coastguard Worker 42*cf5a6c84SAndroid Build Coastguard Workertesting "-v42" "nl -v 42" " 42\tone\n 43\ttwo\n 44\tthree\n" \ 43*cf5a6c84SAndroid Build Coastguard Worker "" "one\ntwo\nthree\n" 44*cf5a6c84SAndroid Build Coastguard Workertesting "-v-1" "nl -v -1" " -1\tone\n 0\ttwo\n 1\tthree\n" \ 45*cf5a6c84SAndroid Build Coastguard Worker "" "one\ntwo\nthree\n" 46*cf5a6c84SAndroid Build Coastguard Workertesting "-v0" "nl -v 0" " 0\tone\n 1\ttwo\n 2\tthree\n" \ 47*cf5a6c84SAndroid Build Coastguard Worker "" "one\ntwo\nthree\n" 48*cf5a6c84SAndroid Build Coastguard Worker 49*cf5a6c84SAndroid Build Coastguard Workertesting "-l" "nl -ba -l2 -w2 - input" \ 50*cf5a6c84SAndroid Build Coastguard Worker " 1\tone\n \n 2\t\n 3\ttwo\n \n 4\t\n \n 5\tthree\n 6\tfour\n \n 7\t\n \n 8\tbang\n \n" \ 51*cf5a6c84SAndroid Build Coastguard Worker "\n\nbang\n\n" "one\n\n\ntwo\n\n\n\nthree\nfour\n\n" 52*cf5a6c84SAndroid Build Coastguard Workertesting "no space" "nl -w 1 -v 42" "42\tline\n" "" "line\n" 53*cf5a6c84SAndroid Build Coastguard Worker 54*cf5a6c84SAndroid Build Coastguard Worker# Should test for -E but no other implementation seems to have it? 55*cf5a6c84SAndroid Build Coastguard Workertoyonly testing "-E" "nl -w2 -sx -Ebp'(one|two)'" " 1xone\n and\n 2xtwo\n" \ 56*cf5a6c84SAndroid Build Coastguard Worker "" "one\nand\ntwo\n" 57