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

Function Test_Bytes_UnmarshalYAML

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

Source from the content-addressed store, hash-verified

116}
117
118func Test_Bytes_UnmarshalYAML(t *testing.T) {
119 for _, tcase := range []struct {
120 input string
121 expected uint64
122 }{
123 {
124 input: "1.5GiB\n",
125 expected: (1024 + 512) * 1024 * 1024,
126 },
127 {
128 input: "1.5GB\n",
129 expected: (1024 + 512) * 1024 * 1024,
130 },
131 {
132 input: "1536MiB\n",
133 expected: (1024 + 512) * 1024 * 1024,
134 },
135 {
136 input: "1536MB\n",
137 expected: (1024 + 512) * 1024 * 1024,
138 },
139 {
140 input: "1GiB\n",
141 expected: 1024 * 1024 * 1024,
142 },
143 {
144 input: "1GB\n",
145 expected: 1024 * 1024 * 1024,
146 },
147 {
148 input: "1MiB\n",
149 expected: 1024 * 1024,
150 },
151 {
152 input: "1MB\n",
153 expected: 1024 * 1024,
154 },
155 {
156 input: "1KiB\n",
157 expected: 1024,
158 },
159 {
160 input: "1KB\n",
161 expected: 1024,
162 },
163 } {
164 var b Bytes
165 require.NoError(t, yaml.Unmarshal([]byte(tcase.input), &b))
166 require.Equal(t, Bytes(tcase.expected), b)
167 }
168}

Callers

nothing calls this directly

Calls 3

BytesTypeAlias · 0.85
UnmarshalMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected