diff options
author | Rob Landley <rob@landley.net> | 2021-07-20 16:02:31 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-20 16:29:22 +0200 |
commit | 0068ce2fa0e3dbc618b8ca87ab56e144731da784 (patch) | |
tree | 6f4d2d6cd45089b7fdb67fcdfcb4f85baba6976e /testsuite | |
parent | dabbeeb79356eef78528acd55e1f143ae80372f7 (diff) |
cut: add toybox-compatible options -O OUTSEP, -D, -F LIST
function old new delta
cut_main 884 1201 +317
packed_usage 33823 33885 +62
.rodata 104186 104179 -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 379/-7) Total: 372 bytes
Signed-off-by: Rob Landley <rob@landley.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/cut.tests | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/testsuite/cut.tests b/testsuite/cut.tests index 110340277..d705b91c3 100755 --- a/testsuite/cut.tests +++ b/testsuite/cut.tests @@ -15,4 +15,68 @@ testing "cut '-' (stdin) and multi file handling" \ "the quick brown fox\n" \ "jumps over the lazy dog\n" \ +abc="\ +one:two:three:four:five:six:seven +alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu +the quick brown fox jumps over the lazy dog +" + +testing "cut -b a,a,a" "cut -b 3,3,3 input" "e\np\ne\n" "$abc" "" + +testing "cut -b overlaps" "cut -b 1-3,2-5,7-9,9-10 input" \ + "one:to:th\nalphabeta\nthe qick \n" "$abc" "" +testing "-b encapsulated" "cut -b 3-8,4-6 input" "e:two:\npha:be\ne quic\n" \ + "$abc" "" +# --output-delimiter not implemnted (yet?) +#testing "cut -bO overlaps" \ +# "cut --output-delimiter ' ' -b 1-3,2-5,7-9,9-10 input" \ +# "one:t o:th\nalpha beta\nthe q ick \n" "$abc" "" +testing "cut high-low error" "cut -b 8-3 abc.txt 2>/dev/null || echo err" "err\n" \ + "$abc" "" + +testing "cut -c a-b" "cut -c 4-10 input" ":two:th\nha:beta\n quick \n" "$abc" "" +testing "cut -c a-" "cut -c 41- input" "\ntheta:iota:kappa:lambda:mu\ndog\n" "$abc" "" +testing "cut -c -b" "cut -c -39 input" \ + "one:two:three:four:five:six:seven\nalpha:beta:gamma:delta:epsilon:zeta:eta\nthe quick brown fox jumps over the lazy\n" \ + "$abc" "" +testing "cut -c a" "cut -c 40 input" "\n:\n \n" "$abc" "" +testing "cut -c a,b-c,d" "cut -c 3,5-7,10 input" "etwoh\npa:ba\nequi \n" "$abc" "" + +testing "cut -f a-" "cut -d ':' -f 5- input" "five:six:seven\nepsilon:zeta:eta:theta:iota:kappa:lambda:mu\nthe quick brown fox jumps over the lazy dog\n" "$abc" "" + +testing "cut show whole line with no delim" "cut -d ' ' -f 3 input" \ + "one:two:three:four:five:six:seven\nalpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu\nbrown\n" "$abc" "" + +testing "cut with echo, -c (a-b)" "echo 'ref_categorie=test' | cut -c 1-15 " "ref_categorie=t\n" "" "" +testing "cut with echo, -c (a)" "echo 'ref_categorie=test' | cut -c 14" "=\n" "" "" + +testing "cut with -c (a,b,c)" "cut -c 4,5,20 input" "det\n" "abcdefghijklmnopqrstuvwxyz" "" + +testing "cut with -b (a,b,c)" "cut -b 4,5,20 input" "det\n" "abcdefghijklmnopqrstuvwxyz" "" + +input="\ +406378:Sales:Itorre:Jan +031762:Marketing:Nasium:Jim +636496:Research:Ancholie:Mel +396082:Sales:Jucacion:Ed +" +testing "cut with -d -f(:) -s" "cut -d: -f3 -s input" "Itorre\nNasium\nAncholie\nJucacion\n" "$input" "" +testing "cut with -d -f( ) -s" "cut -d' ' -f3 -s input && echo yes" "yes\n" "$input" "" +testing "cut with -d -f(a) -s" "cut -da -f3 -s input" "n\nsium:Jim\n\ncion:Ed\n" "$input" "" +testing "cut with -d -f(a) -s -n" "cut -da -f3 -s -n input" "n\nsium:Jim\n\ncion:Ed\n" "$input" "" + +# substitute for awk +testing "cut -DF" "cut -DF 2,7,5" \ + "said and your\nare\nis demand. supply\nforecast :\nyou you better,\n\nEm: Took hate\n" "" \ +"Bother, said Pooh. It's your husband, and he has a gun. +Cheerios are donut seeds. +Talk is cheap because supply exceeds demand. +Weather forecast for tonight : dark. +Apple: you can buy better, but you can't pay more. +Subcalifragilisticexpialidocious. +Auntie Em: Hate you, hate Kansas. Took the dog. Dorothy." + +testing "cut empty field" "cut -d ':' -f 1-3" "a::b\n" "" "a::b\n" +testing "cut empty field 2" "cut -d ':' -f 3-5" "b::c\n" "" "a::b::c:d\n" + exit $FAILCOUNT |