1
0
mirror of https://github.com/eclipse/paho.mqtt.cpp.git synced 2025-05-09 03:11:23 +08:00

#444 Unit tests to check that connect options builder sets properties.

This commit is contained in:
fpagliughi 2023-11-12 19:32:47 -05:00
parent b94cb27722
commit bb66355be6
2 changed files with 26 additions and 13 deletions

View File

@ -340,19 +340,6 @@ public:
* @return The number of property items in the list.
*/
size_t size() const { return size_t(props_.count); }
/**
* Gets the number of bytes required for the serialized
* structure on the wire.
* @return The number of bytes required for the serialized
* struct.
*/
#if 0
// Note: This isn't exported by the shared library. Perhaps we can change
// that in the upstream C lib.
size_t byte_length() const {
return (size_t) ::MQTTProperties_len(const_cast<MQTTProperties*>(&props_));
}
#endif
/**
* Adds a property to the list.
* @param prop The property to add to the list.

View File

@ -547,3 +547,29 @@ TEST_CASE("connect_options_builder default generator", "[options]")
REQUIRE(DFLT_WS_KEEP_ALIVE == (int) opts.get_keep_alive_interval().count());
}
// ----------------------------------------------------------------------
// Test the builder
// ----------------------------------------------------------------------
TEST_CASE("connect_options_builder set", "[options]")
{
const uint32_t INTERVAL = 80000;
mqtt::properties conn_props{
mqtt::property{mqtt::property::SESSION_EXPIRY_INTERVAL, INTERVAL}};
auto opts = mqtt::connect_options_builder()
.properties(conn_props)
.finalize();
auto& props = opts.get_properties();
REQUIRE(!props.empty());
REQUIRE(1 == props.size());
REQUIRE(INTERVAL == get<uint32_t>(props, mqtt::property::SESSION_EXPIRY_INTERVAL));
const auto& copts = opts.c_struct();
REQUIRE(nullptr != copts.connectProperties);
}