47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
//-----------------------------------------------------------------------------
|
|
// ___ __ _ _
|
|
// / _ \__ _ _ __ ___ ___ / /(_)_ __ | | __
|
|
// / /_)/ _` | '__/ __|/ _ \/ / | | '_ \| |/ /
|
|
// / ___/ (_| | | \__ \ __/ /__| | | | | <
|
|
// \/ \__,_|_| |___/\___\____/_|_| |_|_|\_\ .
|
|
//
|
|
//-----------------------------------------------------------------------------
|
|
// Author: Kurt Sassenrath
|
|
// Module: msgpack
|
|
//
|
|
// Packer tests, strings.
|
|
//
|
|
// Copyright (c) 2023 Kurt Sassenrath.
|
|
//
|
|
// License TBD.
|
|
//-----------------------------------------------------------------------------
|
|
#include "test_packer.h"
|
|
|
|
#include <rapidcheck.h>
|
|
|
|
using namespace boost::ut;
|
|
|
|
namespace {
|
|
|
|
template <std::unsigned_integral LenType, typename StrType = std::string>
|
|
auto check_string() {
|
|
return rc::check([](LenType value) {
|
|
auto str = *rc::gen::container<std::string>(
|
|
value, rc::gen::character<char>());
|
|
std::vector<std::byte> payload;
|
|
payload.resize(value + 32);
|
|
msgpack::packer packer(payload);
|
|
if (!packer.pack(str)) return false;
|
|
return true;
|
|
});
|
|
}
|
|
|
|
} // anonymous namespace
|
|
|
|
suite pack_strings = [] {
|
|
"packer::pack<std::string>"_test = [] {
|
|
expect(check_string<std::uint8_t>());
|
|
expect(check_string<std::uint16_t>());
|
|
};
|
|
};
|