mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 20:46:52 +03:00
* derive correct node_id for homeassistant service discovery in nested topics (fixes #1792) * explicit use of std::string * move nodeId creation to separate function add unit-tests * add documentation about node_id generation for Home Assistant MQTT Service Discovery
22 lines
576 B
C++
22 lines
576 B
C++
#include <unity.h>
|
|
#include <server_mqtt.h>
|
|
|
|
void test_createNodeId()
|
|
{
|
|
std::string topic = "watermeter";
|
|
TEST_ASSERT_EQUAL_STRING("watermeter", createNodeId(topic).c_str());
|
|
|
|
topic = "/watermeter";
|
|
TEST_ASSERT_EQUAL_STRING("watermeter", createNodeId(topic).c_str());
|
|
|
|
topic = "home/test/watermeter";
|
|
TEST_ASSERT_EQUAL_STRING("watermeter", createNodeId(topic).c_str());
|
|
|
|
topic = "home/test/subtopic/something/test/watermeter";
|
|
TEST_ASSERT_EQUAL_STRING("watermeter", createNodeId(topic).c_str());
|
|
}
|
|
|
|
void test_mqtt()
|
|
{
|
|
test_createNodeId();
|
|
} |