29
29
#include < lib/dnssd/minimal_mdns/records/Srv.h>
30
30
#include < lib/dnssd/minimal_mdns/records/Txt.h>
31
31
#include < lib/support/CHIPMemString.h>
32
- #include < lib/support/UnitTestRegistration.h>
33
32
#include < system/SystemMutex.h>
34
33
35
- #include < nlunit-test .h>
34
+ #include < gtest/gtest .h>
36
35
37
36
namespace mdns {
38
37
namespace Minimal {
@@ -78,23 +77,19 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
78
77
public TxtRecordDelegate
79
78
{
80
79
public:
81
- CheckOnlyServer (nlTestSuite * inSuite) : ServerBase(*static_cast <ServerBase::EndpointInfoPoolType *>(this )), mInSuite (inSuite)
82
- {
83
- Reset ();
84
- }
85
- CheckOnlyServer () : ServerBase(*static_cast <ServerBase::EndpointInfoPoolType *>(this )), mInSuite (nullptr ) { Reset (); }
80
+ CheckOnlyServer () : ServerBase(*static_cast <ServerBase::EndpointInfoPoolType *>(this )) { Reset (); }
86
81
~CheckOnlyServer () {}
87
82
88
83
// Parser delegates
89
84
void OnHeader (ConstHeaderRef & header) override
90
85
{
91
- NL_TEST_ASSERT ( mInSuite , header.GetFlags ().IsResponse ());
92
- NL_TEST_ASSERT ( mInSuite , header.GetFlags ().IsValidMdns ());
86
+ EXPECT_TRUE ( header.GetFlags ().IsResponse ());
87
+ EXPECT_TRUE ( header.GetFlags ().IsValidMdns ());
93
88
mTotalRecords += header.GetAnswerCount () + header.GetAdditionalCount ();
94
89
95
90
if (!header.GetFlags ().IsTruncated ())
96
91
{
97
- NL_TEST_ASSERT ( mInSuite , mTotalRecords == GetNumExpectedRecords ());
92
+ EXPECT_EQ ( mTotalRecords , GetNumExpectedRecords ());
98
93
if (mTotalRecords != GetNumExpectedRecords ())
99
94
{
100
95
ChipLogError (Discovery, " Received %d records, expected %d" , mTotalRecords , GetNumExpectedRecords ());
@@ -114,7 +109,7 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
114
109
case QType::SRV: {
115
110
SrvRecord srv;
116
111
bool srvParseOk = srv.Parse (data.GetData (), mPacketData );
117
- NL_TEST_ASSERT ( mInSuite , srvParseOk);
112
+ EXPECT_TRUE ( srvParseOk);
118
113
if (!srvParseOk)
119
114
{
120
115
return ;
@@ -146,7 +141,7 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
146
141
for (size_t t = 0 ; t < expectedTxt->GetNumEntries (); ++t)
147
142
{
148
143
bool ok = AddExpectedTxtRecord (expectedTxt->GetEntries ()[t]);
149
- NL_TEST_ASSERT ( mInSuite , ok);
144
+ EXPECT_TRUE ( ok);
150
145
}
151
146
ParseTxtRecord (data.GetData (), this );
152
147
if (CheckTxtRecordMatches ())
@@ -164,7 +159,7 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
164
159
}
165
160
}
166
161
}
167
- NL_TEST_ASSERT ( mInSuite , recordIsExpected);
162
+ EXPECT_TRUE ( recordIsExpected);
168
163
if (!recordIsExpected)
169
164
{
170
165
char nameStr[64 ];
@@ -253,7 +248,7 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
253
248
void AddExpectedRecord (SrvResourceRecord * srv)
254
249
{
255
250
RecordInfo * info = AddExpectedRecordBase (srv);
256
- NL_TEST_ASSERT ( mInSuite , info != nullptr );
251
+ ASSERT_NE ( info, nullptr );
257
252
if (info == nullptr )
258
253
{
259
254
return ;
@@ -263,7 +258,7 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
263
258
void AddExpectedRecord (TxtResourceRecord * txt)
264
259
{
265
260
RecordInfo * info = AddExpectedRecordBase (txt);
266
- NL_TEST_ASSERT ( mInSuite , info != nullptr );
261
+ ASSERT_NE ( info, nullptr );
267
262
if (info == nullptr )
268
263
{
269
264
return ;
@@ -272,7 +267,6 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
272
267
}
273
268
bool GetSendCalled () { return mSendCalled ; }
274
269
bool GetHeaderFound () { return mHeaderFound ; }
275
- void SetTestSuite (nlTestSuite * suite) { mInSuite = suite; }
276
270
void Reset ()
277
271
{
278
272
for (auto & info : mExpectedRecordInfo )
@@ -287,7 +281,6 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
287
281
}
288
282
289
283
private:
290
- nlTestSuite * mInSuite ;
291
284
static constexpr size_t kMaxExpectedRecords = 10 ;
292
285
struct RecordInfo
293
286
{
@@ -335,17 +328,13 @@ class CheckOnlyServer : private chip::PoolImpl<ServerBase::EndpointInfo, 0, chip
335
328
}
336
329
void TestGotAllExpectedPackets ()
337
330
{
338
- if (mInSuite == nullptr )
339
- {
340
- return ;
341
- }
342
331
for (auto & info : mExpectedRecordInfo )
343
332
{
344
333
if (info.record == nullptr )
345
334
{
346
335
continue ;
347
336
}
348
- NL_TEST_ASSERT ( mInSuite , info.found == true );
337
+ EXPECT_TRUE ( info.found );
349
338
if (!info.found )
350
339
{
351
340
char name[64 ];
0 commit comments