From d06ea3708d12e3e87fa26441715ac47f6dc63032 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 3 Sep 2015 20:36:44 -0500 Subject: Make human_readable() handle base 1024 units without floating point. Rounds correctly via brute force, displayed digits are decimal even when working with powers of 2, shows at most 3 significant (decimal) digits. (So no "1023M" nonsense, that's 1.0G.) --- tests/test_human_readable.test | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 tests/test_human_readable.test (limited to 'tests/test_human_readable.test') diff --git a/tests/test_human_readable.test b/tests/test_human_readable.test new file mode 100755 index 00000000..a66b4fda --- /dev/null +++ b/tests/test_human_readable.test @@ -0,0 +1,10 @@ +#!/bin/bash + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +testing "human_readable" "test_human_readable 123456789" "123M\n" "" "" +testing "human_readable -b" "test_human_readable -b 123456789" "123MB\n" "" "" +testing "human_readable -s" "test_human_readable -s 123456789" "123 M\n" "" "" +testing "human_readable -i" "test_human_readable -i 5675" "5.5k\n" "" "" -- cgit v1.2.3