forked from cerc-io/plugeth
Restructure StorageSize string test
This commit is contained in:
parent
be96da179a
commit
a1d62abca4
@ -1,12 +1,31 @@
|
|||||||
package ethutil
|
package ethutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSize(t *testing.T) {
|
func TestStorageSizeString(t *testing.T) {
|
||||||
fmt.Println(StorageSize(2381273))
|
data1 := 2381273
|
||||||
fmt.Println(StorageSize(2192))
|
data2 := 2192
|
||||||
fmt.Println(StorageSize(12))
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user