Replaced nlunit-test with pw_unit_test in src/lib/address_resolve/ (#33064)
diff --git a/src/lib/address_resolve/tests/BUILD.gn b/src/lib/address_resolve/tests/BUILD.gn
index e82e6db..994833f 100644
--- a/src/lib/address_resolve/tests/BUILD.gn
+++ b/src/lib/address_resolve/tests/BUILD.gn
@@ -14,13 +14,12 @@
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
-import("//build_overrides/nlunit_test.gni")
import("${chip_root}/src/lib/address_resolve/address_resolve.gni")
import("${chip_root}/build/chip/chip_test_suite.gni")
-chip_test_suite_using_nltest("tests") {
+chip_test_suite("tests") {
output_name = "libAddressResolveTests"
if (chip_address_resolve_strategy == "default") {
@@ -29,8 +28,6 @@
public_deps = [
"${chip_root}/src/lib/address_resolve",
- "${chip_root}/src/lib/support:testing_nlunit",
"${chip_root}/src/protocols",
- "${nlunit_test_root}:nlunit-test",
]
}
diff --git a/src/lib/address_resolve/tests/TestAddressResolve_DefaultImpl.cpp b/src/lib/address_resolve/tests/TestAddressResolve_DefaultImpl.cpp
index f926fc2..74dc3bd 100644
--- a/src/lib/address_resolve/tests/TestAddressResolve_DefaultImpl.cpp
+++ b/src/lib/address_resolve/tests/TestAddressResolve_DefaultImpl.cpp
@@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <gtest/gtest.h>
+
#include <lib/address_resolve/AddressResolve_DefaultImpl.h>
-#include <lib/support/UnitTestRegistration.h>
-
-#include <nlunit-test.h>
-
using namespace chip;
using namespace chip::AddressResolve;
@@ -66,7 +64,7 @@
return Transport::PeerAddress::UDP(ipAddress, port, interfaceId);
}
-void TestLookupResult(nlTestSuite * inSuite, void * inContext)
+TEST(TestAddressResolveDefaultImpl, TestLookupResult)
{
ResolveResult lowResult;
lowResult.address = GetAddressWithLowScore();
@@ -83,8 +81,8 @@
IpScore mediumScore = ScoreIpAddress(mediumResult.address.GetIPAddress(), Inet::InterfaceId::Null());
IpScore highScore = ScoreIpAddress(highResult.address.GetIPAddress(), Inet::InterfaceId::Null());
- NL_TEST_ASSERT(inSuite, to_underlying(lowScore) < to_underlying(mediumScore));
- NL_TEST_ASSERT(inSuite, to_underlying(mediumScore) < to_underlying(highScore));
+ EXPECT_LT(to_underlying(lowScore), to_underlying(mediumScore));
+ EXPECT_LT(to_underlying(mediumScore), to_underlying(highScore));
ResolveResult outResult;
@@ -95,20 +93,20 @@
handle.ResetForLookup(now, request);
// Check that no result exists.
- NL_TEST_ASSERT(inSuite, !handle.HasLookupResult());
+ EXPECT_FALSE(handle.HasLookupResult());
// Fill a single slot.
handle.LookupResult(lowResult);
// Check that a result exists.
- NL_TEST_ASSERT(inSuite, handle.HasLookupResult());
+ EXPECT_TRUE(handle.HasLookupResult());
// Check that the result match what has been inserted.
outResult = handle.TakeLookupResult();
- NL_TEST_ASSERT(inSuite, lowResult.address == outResult.address);
+ EXPECT_EQ(lowResult.address, outResult.address);
// Check that the result has been consumed properly
- NL_TEST_ASSERT(inSuite, !handle.HasLookupResult());
+ EXPECT_FALSE(handle.HasLookupResult());
handle.ResetForLookup(now, request);
@@ -121,13 +119,13 @@
// Read back all results and validate that they match the input.
for (auto i = 0; i < kNumberOfAvailableSlots; i++)
{
- NL_TEST_ASSERT(inSuite, handle.HasLookupResult());
+ EXPECT_TRUE(handle.HasLookupResult());
outResult = handle.TakeLookupResult();
- NL_TEST_ASSERT(inSuite, lowResult.address == outResult.address);
+ EXPECT_EQ(lowResult.address, outResult.address);
}
// Check that the results has been consumed properly.
- NL_TEST_ASSERT(inSuite, !handle.HasLookupResult());
+ EXPECT_FALSE(handle.HasLookupResult());
handle.ResetForLookup(now, request);
@@ -140,13 +138,13 @@
// Read back all results and validate that they match the input.
for (auto i = 0; i < kNumberOfAvailableSlots; i++)
{
- NL_TEST_ASSERT(inSuite, handle.HasLookupResult());
+ EXPECT_TRUE(handle.HasLookupResult());
outResult = handle.TakeLookupResult();
- NL_TEST_ASSERT(inSuite, lowResult.address == outResult.address);
+ EXPECT_EQ(lowResult.address, outResult.address);
}
// Check that the results has been consumed properly.
- NL_TEST_ASSERT(inSuite, !handle.HasLookupResult());
+ EXPECT_FALSE(handle.HasLookupResult());
handle.ResetForLookup(now, request);
@@ -158,9 +156,9 @@
// Add a result with a medium score and ensure it sits at the top.
handle.LookupResult(mediumResult);
- NL_TEST_ASSERT(inSuite, handle.HasLookupResult());
+ EXPECT_TRUE(handle.HasLookupResult());
outResult = handle.TakeLookupResult();
- NL_TEST_ASSERT(inSuite, mediumResult.address == outResult.address);
+ EXPECT_EQ(mediumResult.address, outResult.address);
handle.ResetForLookup(now, request);
@@ -173,16 +171,16 @@
// Add a result with a medium score and a result with a high score and ensure the result with the high score comes first.
handle.LookupResult(mediumResult);
handle.LookupResult(highResult);
- NL_TEST_ASSERT(inSuite, handle.HasLookupResult());
+ EXPECT_TRUE(handle.HasLookupResult());
outResult = handle.TakeLookupResult();
- NL_TEST_ASSERT(inSuite, highResult.address == outResult.address);
+ EXPECT_EQ(highResult.address, outResult.address);
if (kNumberOfAvailableSlots > 1)
{
// Ensure the second result is the medium result.
- NL_TEST_ASSERT(inSuite, handle.HasLookupResult());
+ EXPECT_TRUE(handle.HasLookupResult());
outResult = handle.TakeLookupResult();
- NL_TEST_ASSERT(inSuite, mediumResult.address == outResult.address);
+ EXPECT_EQ(mediumResult.address, outResult.address);
}
if (kNumberOfAvailableSlots > 2)
@@ -190,28 +188,13 @@
// Ensure that all the other results are low results.
for (auto i = 2; i < kNumberOfAvailableSlots; i++)
{
- NL_TEST_ASSERT(inSuite, handle.HasLookupResult());
+ EXPECT_TRUE(handle.HasLookupResult());
outResult = handle.TakeLookupResult();
- NL_TEST_ASSERT(inSuite, lowResult.address == outResult.address);
+ EXPECT_EQ(lowResult.address, outResult.address);
}
}
// Check that the results has been consumed properly.
- NL_TEST_ASSERT(inSuite, !handle.HasLookupResult());
+ EXPECT_FALSE(handle.HasLookupResult());
}
-
-const nlTest sTests[] = {
- NL_TEST_DEF("TestLookupResult", TestLookupResult), //
- NL_TEST_SENTINEL() //
-};
-
} // namespace
-
-int TestAddressResolve_DefaultImpl()
-{
- nlTestSuite theSuite = { "AddressResolve_DefaultImpl", sTests, nullptr, nullptr };
- nlTestRunner(&theSuite, nullptr);
- return nlTestRunnerStats(&theSuite);
-}
-
-CHIP_REGISTER_TEST_SUITE(TestAddressResolve_DefaultImpl)