Skip to content

Commit c2070f8

Browse files
authored
common: increase StorageSize test coverage (#25188)
1 parent 3e693e1 commit c2070f8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

common/size_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ func TestStorageSizeString(t *testing.T) {
2525
size StorageSize
2626
str string
2727
}{
28+
{2839274474874, "2.58 TiB"},
29+
{2458492810, "2.29 GiB"},
2830
{2381273, "2.27 MiB"},
2931
{2192, "2.14 KiB"},
3032
{12, "12.00 B"},
@@ -36,3 +38,22 @@ func TestStorageSizeString(t *testing.T) {
3638
}
3739
}
3840
}
41+
42+
func TestStorageSizeTerminalString(t *testing.T) {
43+
tests := []struct {
44+
size StorageSize
45+
str string
46+
}{
47+
{2839274474874, "2.58TiB"},
48+
{2458492810, "2.29GiB"},
49+
{2381273, "2.27MiB"},
50+
{2192, "2.14KiB"},
51+
{12, "12.00B"},
52+
}
53+
54+
for _, test := range tests {
55+
if test.size.TerminalString() != test.str {
56+
t.Errorf("%f: got %q, want %q", float64(test.size), test.size.TerminalString(), test.str)
57+
}
58+
}
59+
}

0 commit comments

Comments
 (0)