(t *testing.T)
| 149 | } |
| 150 | |
| 151 | func TestDecoder_ToBytes(t *testing.T) { |
| 152 | t.Run("to bytes with data", func(t *testing.T) { |
| 153 | decoder := NewDecoder() |
| 154 | decoder.dst = []byte("hello world") |
| 155 | result := decoder.ToBytes() |
| 156 | assert.Equal(t, []byte("hello world"), result) |
| 157 | }) |
| 158 | |
| 159 | t.Run("to bytes with empty data", func(t *testing.T) { |
| 160 | decoder := NewDecoder() |
| 161 | decoder.dst = []byte{} |
| 162 | result := decoder.ToBytes() |
| 163 | assert.Equal(t, []byte(""), result) |
| 164 | }) |
| 165 | |
| 166 | t.Run("to bytes with nil data", func(t *testing.T) { |
| 167 | decoder := NewDecoder() |
| 168 | decoder.dst = nil |
| 169 | result := decoder.ToBytes() |
| 170 | assert.Equal(t, []byte(""), result) |
| 171 | }) |
| 172 | |
| 173 | t.Run("to bytes with unicode data", func(t *testing.T) { |
| 174 | decoder := NewDecoder() |
| 175 | decoder.dst = []byte("你好世界") |
| 176 | result := decoder.ToBytes() |
| 177 | assert.Equal(t, []byte("你好世界"), result) |
| 178 | }) |
| 179 | |
| 180 | t.Run("to bytes with binary data", func(t *testing.T) { |
| 181 | decoder := NewDecoder() |
| 182 | decoder.dst = []byte{0x00, 0x01, 0x02, 0x03} |
| 183 | result := decoder.ToBytes() |
| 184 | assert.Equal(t, []byte{0x00, 0x01, 0x02, 0x03}, result) |
| 185 | }) |
| 186 | |
| 187 | t.Run("to bytes with large data", func(t *testing.T) { |
| 188 | largeData := make([]byte, 1000) |
| 189 | for i := range largeData { |
| 190 | largeData[i] = byte(i % 256) |
| 191 | } |
| 192 | decoder := NewDecoder() |
| 193 | decoder.dst = largeData |
| 194 | result := decoder.ToBytes() |
| 195 | assert.Equal(t, largeData, result) |
| 196 | }) |
| 197 | } |
| 198 | |
| 199 | func TestDecoder_stream(t *testing.T) { |
| 200 | t.Run("success with data", func(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…