|
| 1 | +/* Copyright (c) 2018-2022 Marcelo Zimbres Silva ([email protected]) |
| 2 | + * |
| 3 | + * Distributed under the Boost Software License, Version 1.0. (See |
| 4 | + * accompanying file LICENSE.txt) |
| 5 | + */ |
| 6 | + |
| 7 | +#include <boost/redis/ignore.hpp> |
| 8 | +#include <boost/redis/response.hpp> |
| 9 | +#include <boost/redis/adapter/any_adapter.hpp> |
| 10 | +#include <string> |
| 11 | +#define BOOST_TEST_MODULE any_adapter |
| 12 | +#include <boost/test/included/unit_test.hpp> |
| 13 | + |
| 14 | +using boost::redis::generic_response; |
| 15 | +using boost::redis::response; |
| 16 | +using boost::redis::ignore; |
| 17 | +using boost::redis::any_adapter; |
| 18 | + |
| 19 | +BOOST_AUTO_TEST_CASE(any_adapter_response_types) |
| 20 | +{ |
| 21 | + // any_adapter can be used with any supported responses |
| 22 | + response<int> r1; |
| 23 | + response<int, std::string> r2; |
| 24 | + generic_response r3; |
| 25 | + |
| 26 | + BOOST_CHECK_NO_THROW(any_adapter{r1}); |
| 27 | + BOOST_CHECK_NO_THROW(any_adapter{r2}); |
| 28 | + BOOST_CHECK_NO_THROW(any_adapter{r3}); |
| 29 | + BOOST_CHECK_NO_THROW(any_adapter{ignore}); |
| 30 | +} |
| 31 | + |
| 32 | +BOOST_AUTO_TEST_CASE(any_adapter_copy_move) |
| 33 | +{ |
| 34 | + // any_adapter can be copied/moved |
| 35 | + response<int, std::string> r; |
| 36 | + any_adapter ad1 {r}; |
| 37 | + |
| 38 | + // copy constructor |
| 39 | + any_adapter ad2 {ad1}; |
| 40 | + |
| 41 | + // move constructor |
| 42 | + any_adapter ad3 {std::move(ad2)}; |
| 43 | + |
| 44 | + // copy assignment |
| 45 | + BOOST_CHECK_NO_THROW(ad2 = ad1); |
| 46 | + |
| 47 | + // move assignment |
| 48 | + BOOST_CHECK_NO_THROW(ad2 = std::move(ad1)); |
| 49 | +} |
0 commit comments