| 87 | } |
| 88 | } |
| 89 | func Test_Bytes_MarshalYAML(t *testing.T) { |
| 90 | for _, tcase := range []struct { |
| 91 | input uint64 |
| 92 | expected string |
| 93 | }{ |
| 94 | { |
| 95 | input: (1024 + 512) * 1024 * 1024, |
| 96 | expected: "1GiB512MiB\n", |
| 97 | }, |
| 98 | { |
| 99 | input: 1024 * 1024 * 1024, |
| 100 | expected: "1GiB\n", |
| 101 | }, |
| 102 | { |
| 103 | input: 1024 * 1024, |
| 104 | expected: "1MiB\n", |
| 105 | }, |
| 106 | { |
| 107 | input: 1024, |
| 108 | expected: "1KiB\n", |
| 109 | }, |
| 110 | } { |
| 111 | b := Bytes(tcase.input) |
| 112 | y, err := yaml.Marshal(b) |
| 113 | require.NoError(t, err) |
| 114 | require.Equal(t, []byte(tcase.expected), y) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | func Test_Bytes_UnmarshalYAML(t *testing.T) { |
| 119 | for _, tcase := range []struct { |