• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/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 -f xa[a-z]
9
10testing "-" "seq 1 12345 | split - && ls xa[a-z] | wc -l" "13\n" "" ""
11rm -f xa[a-z]
12
13seq 1 12345 > file
14testing "file" "split file && ls xa[a-z] | wc -l" "13\n" "" ""
15rm -f xa[a-z]
16
17toyonly testing "-l" "split file -l 10k && wc -l xab" "2105 xab\n" "" ""
18rm -f xa[ab]
19
20testing "suffix exhaustion" \
21  "split file -l 10 -a 1 walrus 2>/dev/null || ls walrus* | wc -l" "26\n" "" ""
22rm -f walrus*
23
24testing "bytes" \
25  "seq 1 20000 | split -b 100 -a 3 - whang && ls whang* | wc -l && wc -c whangbpw" "1089\n94 whangbpw\n" "" ""
26
27testing "reassembly" \
28  'ls whang* | sort | xargs cat > reassembled && seq 1 20000 | diff -u reassembled - && echo yes' \
29  "yes\n" "" ""
30rm -f file whang* reassembled
31
32testing "-n" "split -n 3 input; md5sum xaa xab xac" \
33  "494bb8fb423bfa1a5fd66dd0b98f866d  xaa\n449acfdbc692780de30a2df05c5d32aa  xab\n15ab4be57aebe9a1e445195d5094036c  xac\n" \
34  "$(seq 1 10000)" ""
35
36