1*cf5a6c84SAndroid Build Coastguard Worker#!/bin/bash 2*cf5a6c84SAndroid Build Coastguard Worker 3*cf5a6c84SAndroid Build Coastguard Worker# Copyright 2013 Robin Mittal <[email protected]> 4*cf5a6c84SAndroid Build Coastguard Worker# Copyright 2013 Divya Kothari <[email protected]> 5*cf5a6c84SAndroid Build Coastguard Worker# Copyright 2013 Kyungwan.Han <[email protected]> 6*cf5a6c84SAndroid Build Coastguard Worker 7*cf5a6c84SAndroid Build Coastguard Worker[ -f testing.sh ] && . testing.sh 8*cf5a6c84SAndroid Build Coastguard Worker 9*cf5a6c84SAndroid Build Coastguard Worker#testing "name" "command" "result" "infile" "stdin" 10*cf5a6c84SAndroid Build Coastguard Worker 11*cf5a6c84SAndroid Build Coastguard Worker# Creating test file for testing cut 12*cf5a6c84SAndroid Build Coastguard Workerecho "one:two:three:four:five:six:seven 13*cf5a6c84SAndroid Build Coastguard Workeralpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu 14*cf5a6c84SAndroid Build Coastguard Workerthe quick brown fox jumps over the lazy dog" >abc.txt 15*cf5a6c84SAndroid Build Coastguard Worker 16*cf5a6c84SAndroid Build Coastguard Workertestcmd "-b a,a,a" "-b 3,3,3 abc.txt" "e\np\ne\n" "" "" 17*cf5a6c84SAndroid Build Coastguard Workertestcmd "-b overlaps" "-b 1-3,2-5,7-9,9-10 abc.txt" \ 18*cf5a6c84SAndroid Build Coastguard Worker "one:to:th\nalphabeta\nthe qick \n" "" "" 19*cf5a6c84SAndroid Build Coastguard Workertestcmd "-b encapsulated" "-b 3-8,4-6 abc.txt" "e:two:\npha:be\ne quic\n" \ 20*cf5a6c84SAndroid Build Coastguard Worker "" "" 21*cf5a6c84SAndroid Build Coastguard Workertestcmd "-bO overlaps" "-O ' ' -b 1-3,2-5,7-9,9-10 abc.txt" \ 22*cf5a6c84SAndroid Build Coastguard Worker "one:t o:th\nalpha beta\nthe q ick \n" "" "" 23*cf5a6c84SAndroid Build Coastguard Workertestcmd "high-low error" "-b 8-3 abc.txt 2>/dev/null || echo err" "err\n" \ 24*cf5a6c84SAndroid Build Coastguard Worker "" "" 25*cf5a6c84SAndroid Build Coastguard Worker 26*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c a-b" "-c 4-10 abc.txt" ":two:th\nha:beta\n quick \n" "" "" 27*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c a-" "-c 41- abc.txt" "\ntheta:iota:kappa:lambda:mu\ndog\n" "" "" 28*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c -b" "-c -39 abc.txt" \ 29*cf5a6c84SAndroid Build Coastguard Worker "one:two:three:four:five:six:seven\nalpha:beta:gamma:delta:epsilon:zeta:eta\nthe quick brown fox jumps over the lazy\n" \ 30*cf5a6c84SAndroid Build Coastguard Worker "" "" 31*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c a" "-c 40 abc.txt" "\n:\n \n" "" "" 32*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c a,b-c,d" "-c 3,5-7,10 abc.txt" "etwoh\npa:ba\nequi \n" "" "" 33*cf5a6c84SAndroid Build Coastguard Workertoyonly testcmd "-c japan.txt" '-c 3-6,9-12 "$FILES/utf8/japan.txt"' \ 34*cf5a6c84SAndroid Build Coastguard Worker "ガラスをられます\n" "" "" 35*cf5a6c84SAndroid Build Coastguard Worker 36*cf5a6c84SAndroid Build Coastguard Workertoyonly testcmd "-C test1.txt" '-C -1 "$FILES/utf8/test1.txt"' "l̴̗̞̠\n" "" "" 37*cf5a6c84SAndroid Build Coastguard Worker 38*cf5a6c84SAndroid Build Coastguard Worker# substitute for awk 39*cf5a6c84SAndroid Build Coastguard Workertestcmd "-DF" "-DF 2,7,5" \ 40*cf5a6c84SAndroid Build Coastguard Worker "said and your\nare\nis demand. supply\nforecast :\nyou you better,\n\nEm: Took hate\n" "" \ 41*cf5a6c84SAndroid Build Coastguard Worker"Bother, said Pooh. It's your husband, and he has a gun. 42*cf5a6c84SAndroid Build Coastguard WorkerCheerios are donut seeds. 43*cf5a6c84SAndroid Build Coastguard WorkerTalk is cheap because supply exceeds demand. 44*cf5a6c84SAndroid Build Coastguard WorkerWeather forecast for tonight : dark. 45*cf5a6c84SAndroid Build Coastguard WorkerApple: you can buy better, but you can't pay more. 46*cf5a6c84SAndroid Build Coastguard WorkerSubcalifragilisticexpialidocious. 47*cf5a6c84SAndroid Build Coastguard WorkerAuntie Em: Hate you, hate Kansas. Took the dog. Dorothy." 48*cf5a6c84SAndroid Build Coastguard Workertestcmd "-DF 2" "-DF 7,1,3-6,2-5" \ 49*cf5a6c84SAndroid Build Coastguard Worker "seven one three four five six two three four five\n" "" \ 50*cf5a6c84SAndroid Build Coastguard Worker "one two three four five six seven eight nine\n" 51*cf5a6c84SAndroid Build Coastguard Worker 52*cf5a6c84SAndroid Build Coastguard Workertestcmd "empty field" "-d ':' -f 1-3" "a::b\n" "" "a::b\n" 53*cf5a6c84SAndroid Build Coastguard Workertestcmd "empty field 2" "-d ':' -f 3-5" "b::c\n" "" "a::b::c:d\n" 54*cf5a6c84SAndroid Build Coastguard Worker 55*cf5a6c84SAndroid Build Coastguard Workertestcmd "-f a-" "-d ':' -f 5- abc.txt" "five:six:seven\nepsilon:zeta:eta:theta:iota:kappa:lambda:mu\nthe quick brown fox jumps over the lazy dog\n" "" "" 56*cf5a6c84SAndroid Build Coastguard Worker 57*cf5a6c84SAndroid Build Coastguard Workertestcmd "show whole line with no delim" "-d ' ' -f 3 abc.txt" \ 58*cf5a6c84SAndroid Build Coastguard Worker "one:two:three:four:five:six:seven\nalpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu\nbrown\n" "" "" 59*cf5a6c84SAndroid Build Coastguard Worker 60*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c (a-b)" "-c 1-15 " "ref_categorie=t\n" "" "ref_categorie=test\n" 61*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c (a)" "-c 14" "=\n" "" "ref_categorie=test\n" 62*cf5a6c84SAndroid Build Coastguard Worker 63*cf5a6c84SAndroid Build Coastguard Worker# Modifying abc.txt data as per new testcase 64*cf5a6c84SAndroid Build Coastguard Workerecho "abcdefghijklmnopqrstuvwxyz" >abc.txt 65*cf5a6c84SAndroid Build Coastguard Worker 66*cf5a6c84SAndroid Build Coastguard Workertestcmd "-c (a,b,c)" "-c 4,5,20 abc.txt" "det\n" "" "" 67*cf5a6c84SAndroid Build Coastguard Workertestcmd "-b (a,b,c)" "-b 4,5,20 abc.txt" "det\n" "" "" 68*cf5a6c84SAndroid Build Coastguard Worker 69*cf5a6c84SAndroid Build Coastguard Worker# Modifying abc.txt data as per testcase 70*cf5a6c84SAndroid Build Coastguard Workerecho "406378:Sales:Itorre:Jan 71*cf5a6c84SAndroid Build Coastguard Worker031762:Marketing:Nasium:Jim 72*cf5a6c84SAndroid Build Coastguard Worker636496:Research:Ancholie:Mel 73*cf5a6c84SAndroid Build Coastguard Worker396082:Sales:Jucacion:Ed" >abc.txt 74*cf5a6c84SAndroid Build Coastguard Worker 75*cf5a6c84SAndroid Build Coastguard Workertestcmd "-d -f(:) -s" "-d: -f3 -s abc.txt" "Itorre\nNasium\nAncholie\nJucacion\n" "" "" 76*cf5a6c84SAndroid Build Coastguard Workertestcmd "-d -f( ) -s" "-d' ' -f3 -s abc.txt && echo yes" "yes\n" "" "" 77*cf5a6c84SAndroid Build Coastguard Workertestcmd "-d -f(a) -s" "-da -f3 -s abc.txt" "n\nsium:Jim\n\ncion:Ed\n" "" "" 78*cf5a6c84SAndroid Build Coastguard Workertestcmd "-d -f(a) -s -n" "-da -f3 -s -n abc.txt" "n\nsium:Jim\n\ncion:Ed\n" "" "" 79*cf5a6c84SAndroid Build Coastguard Worker 80*cf5a6c84SAndroid Build Coastguard Worker# Feature posix documents but nobody bothers to implement 81*cf5a6c84SAndroid Build Coastguard Workertoyonly testcmd "-nb" '-nb 8-17 "$FILES/utf8/japan.txt"' "ガラス\n" "" "" 82*cf5a6c84SAndroid Build Coastguard Worker 83*cf5a6c84SAndroid Build Coastguard Worker# Feature that is, as far as I can tell, totally undocumented? 84*cf5a6c84SAndroid Build Coastguard Workertestcmd "-d newline" "-d \$'\n' -f 2-3,5" "two\nthree\nfive\n" "" \ 85*cf5a6c84SAndroid Build Coastguard Worker 'one\ntwo\nthree\nfour\nfive\nsix\seven\n' 86*cf5a6c84SAndroid Build Coastguard Worker 87*cf5a6c84SAndroid Build Coastguard Worker# Removing abc.txt file for cleanup purpose 88*cf5a6c84SAndroid Build Coastguard Workerrm abc.txt 89