| 141 | } |
| 142 | |
| 143 | void TestUnpackOnes(UnpackFunc<Int> unpack, const UnpackOptions& opts) { |
| 144 | const auto num_bytes = GetNumBytes(opts.batch_size, opts.bit_width, opts.bit_offset); |
| 145 | |
| 146 | const std::vector<uint8_t> packed(static_cast<std::size_t>(num_bytes), uint8_t{0xFF}); |
| 147 | const auto unpacked = UnpackValues(packed.data(), opts, unpack); |
| 148 | |
| 149 | // Generate bit_width ones |
| 150 | Int expected_value = 0; |
| 151 | if constexpr (std::is_same_v<Int, bool>) { |
| 152 | expected_value = static_cast<bool>(opts.bit_width); |
| 153 | } else { |
| 154 | for (int i = 0; i < opts.bit_width; ++i) { |
| 155 | expected_value = (expected_value << 1) | 1; |
| 156 | } |
| 157 | } |
| 158 | const std::vector<Int> expected(static_cast<std::size_t>(opts.batch_size), |
| 159 | expected_value); |
| 160 | EXPECT_EQ(unpacked, expected); |
| 161 | } |
| 162 | |
| 163 | void TestUnpackAlternating(UnpackFunc<Int> unpack, const UnpackOptions& opts) { |
| 164 | const auto num_bytes = GetNumBytes(opts.batch_size, opts.bit_width, opts.bit_offset); |
nothing calls this directly
no test coverage detected