aboutsummaryrefslogtreecommitdiff
path: root/tests/cut.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-09-20 13:09:14 -0500
committerRob Landley <rob@landley.net>2014-09-20 13:09:14 -0500
commit387edf547eb09b27ca6d49772eb048d729f09cf4 (patch)
tree59d482f33735690cab6d90723393afa1e2c8dce5 /tests/cut.test
parentd3df423a6cde0c6282658ff628574771d3824d71 (diff)
downloadtoybox-387edf547eb09b27ca6d49772eb048d729f09cf4.tar.gz
Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Diffstat (limited to 'tests/cut.test')
-rw-r--r--tests/cut.test47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/cut.test b/tests/cut.test
new file mode 100644
index 00000000..a0019527
--- /dev/null
+++ b/tests/cut.test
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
+# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
+# Copyright 2013 Kyungwan.Han <asura321@gmail.com>
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+#set -x
+
+# Creating test file for testing cut
+echo "one:two:three:four:five:six:seven
+alpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu
+the quick brown fox jumps over the lazy dog" >abc.txt
+
+testing "cut with -c (a-b)" "cut -c 4-10 abc.txt" ":two:th\nha:beta\n quick \n" "" ""
+testing "cut with -f (a-)" "cut -d ':' -f 5- abc.txt" "five:six:seven\nepsilon:zeta:eta:teta:iota:kappa:lambda:mu\nthe quick brown fox jumps over the lazy dog\n" "" ""
+
+testing "cut with -f (a)" "cut -d ' ' -f 3 abc.txt" "one:two:three:four:five:six:seven\nalpha:beta:gamma:delta:epsilon:zeta:eta:teta:iota:kappa:lambda:mu\nbrown\n" "" ""
+
+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" "" ""
+
+# Modifying abc.txt data as per new testcase
+echo "abcdefghijklmnopqrstuvwxyz" >abc.txt
+
+testing "cut with -c (a,b,c)" "cut -c 4,5,20 abc.txt" "det\n" "" ""
+
+testing "cut with -b (a,b,c)" "cut -b 4,5,20 abc.txt" "det\n" "" ""
+
+# Modifying abc.txt data as per testcase
+echo "406378:Sales:Itorre:Jan
+031762:Marketing:Nasium:Jim
+636496:Research:Ancholie:Mel
+396082:Sales:Jucacion:Ed" >abc.txt
+
+testing "cut with -d -f(:) -s" "cut -d: -f3 -s abc.txt" "Itorre\nNasium\nAncholie\nJucacion\n" "" ""
+
+testing "cut with -d -f( ) -s" "cut -d' ' -f3 -s abc.txt && echo yes" "yes\n" "" ""
+
+testing "cut with -d -f(a) -s" "cut -da -f3 -s abc.txt" "n\nsium:Jim\n\ncion:Ed\n" "" ""
+
+testing "cut with -d -f(a) -s -n" "cut -da -f3 -s -n abc.txt" "n\nsium:Jim\n\ncion:Ed\n" "" ""
+
+# Removing abc.txt file for cleanup purpose
+rm abc.txt