Skip to content

Commit

Permalink
Fix tests - they were not testing right.
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Jun 29, 2021
1 parent 82ee47e commit ab1b0d1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/lib/mdns/minimal/tests/TestResponseSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <mdns/minimal/responders/Ptr.h>
#include <mdns/minimal/responders/Srv.h>
#include <mdns/minimal/responders/Txt.h>
#include <mdns/minimal/RecordData.h>

#include <support/CHIPMem.h>
#include <support/UnitTestRegistration.h>
Expand Down Expand Up @@ -61,9 +62,22 @@ class CheckOnlyServer : public ServerBase, public ParserDelegate
// For now, types and names are sufficient for checking that the response sender is sending out the correct records.
if (data.GetType() == expectedRecord[i]->GetType() && data.GetName() == expectedRecord[i]->GetName())
{
foundRecord[i] = true;
recordIsExpected = true;
break;
if (data.GetType() == QType::PTR) {
// Check that the internal values are the same
SerializedQNameIterator dataTarget;
ParsePtrRecord(data.GetData(), data.GetData(), &dataTarget);
const PtrResourceRecord* expectedPtr = static_cast<const PtrResourceRecord*>(expectedRecord[i]);
if (dataTarget == expectedPtr->GetPtr()) {
foundRecord[i] = true;
recordIsExpected = true;
break;
}
}
else {
foundRecord[i] = true;
recordIsExpected = true;
break;
}
}
}
NL_TEST_ASSERT(mInSuite, recordIsExpected);
Expand All @@ -89,6 +103,7 @@ class CheckOnlyServer : public ServerBase, public ParserDelegate
if (expectedRecord[i] == nullptr)
{
expectedRecord[i] = record;
foundRecord[i] = false;
return;
}
}
Expand Down

0 comments on commit ab1b0d1

Please sign in to comment.