mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
f1e010a5a7
Allows tap.sh to show the line number where the helper function was called on failures. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
58 lines
995 B
Bash
Executable File
58 lines
995 B
Bash
Executable File
#!/bin/bash
|
|
|
|
source "$(dirname "$0")"/../tap.sh || exit 1
|
|
|
|
# source the library function
|
|
lib=${1:-${PMTEST_SCRIPTLIB_DIR}human_to_size.sh}
|
|
if [[ -z $lib || ! -f $lib ]]; then
|
|
tap_bail "human_to_size library (%s) could not be located" "${lib}"
|
|
exit 1
|
|
fi
|
|
. "$lib"
|
|
|
|
if ! type -t human_to_size &>/dev/null; then
|
|
tap_bail "human_to_size function not found"
|
|
exit 1
|
|
fi
|
|
|
|
tap_parse_hts() {
|
|
local input=$1 expected=$2
|
|
tap_is_str "$(human_to_size "$input")" "$expected" "$input"
|
|
}
|
|
|
|
tap_plan 15
|
|
|
|
# tap_parse_hts <input> <expected output>
|
|
|
|
tap_parse_hts '1MiB' 1048576
|
|
|
|
tap_parse_hts '10XiB' ''
|
|
|
|
tap_parse_hts '10 MiB' 10485760
|
|
|
|
tap_parse_hts '10 XiB' ''
|
|
|
|
tap_parse_hts '.1 TiB' 109951162778
|
|
|
|
tap_parse_hts ' -3 KiB ' -3072
|
|
|
|
tap_parse_hts 'foo3KiB' ''
|
|
|
|
tap_parse_hts '3KiBfoo' ''
|
|
|
|
tap_parse_hts '3kib' ''
|
|
|
|
tap_parse_hts '+1KiB' 1024
|
|
|
|
tap_parse_hts '+1.0 KiB' 1024
|
|
|
|
tap_parse_hts '1MB' 1000000
|
|
|
|
tap_parse_hts '1M' 1048576
|
|
|
|
tap_parse_hts ' 1 G ' 1073741824
|
|
|
|
tap_parse_hts '1Q' ''
|
|
|
|
# vim: set noet:
|