| 219 | } |
| 220 | |
| 221 | Status StreamingDecompress(Codec* decompressor, int64_t input_len, uint8_t* input, |
| 222 | int64_t uncompressed_len, uint8_t* uncompressed_input, bool expected_stream_end, |
| 223 | int64_t* bytes_decompressed = NULL) { |
| 224 | // Should take multiple calls to ProcessBlockStreaming() to decompress the buffer. |
| 225 | int64_t decompressed_len = 0; |
| 226 | int64_t compressed_bytes_remaining = input_len; |
| 227 | uint8_t* compressed_input = input; |
| 228 | bool stream_end; |
| 229 | do { |
| 230 | uint8_t* output = NULL; |
| 231 | int64_t output_len = 0; |
| 232 | int64_t compressed_bytes_read = 0; |
| 233 | RETURN_IF_ERROR(decompressor->ProcessBlockStreaming(compressed_bytes_remaining, |
| 234 | compressed_input, &compressed_bytes_read, &output_len, &output, &stream_end)); |
| 235 | EXPECT_EQ( |
| 236 | Ubsan::MemCmp(uncompressed_input + decompressed_len, output, output_len), 0); |
| 237 | decompressed_len += output_len; |
| 238 | EXPECT_LE(decompressed_len, uncompressed_len); |
| 239 | compressed_input = compressed_input + compressed_bytes_read; |
| 240 | compressed_bytes_remaining -= compressed_bytes_read; |
| 241 | } while (compressed_bytes_remaining > 0); |
| 242 | |
| 243 | EXPECT_EQ(0, compressed_bytes_remaining); |
| 244 | EXPECT_EQ(stream_end, expected_stream_end); |
| 245 | if (stream_end) { |
| 246 | EXPECT_EQ(decompressed_len, uncompressed_len); |
| 247 | } |
| 248 | if (bytes_decompressed != NULL) *bytes_decompressed = decompressed_len; |
| 249 | |
| 250 | return Status::OK(); |
| 251 | } |
| 252 | |
| 253 | void CompressAndStreamingDecompress(Codec* compressor, Codec* decompressor, |
| 254 | int64_t input_len, uint8_t* input) { |
nothing calls this directly
no test coverage detected