MCPcopy Create free account
hub / github.com/labstack/gommon / TestBytesFormat

Function TestBytesFormat

bytes/bytes_test.go:10–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestBytesFormat(t *testing.T) {
11 // B
12 b := Format(0)
13 assert.Equal(t, "0", b)
14 // B
15 b = Format(515)
16 assert.Equal(t, "515B", b)
17
18 // KiB
19 b = Format(31323)
20 assert.Equal(t, "30.59KiB", b)
21
22 // MiB
23 b = Format(13231323)
24 assert.Equal(t, "12.62MiB", b)
25
26 // GiB
27 b = Format(7323232398)
28 assert.Equal(t, "6.82GiB", b)
29
30 // TiB
31 b = Format(7323232398434)
32 assert.Equal(t, "6.66TiB", b)
33
34 // PiB
35 b = Format(9923232398434432)
36 assert.Equal(t, "8.81PiB", b)
37
38 // EiB
39 b = Format(math.MaxInt64)
40 assert.Equal(t, "8.00EiB", b)
41
42 // KB
43 b = FormatDecimal(31323)
44 assert.Equal(t, "31.32KB", b)
45
46 // MB
47 b = FormatDecimal(13231323)
48 assert.Equal(t, "13.23MB", b)
49
50 // GB
51 b = FormatDecimal(7323232398)
52 assert.Equal(t, "7.32GB", b)
53
54 // TB
55 b = FormatDecimal(7323232398434)
56 assert.Equal(t, "7.32TB", b)
57
58 // PB
59 b = FormatDecimal(9923232398434432)
60 assert.Equal(t, "9.92PB", b)
61
62 // EB
63 b = FormatDecimal(math.MaxInt64)
64 assert.Equal(t, "9.22EB", b)
65}
66
67func TestBytesParseErrors(t *testing.T) {

Callers

nothing calls this directly

Calls 2

FormatFunction · 0.85
FormatDecimalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…