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 jagdeep sidhu committed Jul 4, 2022
1 parent 5242202 commit ac5e6ad
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions common/size_test.go
Original file line number Diff line number Diff line change
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 ac5e6ad

Please sign in to comment.