(t *testing.T)
| 93 | } |
| 94 | |
| 95 | func (s) TestBufferSlice_MaterializeToBuffer(t *testing.T) { |
| 96 | tests := []struct { |
| 97 | name string |
| 98 | in mem.BufferSlice |
| 99 | pool mem.BufferPool |
| 100 | wantData []byte |
| 101 | }{ |
| 102 | { |
| 103 | name: "single", |
| 104 | in: mem.BufferSlice{newBuffer([]byte("abcd"), nil)}, |
| 105 | pool: nil, // MaterializeToBuffer should not use the pool in this case. |
| 106 | wantData: []byte("abcd"), |
| 107 | }, |
| 108 | { |
| 109 | name: "multiple", |
| 110 | in: mem.BufferSlice{ |
| 111 | newBuffer([]byte("abcd"), nil), |
| 112 | newBuffer([]byte("abcd"), nil), |
| 113 | newBuffer([]byte("abcd"), nil), |
| 114 | }, |
| 115 | pool: mem.DefaultBufferPool(), |
| 116 | wantData: []byte("abcdabcdabcd"), |
| 117 | }, |
| 118 | } |
| 119 | for _, tt := range tests { |
| 120 | t.Run(tt.name, func(t *testing.T) { |
| 121 | defer tt.in.Free() |
| 122 | got := tt.in.MaterializeToBuffer(tt.pool) |
| 123 | defer got.Free() |
| 124 | if !bytes.Equal(got.ReadOnlyData(), tt.wantData) { |
| 125 | t.Errorf("BufferSlice.MaterializeToBuffer() = %s, want %s", string(got.ReadOnlyData()), string(tt.wantData)) |
| 126 | } |
| 127 | }) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | func (s) TestBufferSlice_Reader(t *testing.T) { |
| 132 | bs := mem.BufferSlice{ |
nothing calls this directly
no test coverage detected