| 1506 | |
| 1507 | template <typename U> |
| 1508 | void CheckDecode(std::span<const uint8_t> encoded_data, |
| 1509 | std::span<const U> expected_decoded_data, |
| 1510 | const ColumnDescriptor* descr = nullptr) { |
| 1511 | static_assert(sizeof(U) == sizeof(c_type)); |
| 1512 | static_assert(std::is_same_v<U, FLBA> == std::is_same_v<c_type, FLBA>); |
| 1513 | |
| 1514 | std::unique_ptr<TypedDecoder<Type>> decoder = |
| 1515 | MakeTypedDecoder<Type>(Encoding::BYTE_STREAM_SPLIT, descr); |
| 1516 | int num_elements = static_cast<int>(expected_decoded_data.size()); |
| 1517 | decoder->SetData(num_elements, encoded_data.data(), |
| 1518 | static_cast<int>(encoded_data.size())); |
| 1519 | std::vector<U> decoded_data(num_elements); |
| 1520 | int num_decoded_elements = |
| 1521 | decoder->Decode(reinterpret_cast<c_type*>(decoded_data.data()), num_elements); |
| 1522 | ASSERT_EQ(num_elements, num_decoded_elements); |
| 1523 | // Compare to expected values |
| 1524 | if constexpr (std::is_same_v<c_type, FLBA>) { |
| 1525 | auto type_length = descr->type_length(); |
| 1526 | for (int i = 0; i < num_elements; ++i) { |
| 1527 | ASSERT_TRUE(std::ranges::equal( |
| 1528 | std::span<const uint8_t>(expected_decoded_data[i].ptr, type_length), |
| 1529 | std::span<const uint8_t>(decoded_data[i].ptr, type_length))); |
| 1530 | } |
| 1531 | } else { |
| 1532 | for (int i = 0; i < num_elements; ++i) { |
| 1533 | ASSERT_EQ(expected_decoded_data[i], decoded_data[i]); |
| 1534 | } |
| 1535 | } |
| 1536 | ASSERT_EQ(0, decoder->values_left()); |
| 1537 | } |
| 1538 | |
| 1539 | template <typename U> |
| 1540 | void CheckEncode(std::span<const U> data, |
nothing calls this directly
no test coverage detected