common: increase StorageSize test coverage (#25188)

This commit is contained in:
Seungbae.yu 2022-06-29 19:13:00 +09:00 committed by GitHub
parent 3e693e1ef6
commit c2070f8d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -25,6 +25,8 @@ func TestStorageSizeString(t *testing.T) {
size StorageSize size StorageSize
str string str string
}{ }{
{2839274474874, "2.58 TiB"},
{2458492810, "2.29 GiB"},
{2381273, "2.27 MiB"}, {2381273, "2.27 MiB"},
{2192, "2.14 KiB"}, {2192, "2.14 KiB"},
{12, "12.00 B"}, {12, "12.00 B"},
@ -36,3 +38,22 @@ func TestStorageSizeString(t *testing.T) {
} }
} }
} }
func TestStorageSizeTerminalString(t *testing.T) {
tests := []struct {
size StorageSize
str string
}{
{2839274474874, "2.58TiB"},
{2458492810, "2.29GiB"},
{2381273, "2.27MiB"},
{2192, "2.14KiB"},
{12, "12.00B"},
}
for _, test := range tests {
if test.size.TerminalString() != test.str {
t.Errorf("%f: got %q, want %q", float64(test.size), test.size.TerminalString(), test.str)
}
}
}