mirror of
https://github.com/eclipse/paho.mqtt.cpp.git
synced 2025-05-09 19:31:22 +08:00
#444 Unit tests to check that connect options builder sets properties.
This commit is contained in:
parent
b94cb27722
commit
bb66355be6
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user