Skip to content

Commit 77ade12

Browse files
committed
Failing test
1 parent 746fb62 commit 77ade12

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

test/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ make_test(test_conn_exec_cancel 20)
4747
make_test(test_conn_exec_cancel2 20)
4848
make_test(test_conn_echo_stress 20)
4949
make_test(test_any_adapter 17)
50+
make_test(test_conversions 17)
5051
make_test(test_issue_50 20)
5152
make_test(test_issue_181 17)
5253

test/test_conversions.cpp

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* Copyright (c) 2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
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/system/detail/error_code.hpp"
9+
#define BOOST_TEST_MODULE conversions
10+
#include <boost/redis/connection.hpp>
11+
#include <boost/test/included/unit_test.hpp>
12+
13+
#include "common.hpp"
14+
15+
namespace net = boost::asio;
16+
using boost::redis::connection;
17+
using boost::redis::ignore_t;
18+
using boost::redis::request;
19+
using boost::redis::response;
20+
using boost::system::error_code;
21+
22+
BOOST_AUTO_TEST_CASE(ints)
23+
{
24+
// Setup
25+
net::io_context ioc;
26+
auto conn = std::make_shared<connection>(ioc);
27+
run(conn);
28+
29+
// Get an integer key as all possible C++ integral types
30+
request req;
31+
req.push("SET", "key", 42);
32+
for (int i = 0; i < 10; ++i)
33+
req.push("GET", "key");
34+
35+
response<
36+
ignore_t,
37+
signed char,
38+
unsigned char,
39+
char,
40+
short,
41+
unsigned short,
42+
int,
43+
unsigned int,
44+
long,
45+
unsigned long,
46+
long long,
47+
unsigned long long
48+
> resp;
49+
50+
conn->async_exec(req, resp, [conn](error_code ec, std::size_t) {
51+
BOOST_TEST(!ec);
52+
conn->cancel();
53+
});
54+
55+
// Run the operations
56+
ioc.run();
57+
58+
// Check
59+
BOOST_TEST(std::get<1>(resp).value() == 42);
60+
BOOST_TEST(std::get<2>(resp).value() == 42);
61+
BOOST_TEST(std::get<3>(resp).value() == 42);
62+
BOOST_TEST(std::get<4>(resp).value() == 42);
63+
BOOST_TEST(std::get<5>(resp).value() == 42);
64+
BOOST_TEST(std::get<6>(resp).value() == 42);
65+
BOOST_TEST(std::get<7>(resp).value() == 42);
66+
BOOST_TEST(std::get<8>(resp).value() == 42);
67+
BOOST_TEST(std::get<9>(resp).value() == 42);
68+
BOOST_TEST(std::get<10>(resp).value() == 42);
69+
BOOST_TEST(std::get<11>(resp).value() == 42);
70+
}

0 commit comments

Comments
 (0)