| 108 | protected: |
| 109 | template <typename Int> |
| 110 | void TestRoundtripAlignment(UnpackFunc<Int> unpack, const UnpackOptions& opts) { |
| 111 | const auto original = |
| 112 | GenerateRandomValuesForPacking<Int>(opts.batch_size, opts.bit_width); |
| 113 | const auto packed = |
| 114 | PackValues(original, opts.batch_size, opts.bit_width, opts.bit_offset); |
| 115 | const auto unpacked = UnpackValues(packed.data(), opts, unpack); |
| 116 | |
| 117 | ASSERT_EQ(unpacked.size(), opts.batch_size); |
| 118 | const auto [iter_original, iter_unpacked] = |
| 119 | std::mismatch(original.cbegin(), original.cend(), unpacked.cbegin()); |
| 120 | Int val_original = 0; |
| 121 | Int val_unpacked = 0; |
| 122 | const auto mismatch_idx = static_cast<std::size_t>(iter_original - original.cbegin()); |
| 123 | if (mismatch_idx < unpacked.size()) { |
| 124 | val_original = *iter_original; |
| 125 | val_unpacked = *iter_unpacked; |
| 126 | } |
| 127 | EXPECT_EQ(original, unpacked) << "At position " << mismatch_idx << "/" |
| 128 | << unpacked.size() << ", expected original value " |
| 129 | << val_original << " but unpacked " << val_unpacked; |
| 130 | } |
| 131 | |
| 132 | template <typename Int> |
| 133 | void TestUnpackZeros(UnpackFunc<Int> unpack, const UnpackOptions& opts) { |
nothing calls this directly
no test coverage detected