fs: Extend SizeSuffix to include TB and PB for rclone about

This commit is contained in:
Nick Craig-Wood
2018-04-17 21:47:20 +01:00
parent 1ac6dacf0f
commit ef3bcec76c
3 changed files with 30 additions and 15 deletions

View File

@ -44,6 +44,9 @@ func TestSizeSuffixUnit(t *testing.T) {
{1024 * 1024 * 1024, "1 GBytes"},
{10 * 1024 * 1024 * 1024, "10 GBytes"},
{10.1 * 1024 * 1024 * 1024, "10.100 GBytes"},
{10 * 1024 * 1024 * 1024 * 1024, "10 TBytes"},
{10 * 1024 * 1024 * 1024 * 1024 * 1024, "10 PBytes"},
{1 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024, "1024 PBytes"},
{-1, "off"},
{-100, "off"},
} {
@ -70,20 +73,22 @@ func TestSizeSuffixSet(t *testing.T) {
{"1M", 1024 * 1024, false},
{"1.g", 1024 * 1024 * 1024, false},
{"10G", 10 * 1024 * 1024 * 1024, false},
{"10T", 10 * 1024 * 1024 * 1024 * 1024, false},
{"10P", 10 * 1024 * 1024 * 1024 * 1024 * 1024, false},
{"off", -1, false},
{"OFF", -1, false},
{"", 0, true},
{"1p", 0, true},
{"1.p", 0, true},
{"1p", 0, true},
{"1q", 0, true},
{"1.q", 0, true},
{"1q", 0, true},
{"-1K", 0, true},
} {
ss := SizeSuffix(0)
err := ss.Set(test.in)
if test.err {
require.Error(t, err)
require.Error(t, err, test.in)
} else {
require.NoError(t, err)
require.NoError(t, err, test.in)
}
assert.Equal(t, test.want, int64(ss))
}