From a28c0c1418415034f14b2250ff865323e434f10f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 13 Jan 2024 01:40:11 +0100 Subject: w --- serialize/packbits.cpp | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'serialize/packbits.cpp') diff --git a/serialize/packbits.cpp b/serialize/packbits.cpp index 1b353b43..a45c68d8 100644 --- a/serialize/packbits.cpp +++ b/serialize/packbits.cpp @@ -11,34 +11,31 @@ constexpr bool test1() { constexpr size_t left[] = { 8, 3, 2, 1, 0 }; constexpr size_t rest[] = { 0, 5, 6, 7, 8 }; - constexpr size_t bits[] = { 5, 2, 1, 1 }; + constexpr size_t bits[] = { 5, 2, 1, 0 }; constexpr size_t vals[] = { 8, 3, 1, 0 }; - constexpr auto S0 = Storage{0b10111011uz}; - constexpr auto S1 = Storage{0b00000101uz}; - constexpr auto S2 = Storage{0b00000010uz}; - constexpr auto S3 = Storage{0b00000001uz}; - constexpr auto S4 = Storage{0b00000000uz}; - static_assert(S0.Capacity == 8 - rest[0]); - static_assert(S1.Capacity == 8 - rest[1]); - static_assert(S2.Capacity == 8 - rest[2]); - static_assert(S3.Capacity == 8 - rest[3]); - static_assert(S4.Capacity == 8 - rest[4]); - static_assert(S0.advance() == S1.value); - static_assert(S1.advance() == S2.value); - static_assert(S2.advance() == S3.value); - static_assert(S3.advance() == S4.value); + + constexpr auto S0 = Storage{0b10111011uz}; + constexpr auto S1 = Storage{0b00000101uz}; + constexpr auto S2 = Storage{0b00000001uz}; + constexpr auto S3 = Storage{0b00000000uz}; + using P0 = std::decay_t; using P1 = P0::next; using P2 = P1::next; using P3 = P2::next; - static_assert(P0::Capacity == vals[0]); - static_assert(P1::Capacity == vals[1]); - static_assert(P2::Capacity == vals[2]); - static_assert(P3::Capacity == vals[3]); + static_assert(std::is_same_v>); static_assert(std::is_same_v>); static_assert(std::is_same_v>); + static_assert(S0.advance<5>() == S1.value); + static_assert(S1.advance<2>() == S2.value); + static_assert(S2.advance<1>() == S3.value); + + static_assert(S0.get() == (S0.value & (1<() == (S1.value & (1<() == (S2.value & (1<