plugeth/ethutil/size_test.go

36 lines
600 B
Go
Raw Normal View History

2014-08-25 10:53:06 +00:00
package ethutil
import (
2014-11-11 18:05:23 +00:00
checker "gopkg.in/check.v1"
2014-08-25 10:53:06 +00:00
)
2014-11-11 18:05:23 +00:00
type SizeSuite struct{}
var _ = checker.Suite(&SizeSuite{})
func (s *SizeSuite) TestStorageSizeString(c *checker.C) {
2014-11-05 21:16:44 +00:00
data1 := 2381273
data2 := 2192
data3 := 12
exp1 := "2.38 mB"
exp2 := "2.19 kB"
exp3 := "12.00 B"
res1 := StorageSize(data1).String()
res2 := StorageSize(data2).String()
res3 := StorageSize(data3).String()
if res1 != exp1 {
t.Errorf("Expected %s got %s", exp1, res1)
}
if res2 != exp2 {
t.Errorf("Expected %s got %s", exp2, res2)
}
if res3 != exp3 {
t.Errorf("Expected %s got %s", exp3, res3)
}
2014-08-25 10:53:06 +00:00
}