| 1326 | } |
| 1327 | |
| 1328 | void VerifyDecodingMultipleSetData(Encoding::type encoding, int16_t max_level, |
| 1329 | const std::vector<int16_t>& input_levels, |
| 1330 | std::vector<std::vector<uint8_t>>& bytes) { |
| 1331 | LevelDecoder decoder; |
| 1332 | int levels_count = 0; |
| 1333 | std::vector<int16_t> output_levels; |
| 1334 | |
| 1335 | // Decode levels and test with multiple SetData calls |
| 1336 | int setdata_count = static_cast<int>(bytes.size()); |
| 1337 | int num_levels = static_cast<int>(input_levels.size()) / setdata_count; |
| 1338 | output_levels.resize(num_levels); |
| 1339 | // Try multiple SetData |
| 1340 | for (int ct = 0; ct < setdata_count; ct++) { |
| 1341 | int offset = ct * num_levels; |
| 1342 | ASSERT_EQ(num_levels, static_cast<int>(output_levels.size())); |
| 1343 | decoder.SetData(encoding, max_level, num_levels, bytes[ct].data(), |
| 1344 | static_cast<int32_t>(bytes[ct].size())); |
| 1345 | levels_count = decoder.Decode(num_levels, output_levels.data()); |
| 1346 | ASSERT_EQ(num_levels, levels_count); |
| 1347 | for (int i = 0; i < num_levels; i++) { |
| 1348 | EXPECT_EQ(input_levels[i + offset], output_levels[i]); |
| 1349 | } |
| 1350 | } |
| 1351 | } |
| 1352 | |
| 1353 | // Test levels with maximum bit-width from 1 to 8 |
| 1354 | // increase the repetition count for each iteration by a factor of 2 |