truncate.sh (705B)
- #!/bin/sh
- # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- plans=24
- WD="$(dirname "$0")"
- target="${WD}/../cmd/truncate"
- . "${WD}/tap.sh"
- touch foo
- wc_c() {
- wc -c "$@" \
- | while read foo bar; do
- printf '%s,' "$foo"
- done
- }
- tt() {
- tt_name="tt_${1}" ; shift
- tt_size="$1" ; shift
- t_args "${tt_name}" '' "$@" foo
- t_cmd "${tt_name}_check" "${tt_size}," wc_c foo
- }
- tt 0 0 -s 0
- tt 666 666 -s 666
- tt 666K 681984 -s 666K
- tt 666KiB 681984 -s 666KiB
- tt 666KB 666000 -s 666KB
- tt 1024 1024 -s 1024
- tt -666 358 -s -666
- tt +666 1024 -s +666
- tt -1024 0 -s -1024
- tt 2560 2560 -s 2560
- tt %1K $((3*1024)) -s %1K
- tt /2K 2048 -s /2K
- rm foo