44 * accompanying file LICENSE.txt)
55 */
66
7- #include < boost/redis/request.hpp>
8- #include < boost/redis/response.hpp>
97#include < boost/redis/adapter/adapt.hpp>
8+ #include < boost/redis/request.hpp>
109#include < boost/redis/resp3/parser.hpp>
10+ #include < boost/redis/response.hpp>
1111
12- #define BOOST_TEST_MODULE low level
12+ #define BOOST_TEST_MODULE low_level
1313#include < boost/test/included/unit_test.hpp>
1414
1515#include < map>
16- #include < iostream>
1716#include < optional>
1817#include < sstream>
1918
2019// TODO: Test with empty strings.
2120
22- namespace std
23- {
24- auto operator ==(boost::redis::ignore_t , boost::redis::ignore_t ) noexcept {return true ;}
25- auto operator !=(boost::redis::ignore_t , boost::redis::ignore_t ) noexcept {return false ;}
26- }
21+ namespace std {
22+ auto operator ==(boost::redis::ignore_t , boost::redis::ignore_t ) noexcept { return true ; }
23+ auto operator !=(boost::redis::ignore_t , boost::redis::ignore_t ) noexcept { return false ; }
24+ } // namespace std
2725
2826namespace redis = boost::redis;
2927namespace resp3 = boost::redis::resp3;
@@ -56,12 +54,20 @@ using array_type = result<std::array<int, 3>>;
5654using array_type2 = result<std::array<int , 1 >>;
5755
5856// Map
59- using map_type = result<std::map<std::string, std::string>>;
60- using mmap_type = result<std::multimap<std::string, std::string>>;
61- using umap_type = result<std::unordered_map<std::string, std::string>>;
62- using mumap_type = result<std::unordered_multimap<std::string, std::string>>;
57+ using map_type = result<std::map<std::string, std::string>>;
58+ using mmap_type = result<std::multimap<std::string, std::string>>;
59+ using umap_type = result<std::unordered_map<std::string, std::string>>;
60+ using mumap_type = result<std::unordered_multimap<std::string, std::string>>;
6361using op_map_type = result<std::optional<std::map<std::string, std::string>>>;
64- using tuple8_type = result<response<std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string>>;
62+ using tuple8_type = result<response<
63+ std::string,
64+ std::string,
65+ std::string,
66+ std::string,
67+ std::string,
68+ std::string,
69+ std::string,
70+ std::string>>;
6571
6672// Null
6773using op_type_01 = result<std::optional<bool >>;
@@ -85,7 +91,11 @@ struct expect {
8591};
8692
8793template <class Result >
88- auto make_expected (std::string in, Result expected, error_code ec = {}, resp3::type error_type = resp3::type::invalid)
94+ auto make_expected (
95+ std::string in,
96+ Result expected,
97+ error_code ec = {},
98+ resp3::type error_type = resp3::type::invalid)
8999{
90100 return expect<Result>{in, expected, ec, error_type};
91101}
@@ -99,7 +109,7 @@ void test_sync(expect<Result> e)
99109 error_code ec;
100110 auto const res = parse (p, e.in , adapter, ec);
101111
102- BOOST_TEST (res); // None of these tests need more data.
112+ BOOST_TEST (res); // None of these tests need more data.
103113
104114 if (ec) {
105115 BOOST_CHECK_EQUAL (ec, e.ec );
@@ -123,7 +133,7 @@ void test_sync2(expect<Result> e)
123133 error_code ec;
124134 auto const res = parse (p, e.in , adapter, ec);
125135
126- BOOST_TEST (res); // None of these tests need more data.
136+ BOOST_TEST (res); // None of these tests need more data.
127137 BOOST_CHECK_EQUAL (ec, e.ec );
128138}
129139
@@ -133,8 +143,6 @@ auto make_blob()
133143 str[1000 ] = ' \r ' ;
134144 str[1001 ] = ' \n ' ;
135145 return str;
136-
137- return str;
138146}
139147
140148auto const blob = make_blob();
@@ -154,6 +162,8 @@ auto make_blob_string(std::string const& b)
154162result<std::optional<int >> op_int_ok = 11 ;
155163result<std::optional<bool >> op_bool_ok = true ;
156164
165+ // clang-format off
166+
157167// TODO: Test a streamed string that is not finished with a string of
158168// size 0 but other command comes in.
159169generic_response streamed_string_e1
@@ -461,12 +471,11 @@ generic_response const attr_e1b
461471 test (make_expected(S10b, node_type{{resp3::type::simple_error, 1UL , 0UL , {" " }}}, {}, resp3::type::simple_error)); \
462472 test (make_expected(S12a, node_type{{resp3::type::blob_error, 1UL , 0UL , {" SYNTAX invalid syntax" }}}, {}, resp3::type::blob_error));\
463473 test (make_expected(S12b, node_type{{resp3::type::blob_error, 1UL , 0UL , {}}}, {}, resp3::type::blob_error));\
464- test (make_expected(S12c, result<ignore_t >{}, boost::redis::error::resp3_blob_error));\
474+ test (make_expected(S12c, result<ignore_t >{}, boost::redis::error::resp3_blob_error));
465475
466- BOOST_AUTO_TEST_CASE (sansio)
467- {
468- NUMBER_TEST_CONDITIONS (test_sync)
469- }
476+ // clang-format on
477+
478+ BOOST_AUTO_TEST_CASE (sansio){NUMBER_TEST_CONDITIONS (test_sync)}
470479
471480BOOST_AUTO_TEST_CASE (ignore_adapter_simple_error)
472481{
@@ -478,10 +487,7 @@ BOOST_AUTO_TEST_CASE(ignore_adapter_blob_error)
478487 test_sync2 (make_expected (S12a, ignore, boost::redis::error::resp3_blob_error));
479488}
480489
481- BOOST_AUTO_TEST_CASE (ignore_adapter_no_error)
482- {
483- test_sync2 (make_expected (S05b, ignore));
484- }
490+ BOOST_AUTO_TEST_CASE (ignore_adapter_no_error) { test_sync2 (make_expected (S05b, ignore)); }
485491
486492// -----------------------------------------------------------------------------------
487493void check_error (char const * name, boost::redis::error ev)
@@ -492,10 +498,9 @@ void check_error(char const* name, boost::redis::error ev)
492498 BOOST_TEST (!ec.message ().empty ());
493499 BOOST_TEST (cat.equivalent (
494500 static_cast <std::underlying_type<boost::redis::error>::type>(ev),
495- ec.category ().default_error_condition (
496- static_cast <std::underlying_type<boost::redis::error>::type>(ev))));
497- BOOST_TEST (cat.equivalent (ec,
498- static_cast <std::underlying_type<boost::redis::error>::type>(ev)));
501+ ec.category ().default_error_condition (
502+ static_cast <std::underlying_type<boost::redis::error>::type>(ev))));
503+ BOOST_TEST (cat.equivalent (ec, static_cast <std::underlying_type<boost::redis::error>::type>(ev)));
499504}
500505
501506BOOST_AUTO_TEST_CASE (cover_error)
@@ -606,7 +611,7 @@ BOOST_AUTO_TEST_CASE(adapter_as)
606611 result<std::set<std::string>> set;
607612 auto adapter = adapt2 (set);
608613
609- for (auto const & e: set_expected1a.value ()) {
614+ for (auto const & e : set_expected1a.value ()) {
610615 error_code ec;
611616 adapter (e, ec);
612617 }
0 commit comments