#include "packbits-write.hpp" namespace floormat { namespace { using namespace floormat::Pack_impl; using u32 = uint32_t; using u16 = uint16_t; using u8 = uint8_t; template using f32 = output_field; template using f16 = output_field; template using f8 = output_field; static_assert(write_(std::tuple>{4242}, output{0}, std::index_sequence<0>{}) == 4242u); static_assert(write_( std::tuple{f8<3>{7}, f8<2>{3}, f8<1>{1}}, output{0}, std::make_index_sequence<3>{} ) == (1 << 6) - 1); static_assert(write_( std::tuple{f32<2>{0b10}, f32<3>{0b011}, f32<3>{0b001}}, output{0}, make_reverse_index_sequence<3>{}) == 0b000101110); static_assert(pack_write(std::tuple{f32<2>{0b10}, f32<3>{0b011}, f32<3>{0b01}}) == 0b00101110); //static_assert(pack_write(std::tuple{f32<2>{0b10}, f32<3>{0b1011}, f32<3>{0b001}}) == 0b000101110); static_assert(pack_write(std::tuple{f8<2>{0b10}, f8<3>{0b011}, f8<3>{0b01}}) == 0b00101110); //static_assert(pack_write(std::tuple{f8<2>{0b10}, f8<3>{0b011}, f8<4>{0b01}}) == 0b00101110); //static_assert(pack_write(std::tuple{}) == 0); static_assert(pack_write(std::tuple{f8<1>{0b1}, f8<3>{0b101}, f8<2>{0b10}}) == 0b101011); #if 0 // check disassembly u32 foo1(u32 a, u32 b, u32 c); u32 foo1(u32 a, u32 b, u32 c) { return pack_write(std::tuple{f32<2>{a}, f32<3>{b}, f32<3>{c}}); } #endif } // namespace #if 0 [[maybe_unused]] uint8_t test1(uint8_t a, uint8_t b, uint8_t c) { return pack_write(std::tuple{f8<2>{a}, f8<3>{b}, f8<3>{c}}); } #endif } // namespace floormat