2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-02-14 12:52:17 +00:00
Files
mysql/test/integration/close_statement.cpp
2022-10-16 22:42:57 +02:00

39 lines
1.1 KiB
C++

//
// Copyright (c) 2019-2022 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)
//
#include "integration_test_common.hpp"
using namespace boost::mysql::test;
namespace {
auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"});
BOOST_AUTO_TEST_SUITE(test_close_statement)
BOOST_MYSQL_NETWORK_TEST(success, network_fixture, net_samples)
{
setup_and_connect(sample.net);
// Prepare a statement
conn->prepare_statement("SELECT * FROM empty_table", *stmt).validate_no_error();
// Verify it works fine
stmt->execute_collection({}, *result).validate_no_error();
result->read_all().validate_no_error(); // clean all packets sent for this execution
// Close the statement
stmt->close().validate_no_error();
// The statement is no longer valid
BOOST_TEST(!stmt->base().valid());
}
BOOST_AUTO_TEST_SUITE_END() // test_close_statement
} // namespace