-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be2cdba
commit 6d53d57
Showing
3 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ doc/site/* | |
csvtk/csvtk* | ||
csvtk/binaries* | ||
doc/site | ||
*ssshtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: go | ||
|
||
os: | ||
- linux | ||
- osx | ||
|
||
go: | ||
- 1.8 | ||
|
||
script: | ||
- ./testdata/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
|
||
test -e ssshtest || wget -q https://raw.githubusercontent.com/ryanlayer/ssshtest/master/ssshtest | ||
|
||
. ssshtest | ||
set -e | ||
|
||
|
||
cd csvtk; go build; cd ..; | ||
app=./csvtk/csvtk | ||
|
||
set +e | ||
|
||
|
||
# ---------------------------------------------------------------------------- | ||
# csvtk headers | ||
# ---------------------------------------------------------------------------- | ||
|
||
for n in 1 10 100 10000 1000000; do | ||
fn() { | ||
cat <(seq $n | awk '{print "c"$1}' | paste -sd,) <(seq $n | paste -sd,) \ | ||
| $app headers | ||
} | ||
run "headers (n=$n)" fn | ||
assert_no_stderr | ||
assert_equal $(cat $STDOUT_FILE | grep -v '#' | wc -l) $n | ||
done | ||
|
||
# ---------------------------------------------------------------------------- | ||
# csvtk stats | ||
# ---------------------------------------------------------------------------- | ||
|
||
for n in 1 10 100 10000 1000000; do | ||
fn() { | ||
cat <(seq $n | awk '{print "c"$1}' | paste -sd,) <(seq $n | paste -sd,) \ | ||
| $app stats | ||
} | ||
run "stats (n=$n)" fn | ||
assert_no_stderr | ||
assert_equal $(cat $STDOUT_FILE | $app space2tab | sed 1d | cut -f 2 | sed 's/,//g') $n | ||
assert_equal $(cat $STDOUT_FILE | $app space2tab | sed 1d | cut -f 3 | sed 's/,//g') 1 | ||
|
||
fn() { | ||
cat <(seq $n | awk '{print "c"$1}' | paste -sd,) <(seq $n | paste -sd,) \ | ||
| $app stats -H | ||
} | ||
run "stats -H (n=$n)" fn | ||
assert_no_stderr | ||
assert_equal $(cat $STDOUT_FILE | $app space2tab | sed 1d | cut -f 2 | sed 's/,//g') $n | ||
assert_equal $(cat $STDOUT_FILE | $app space2tab | sed 1d | cut -f 3 | sed 's/,//g') 2 | ||
|
||
# ----------------------------------------------------------------------- | ||
# transpose | ||
# ----------------------------------------------------------------------- | ||
fn() { | ||
cat <(seq $n | awk '{print "c"$1}' | paste -sd,) <(seq $n | paste -sd,) \ | ||
| $app transpose \ | ||
| $app stats | ||
} | ||
run "transpose & stats (n=$n)" fn | ||
assert_no_stderr | ||
assert_equal $(cat $STDOUT_FILE | $app space2tab | sed 1d | cut -f 2 | sed 's/,//g') 2 | ||
assert_equal $(cat $STDOUT_FILE | $app space2tab | sed 1d | cut -f 3 | sed 's/,//g') $(($n -1)) | ||
|
||
fn() { | ||
cat <(seq $n | awk '{print "c"$1}' | paste -sd,) <(seq $n | paste -sd,) \ | ||
| $app transpose \ | ||
| $app stats -H | ||
} | ||
run "transpose & stats -H (n=$n)" fn | ||
assert_no_stderr | ||
assert_equal $(cat $STDOUT_FILE | $app space2tab | sed 1d | cut -f 2 | sed 's/,//g') 2 | ||
assert_equal $(cat $STDOUT_FILE | $app space2tab | sed 1d | cut -f 3 | sed 's/,//g') $n | ||
done | ||
|
||
|
||
# ---------------------------------------------------------------------------- | ||
# csvtk cut | ||
# ---------------------------------------------------------------------------- | ||
|
||
for n in 1 10 100 10000 1000000; do | ||
fn() { | ||
seq $n | $app cut -H -f 1 | ||
} | ||
run "cut -H -f 1 (n=$n)" fn | ||
assert_no_stderr | ||
assert_equal $(cat $STDOUT_FILE | wc -l) $n | ||
|
||
fn() { | ||
seq $n | $app cut -H -t -f 1 | ||
} | ||
run "cut -H -t -f 1 (n=$n)" fn | ||
assert_no_stderr | ||
assert_equal $(cat $STDOUT_FILE | wc -l) $n | ||
|
||
fn() { | ||
cat <(echo head) <(seq $n) | $app cut -f head | ||
} | ||
run "cut -f head (n=$n)" fn | ||
assert_no_stderr | ||
assert_equal $(cat $STDOUT_FILE | wc -l) $(($n+1)) | ||
done |