-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformat_test.go
55 lines (46 loc) · 1.3 KB
/
format_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package core
import (
"testing"
)
func TestReadableSize(t *testing.T) {
got := ReadableSize(12.123)
expect := "12.1B"
if got != expect {
t.Errorf("ReadableSize:\n Expect => %v\n Got => %v\n", expect, got)
}
got = ReadableSize(1124.123)
expect = "1.1K"
if got != expect {
t.Errorf("ReadableSize:\n Expect => %v\n Got => %v\n", expect, got)
}
got = ReadableSize(1024 * 1024 * 8)
expect = "8.0M"
if got != expect {
t.Errorf("ReadableSize:\n Expect => %v\n Got => %v\n", expect, got)
}
got = ReadableSize(1024 * 1024 * 1024 * 8)
expect = "8.0G"
if got != expect {
t.Errorf("ReadableSize:\n Expect => %v\n Got => %v\n", expect, got)
}
got = ReadableSize(1024 * 1024 * 1024 * 1024 * 8)
expect = "8.0T"
if got != expect {
t.Errorf("ReadableSize:\n Expect => %v\n Got => %v\n", expect, got)
}
got = ReadableSize(1024 * 1024 * 1024 * 1024 * 1024 * 8)
expect = "8.0P"
if got != expect {
t.Errorf("ReadableSize:\n Expect => %v\n Got => %v\n", expect, got)
}
got = ReadableSize(1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 8)
expect = "TooLarge"
if got != expect {
t.Errorf("ReadableSize:\n Expect => %v\n Got => %v\n", expect, got)
}
got = ReadableSize(0)
expect = "0.0B"
if got != expect {
t.Errorf("ReadableSize:\n Expect => %v\n Got => %v\n", expect, got)
}
}