diff options
author | Alexander Fokin <apfokin@gmail.com> | 2022-02-10 16:45:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:38 +0300 |
commit | 863a59a65247c24db7cb06789bc5cf79d04da32f (patch) | |
tree | 139dc000c8cd4a40f5659e421b7c75135d080307 /library/cpp/bit_io/bitinout_ut.cpp | |
parent | f64e95a9eb9ab03240599eb9581c5a9102426a96 (diff) | |
download | ydb-863a59a65247c24db7cb06789bc5cf79d04da32f.tar.gz |
Restoring authorship annotation for Alexander Fokin <apfokin@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/bit_io/bitinout_ut.cpp')
-rw-r--r-- | library/cpp/bit_io/bitinout_ut.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/bit_io/bitinout_ut.cpp b/library/cpp/bit_io/bitinout_ut.cpp index 23a1ddf344..b678c422c3 100644 --- a/library/cpp/bit_io/bitinout_ut.cpp +++ b/library/cpp/bit_io/bitinout_ut.cpp @@ -14,35 +14,35 @@ namespace NBitIO { "00001010 10101010 10101010 10101010 10101010 10101010 10101010 10101010 " "10110101 01010101 01010101 01010101 01010101 01010101 01010101 01010101 " "01000000"; - - inline ui64 Bits(ui64 bytes) { - return bytes << 3ULL; - } - + + inline ui64 Bits(ui64 bytes) { + return bytes << 3ULL; + } + inline TString PrintBits(const char* a, const char* b, bool reverse = false) { TString s; - TStringOutput out(s); - for (const char* it = a; it != b; ++it) { - if (it != a) - out << ' '; - - ui8 byte = *it; - - if (reverse) - byte = ReverseBits(byte); - - for (ui32 mask = 1; mask < 0xff; mask <<= 1) { - out << ((byte & mask) ? '1' : '0'); - } - } - - return s; - } - - template <typename T> + TStringOutput out(s); + for (const char* it = a; it != b; ++it) { + if (it != a) + out << ' '; + + ui8 byte = *it; + + if (reverse) + byte = ReverseBits(byte); + + for (ui32 mask = 1; mask < 0xff; mask <<= 1) { + out << ((byte & mask) ? '1' : '0'); + } + } + + return s; + } + + template <typename T> inline TString PrintBits(T t, ui32 bits = Bits(sizeof(T))) { - return PrintBits((char*)&t, ((char*)&t) + BytesUp(bits)); - } + return PrintBits((char*)&t, ((char*)&t) + BytesUp(bits)); + } } class TBitIOTest: public TTestBase { |