blob: 2a27c0933d305caed1da408043c49558afbd4cf1 [file] [log] [blame]
Rob Landley55ec0102013-06-16 23:08:09 -05001#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7testing "split" "seq 1 12345 | split && ls xa[a-z] | wc -l" "13\n" "" ""
8rm xa[a-z]
9
Rob Landley336c44a2016-03-02 15:20:04 -060010testing "-" "seq 1 12345 | split - && ls xa[a-z] | wc -l" "13\n" "" ""
Rob Landley55ec0102013-06-16 23:08:09 -050011rm xa[a-z]
12
13seq 1 12345 > file
Rob Landley336c44a2016-03-02 15:20:04 -060014testing "file" "split file && ls xa[a-z] | wc -l" "13\n" "" ""
Rob Landley55ec0102013-06-16 23:08:09 -050015rm xa[a-z]
16
Rob Landley336c44a2016-03-02 15:20:04 -060017testing "-l" "split file -l 10k && wc -l xab" "2105 xab\n" "" ""
Rob Landley55ec0102013-06-16 23:08:09 -050018rm xa[ab]
19
Rob Landley336c44a2016-03-02 15:20:04 -060020testing "suffix exhaustion" \
Rob Landley55ec0102013-06-16 23:08:09 -050021 "split file -l 10 -a 1 walrus 2>/dev/null || ls walrus* | wc -l" "26\n" "" ""
22rm walrus*
23
Rob Landley336c44a2016-03-02 15:20:04 -060024testing "bytes" \
Rob Landley55ec0102013-06-16 23:08:09 -050025 "toybox seq 1 20000 | split -b 100 -a 3 - whang && ls whang* | wc -l && wc -c whangbpw" "1089\n94 whangbpw\n" "" ""
26
Rob Landley336c44a2016-03-02 15:20:04 -060027testing "reassembly" \
Rob Landley55ec0102013-06-16 23:08:09 -050028 'diff -u <(ls whang* | sort | xargs cat) <(seq 1 20000) && echo yes' \
29 "yes\n" "" ""
30
31rm file whang*