| 378 | |
| 379 | template<typename T> |
| 380 | void RunIntToByteArrayTest(const T& input, const std::vector<char>& expected) { |
| 381 | std::string result = BitUtil::IntToByteBuffer(input); |
| 382 | EXPECT_EQ(expected.size(), result.size()) << input; |
| 383 | for (int i = 0; i < std::min(expected.size(), result.size()); ++i) { |
| 384 | EXPECT_EQ(expected[i], result[i]) << input; |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | // __int128_t has no support for << operator. This is a specialized function for this |
| 389 | // type where in case of an EXPECT check failing we don't print the original input. |