//----------------------------------------------------------------------------- // ___ __ _ _ // / _ \__ _ _ __ ___ ___ / /(_)_ __ | | __ // / /_)/ _` | '__/ __|/ _ \/ / | | '_ \| |/ / // / ___/ (_| | | \__ \ __/ /__| | | | | < // \/ \__,_|_| |___/\___\____/_|_| |_|_|\_\ . // //----------------------------------------------------------------------------- // Author: Kurt Sassenrath // Module: msgpack // // Unpacker tests for bytes. // // Copyright (c) 2023 Kurt Sassenrath. // // License TBD. //----------------------------------------------------------------------------- #include "test_unpacker.h" using namespace boost::ut; suite unpack_byte_types = [] { // TODO: Make non-const version? "unpacker::unpack>"_test = [] { constexpr auto payload = test::make_bytes(0xc4, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05); constexpr auto expected = test::make_bytes(0x01, 0x02, 0x03, 0x04, 0x05); { msgpack::unpacker unpacker(payload); auto actual = unpacker.unpack>(); expect(std::ranges::equal(*actual, expected)); } { // Test extent msgpack::unpacker unpacker(payload); auto actual = unpacker.unpack>(); expect(std::ranges::equal(*actual, expected)); } { msgpack::unpacker unpacker(payload); auto actual = unpacker.unpack>(); expect(actual == tl::make_unexpected(msgpack::error::wrong_length)); auto actual2 = unpacker.unpack>(); expect(std::ranges::equal(*actual2, expected)); } }; // TODO: Make non-const version? "unpacker::unpack>"_test = [] { constexpr auto payload = test::make_bytes(0xc4, 0x05, 0x01, 0x02, 0x03, 0x04, 0x06); constexpr auto expected = test::make_bytes(0x01, 0x02, 0x03, 0x04, 0x06); { msgpack::unpacker unpacker(payload); auto actual = unpacker.unpack>(); expect(std::ranges::equal(*actual, expected)); } { msgpack::unpacker unpacker(payload); auto actual = unpacker.unpack>(); expect(actual == tl::make_unexpected(msgpack::error::wrong_length)); auto actual2 = unpacker.unpack>(); expect(std::ranges::equal(*actual2, expected)); } }; };