Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/boost/redis/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct config {
*
* UNIX domain sockets can't be used with Sentinel.
*/
std::string unix_socket;
std::string unix_socket{};

/** @brief (Deprecated) Username used for authentication during connection establishment.
*
Expand Down Expand Up @@ -212,7 +212,7 @@ struct config {
* cfg.setup.hello("my_username", "my_password");
* @endcode
*/
std::string password;
std::string password{};

/** @brief (Deprecated) Client name parameter to use during connection establishment.
*
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ boost_redis_make_test(test_generic_flat_response)
boost_redis_make_test(test_read_buffer)
boost_redis_make_test(test_subscription_tracker)
boost_redis_make_test(test_push_parser)
boost_redis_make_test(test_config)

# Tests that require a real Redis server
if (BOOST_REDIS_INTEGRATION_TESTS)
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ local tests =
test_read_buffer
test_subscription_tracker
test_push_parser
test_config
;

# Build and run the tests
Expand Down
55 changes: 55 additions & 0 deletions test/test_config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// Copyright (c) 2025 Marcelo Zimbres Silva (mzimbres@gmail.com),
// 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 <boost/redis/config.hpp>

#include <boost/config.hpp>

#if !defined(__cpp_designated_initializers) || (__cpp_designated_initializers < 201707L)

#include <boost/config/pragma_message.hpp>

BOOST_PRAGMA_MESSAGE("test_config skipped because designated initializers are not supported");

int main() { }

#else

#include <boost/core/lightweight_test.hpp>

using namespace boost::redis;

namespace {

// A config object can be created using designated initializers.
// No initializer is missing
void test_designated_initializers_config()
{
// Most members have initializers
config cfg1{
.addr = {"127.0.0.1", "2000"},
.use_setup = true,
};

// The ones included above have, too
config cfg2{.unix_socket = "/tmp/sock"};

// Sentinel config has them, too
sentinel_config sent_cfg{.addresses = {{"127.0.0.1", "1000"}}};
}

} // namespace

int main()
{
test_designated_initializers_config();

return boost::report_errors();
}

#endif