Skip to content

Commit

Permalink
common: increase StorageSize test coverage (ethereum#25188)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadoy authored and sadoci committed Jul 7, 2023
1 parent f44ec8d commit c8e56c8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions common/size_test.go
Expand Up @@ -25,6 +25,8 @@ func TestStorageSizeString(t *testing.T) {
size StorageSize
str string
}{
{2839274474874, "2.58 TiB"},
{2458492810, "2.29 GiB"},
{2381273, "2.27 MiB"},
{2192, "2.14 KiB"},
{12, "12.00 B"},
Expand All @@ -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)
}
}
}

0 comments on commit c8e56c8

Please sign in to comment.