Fix payload test (the payload was sent, the test was buggy)

This commit is contained in:
hsaturn
2021-04-05 13:54:40 +02:00
parent 80dade00fe
commit 62868cba34

View File

@@ -15,14 +15,16 @@ MqttBroker broker(1883);
std::map<std::string, std::map<Topic, int>> published; // map[client_id] => map[topic] = count std::map<std::string, std::map<Topic, int>> published; // map[client_id] => map[topic] = count
const char* lastPayload; char* lastPayload = nullptr;
size_t lastLength; size_t lastLength;
void onPublish(const MqttClient* srce, const Topic& topic, const char* payload, size_t length) void onPublish(const MqttClient* srce, const Topic& topic, const char* payload, size_t length)
{ {
if (srce) if (srce)
published[srce->id()][topic]++; published[srce->id()][topic]++;
lastPayload = payload;
if (lastPayload) free(lastPayload);
lastPayload = strdup(payload);
lastLength = length; lastLength = length;
} }
@@ -131,7 +133,6 @@ test(nowifi_nocallback_when_destroyed)
test(nowifi_payload_nullptr) test(nowifi_payload_nullptr)
{ {
return; // FIXME
published.clear(); published.clear();
const char* payload="abcd"; const char* payload="abcd";