MCPcopy
hub / github.com/grafana/dskit / Test_Bytes_Set

Function Test_Bytes_Set

flagext/bytes_test.go:37–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func Test_Bytes_Set(t *testing.T) {
38 for _, tcase := range []struct {
39 input string
40 expected uint64
41 }{
42 {
43 input: "1.5GiB",
44 expected: (1024 + 512) * 1024 * 1024,
45 },
46 {
47 input: "1.5GB",
48 expected: (1024 + 512) * 1024 * 1024,
49 },
50 {
51 input: "1536MiB",
52 expected: (1024 + 512) * 1024 * 1024,
53 },
54 {
55 input: "1536MB",
56 expected: (1024 + 512) * 1024 * 1024,
57 },
58
59 {
60 input: "1GiB",
61 expected: 1024 * 1024 * 1024,
62 },
63 {
64 input: "1GB",
65 expected: 1024 * 1024 * 1024,
66 },
67 {
68 input: "1MiB",
69 expected: 1024 * 1024,
70 },
71 {
72 input: "1MB",
73 expected: 1024 * 1024,
74 },
75 {
76 input: "1KiB",
77 expected: 1024,
78 },
79 {
80 input: "1KB",
81 expected: 1024,
82 },
83 } {
84 var b Bytes
85 require.NoError(t, b.Set(tcase.input))
86 require.Equal(t, b, Bytes(tcase.expected))
87 }
88}
89func Test_Bytes_MarshalYAML(t *testing.T) {
90 for _, tcase := range []struct {
91 input uint64

Callers

nothing calls this directly

Calls 3

SetMethod · 0.95
BytesTypeAlias · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected