test_server_mqtt.cpp 576 B

12345678910111213141516171819202122
  1. #include <unity.h>
  2. #include <server_mqtt.h>
  3. void test_createNodeId()
  4. {
  5. std::string topic = "watermeter";
  6. TEST_ASSERT_EQUAL_STRING("watermeter", createNodeId(topic).c_str());
  7. topic = "/watermeter";
  8. TEST_ASSERT_EQUAL_STRING("watermeter", createNodeId(topic).c_str());
  9. topic = "home/test/watermeter";
  10. TEST_ASSERT_EQUAL_STRING("watermeter", createNodeId(topic).c_str());
  11. topic = "home/test/subtopic/something/test/watermeter";
  12. TEST_ASSERT_EQUAL_STRING("watermeter", createNodeId(topic).c_str());
  13. }
  14. void test_mqtt()
  15. {
  16. test_createNodeId();
  17. }