2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-01-22 17:32:25 +00:00
Files
mysql/test/unit/include/test_unit/serialize_to_vector.hpp
Anarthal (Rubén Pérez) 90405e79e4 Handshake is now more resilient
Errors issued by the server for caching_sha2_password users after a fast
auth OK packet has been received (e.g. bad database errors) are now
reported correctly
Handshake now correctly detects protocol violation errors, like double
auth switches

close #469 
close #468
2025-05-07 13:11:52 +02:00

40 lines
1.1 KiB
C++

//
// Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_MYSQL_TEST_UNIT_INCLUDE_TEST_UNIT_SERIALIZE_TO_VECTOR_HPP
#define BOOST_MYSQL_TEST_UNIT_INCLUDE_TEST_UNIT_SERIALIZE_TO_VECTOR_HPP
#include <boost/mysql/error_code.hpp>
#include <boost/mysql/impl/internal/protocol/impl/serialization_context.hpp>
#include <boost/mysql/impl/internal/protocol/serialization.hpp>
#include <boost/test/unit_test.hpp>
#include <cstdint>
#include <vector>
namespace boost {
namespace mysql {
namespace test {
template <class Fn>
std::vector<std::uint8_t> serialize_to_vector(const Fn& serialize_fn)
{
std::vector<std::uint8_t> buff;
detail::serialization_context ctx(buff, static_cast<std::size_t>(-1), detail::disable_framing);
serialize_fn(ctx);
BOOST_TEST(ctx.error() == error_code());
return buff;
}
} // namespace test
} // namespace mysql
} // namespace boost
#endif