//----------------------------------------------------------------------------- // ___ __ _ _ // / _ \__ _ _ __ ___ ___ / /(_)_ __ | | __ // / /_)/ _` | '__/ __|/ _ \/ / | | '_ \| |/ / // / ___/ (_| | | \__ \ __/ /__| | | | | < // \/ \__,_|_| |___/\___\____/_|_| |_|_|\_\ . // //----------------------------------------------------------------------------- // Author: Kurt Sassenrath // Module: msgpack // // Packer tests, common code. // // Copyright (c) 2023 Kurt Sassenrath. // // License TBD. //----------------------------------------------------------------------------- #ifndef tests_msgpack_packer_6e9a5bf8e14223bc #define tests_msgpack_packer_6e9a5bf8e14223bc #include "parselink/msgpack/core/packer.h" #include "test_utils.h" template constexpr auto within(auto value) noexcept { return value >= std::numeric_limits::min() && value <= std::numeric_limits::max(); } template constexpr auto verify_packed(auto const& packer, auto value) noexcept { std::array::digits + 7) / 8> raw; if (packer.tell() != 1 + raw.size()) return false; auto packed = packer.subspan().subspan(1); be_to_host(packed.begin(), packed.end(), raw.begin()); auto actual = std::bit_cast(raw); return actual == value; } #endif // tests_msgpack_packer_6e9a5bf8e14223bc