Replaced nlunit-test with pw_unit_test in src/lib/format/ (#33063)

* Replaced nlunit-test with pw_unit_test in src/lib/format/

* Restyled by clang-format

* Use EXPECT_STREQ

---------

Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/src/lib/format/tests/BUILD.gn b/src/lib/format/tests/BUILD.gn
index 64be2e3..1001a3b 100644
--- a/src/lib/format/tests/BUILD.gn
+++ b/src/lib/format/tests/BUILD.gn
@@ -14,12 +14,11 @@
 
 import("//build_overrides/build.gni")
 import("//build_overrides/chip.gni")
-import("//build_overrides/nlunit_test.gni")
 
 import("${chip_root}/build/chip/chip_test_suite.gni")
 import("${chip_root}/build/chip/fuzz_test.gni")
 
-chip_test_suite_using_nltest("tests") {
+chip_test_suite("tests") {
   output_name = "libFormatTests"
 
   test_sources = [
@@ -40,8 +39,6 @@
     "${chip_root}/src/lib/format:flat-tree",
     "${chip_root}/src/lib/format:protocol-decoder",
     "${chip_root}/src/lib/format:protocol-tlv-metadata",
-    "${chip_root}/src/lib/support:testing_nlunit",
-    "${nlunit_test_root}:nlunit-test",
   ]
 }
 
diff --git a/src/lib/format/tests/TestDecoding.cpp b/src/lib/format/tests/TestDecoding.cpp
index 0a848e5..ae5c2ef 100644
--- a/src/lib/format/tests/TestDecoding.cpp
+++ b/src/lib/format/tests/TestDecoding.cpp
@@ -17,12 +17,11 @@
 #include <lib/core/TLVWriter.h>
 #include <lib/format/protocol_decoder.h>
 #include <lib/support/StringBuilder.h>
-#include <lib/support/UnitTestRegistration.h>
 
 #include <tlv/meta/clusters_meta.h>
 #include <tlv/meta/protocols_meta.h>
 
-#include <nlunit-test.h>
+#include <gtest/gtest.h>
 
 #include "sample_data.h"
 
@@ -57,8 +56,7 @@
     { 2, _FakeProtocolData },
 } };
 
-void TestSampleData(nlTestSuite * inSuite, const PayloadDecoderInitParams & params, const SamplePayload & data,
-                    const char * expectation)
+void TestSampleData(const PayloadDecoderInitParams & params, const SamplePayload & data, const char * expectation)
 {
     chip::Decoders::PayloadDecoder<64, 128> decoder(
         PayloadDecoderInitParams(params).SetProtocol(data.protocolId).SetMessageType(data.messageType));
@@ -130,23 +128,23 @@
         printf("ACTUAL: '%s'\n", partial.Reset().Add(output_builder.c_str() + idx).AddMarkerIfOverflow().c_str());
     }
 
-    NL_TEST_ASSERT(inSuite, strcmp(output_builder.c_str(), expectation) == 0);
+    EXPECT_STREQ(output_builder.c_str(), expectation);
 }
 
-void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext)
+TEST(TestDecoding, TestFullDataDecoding)
 {
     PayloadDecoderInitParams params;
 
     params.SetProtocolDecodeTree(chip::TLVMeta::protocols_meta).SetClusterDecodeTree(chip::TLVMeta::clusters_meta);
 
-    TestSampleData(inSuite, params, secure_channel_mrp_ack, "mrp_ack: EMPTY\n");
-    TestSampleData(inSuite, params, secure_channel_pkbdf_param_request,
+    TestSampleData(params, secure_channel_mrp_ack, "mrp_ack: EMPTY\n");
+    TestSampleData(params, secure_channel_pkbdf_param_request,
                    "pbkdf_param_request\n"
                    "  initiator_random: hex:7C8698755B8E9866BB4FFDC27B733F3B6EF7F83D43FBE0CA6AD2B8C52C8F4236\n"
                    "  initiator_session_id: 37677\n"
                    "  passcode_id: 0\n"
                    "  has_pbkdf_parameters: false\n");
-    TestSampleData(inSuite, params, secure_channel_pkbdf_param_response,
+    TestSampleData(params, secure_channel_pkbdf_param_response,
                    "pbkdf_param_response\n"
                    "  initiator_random: hex:7C8698755B8E9866BB4FFDC27B733F3B6EF7F83D43FBE0CA6AD2B8C52C8F4236\n"
                    "  responder_random: hex:A44EB3E1A751A88A32BAB59EF16EB9764C20E1A9DDBEF6EFE3F588C943C58424\n"
@@ -154,24 +152,24 @@
                    "  pbkdf_parameters\n"
                    "    iterations: 1000\n"
                    "    salt: hex:E8FC1E6FD0023422B3CA7ECEDD344444551C814D3D0B0EB9C096F00E8A8051B2\n");
-    TestSampleData(inSuite, params, secure_channel_pase_pake1,
+    TestSampleData(params, secure_channel_pase_pake1,
                    // clang-format off
                    "pase_pake1\n"
                    "  pA: hex:0422ABC7A84352850456BD4A510905FE6BB782A0863A9382550E1228020801B22EEC4102C60F80082842B9739705FCD37F134651442A41E3723DFFE0...\n"
                    // clang-format on
     );
-    TestSampleData(inSuite, params, secure_channel_pase_pake2,
+    TestSampleData(params, secure_channel_pase_pake2,
                    // clang-format off
                    "pase_pake2\n"
                    "  pB: hex:04B6A44A3347C6B77900A3674CA19F40F25F056F8CB344EC1B4FA7888B9E6B570B7010431C5D0BE4021FE74A96C40721765FDA6802BE8DFDF5624332...\n"
                    "  cB: hex:40E7452275E38AEBAF0E0F6FAB33A1B0CB5AEB5E824230DD40D0071DC7E55C87\n"
                    // clang-format on
     );
-    TestSampleData(inSuite, params, secure_channel_pase_pake3,
+    TestSampleData(params, secure_channel_pase_pake3,
                    "pase_pake3\n"
                    "  cA: hex:6008C72EDEC9D25D4A36522F0BF23058F9378EFE38CBBCCE8C6853900169BC38\n");
-    TestSampleData(inSuite, params, secure_channel_status_report, "status_report: BINARY DATA\n");
-    TestSampleData(inSuite, params, im_protocol_read_request,
+    TestSampleData(params, secure_channel_status_report, "status_report: BINARY DATA\n");
+    TestSampleData(params, im_protocol_read_request,
                    "read_request\n"
                    "  attribute_requests\n"
                    "    Anonymous<>\n"
@@ -206,7 +204,7 @@
                    "      attribute_id: 3 == 'connectMaxTimeSeconds'\n"
                    "  fabric_filtered: false\n"
                    "  interaction_model_revison: 1\n");
-    TestSampleData(inSuite, params, im_protocol_report_data,
+    TestSampleData(params, im_protocol_report_data,
                    "report_data\n"
                    "  attribute_reports\n"
                    "    Anonymous<>\n"
@@ -279,7 +277,7 @@
                    "  interaction_model_revison: 1\n");
 
     // Different content
-    TestSampleData(inSuite, params, im_protocol_report_data_acl,
+    TestSampleData(params, im_protocol_report_data_acl,
                    "report_data\n"
                    "  attribute_reports\n"
                    "    Anonymous<>\n"
@@ -301,7 +299,7 @@
                    "  interaction_model_revison: 1\n");
 
     TestSampleData(
-        inSuite, params, im_protocol_report_data_window_covering,
+        params, im_protocol_report_data_window_covering,
         "report_data\n"
         "  attribute_reports\n"
         "    Anonymous<>\n"
@@ -315,7 +313,7 @@
         "  suppress_response: true\n"
         "  interaction_model_revison: 1\n");
 
-    TestSampleData(inSuite, params, im_protocol_invoke_request,
+    TestSampleData(params, im_protocol_invoke_request,
                    "invoke_request\n"
                    "  suppress_response: false\n"
                    "  timed_request: false\n"
@@ -328,7 +326,7 @@
                    "      OnOff::Toggle\n"
                    "  interaction_model_revison: 1\n");
 
-    TestSampleData(inSuite, params, im_protocol_invoke_response,
+    TestSampleData(params, im_protocol_invoke_response,
                    "invoke_response\n"
                    "  suppress_response: false\n"
                    "  invoke_responses\n"
@@ -342,7 +340,7 @@
                    "          status: 0 == kSuccess\n"
                    "  interaction_model_revison: 1\n");
 
-    TestSampleData(inSuite, params, im_protocol_invoke_request_change_channel,
+    TestSampleData(params, im_protocol_invoke_request_change_channel,
                    "invoke_request\n"
                    "  suppress_response: false\n"
                    "  timed_request: false\n"
@@ -356,7 +354,7 @@
                    "        match: \"channel name\"\n"
                    "  interaction_model_revison: 1\n");
 
-    TestSampleData(inSuite, params, im_protocol_event_software_fault,
+    TestSampleData(params, im_protocol_event_software_fault,
                    "report_data\n"
                    "  event_reports\n"
                    "    Anonymous<>\n"
@@ -375,7 +373,7 @@
                    "  suppress_response: true\n"
                    "  interaction_model_revison: 1\n");
 
-    TestSampleData(inSuite, params, im_protocol_event_multipress,
+    TestSampleData(params, im_protocol_event_multipress,
                    "report_data\n"
                    "  event_reports\n"
                    "    Anonymous<>\n"
@@ -394,22 +392,22 @@
                    "  interaction_model_revison: 1\n");
 }
 
-void TestMetaDataOnlyDecoding(nlTestSuite * inSuite, void * inContext)
+TEST(TestDecoding, TestMetaDataOnlyDecoding)
 {
     PayloadDecoderInitParams params;
 
     // NO CLUSTER DECODE TREE
     params.SetProtocolDecodeTree(chip::TLVMeta::protocols_meta);
 
-    TestSampleData(inSuite, params, secure_channel_mrp_ack, "mrp_ack: EMPTY\n");
-    TestSampleData(inSuite, params, secure_channel_pkbdf_param_request,
+    TestSampleData(params, secure_channel_mrp_ack, "mrp_ack: EMPTY\n");
+    TestSampleData(params, secure_channel_pkbdf_param_request,
                    "pbkdf_param_request\n"
                    "  initiator_random: hex:7C8698755B8E9866BB4FFDC27B733F3B6EF7F83D43FBE0CA6AD2B8C52C8F4236\n"
                    "  initiator_session_id: 37677\n"
                    "  passcode_id: 0\n"
                    "  has_pbkdf_parameters: false\n");
 
-    TestSampleData(inSuite, params, im_protocol_read_request,
+    TestSampleData(params, im_protocol_read_request,
                    "read_request\n"
                    "  attribute_requests\n"
                    "    Anonymous<>\n"
@@ -444,7 +442,7 @@
                    "      attribute_id: 3\n"
                    "  fabric_filtered: false\n"
                    "  interaction_model_revison: 1\n");
-    TestSampleData(inSuite, params, im_protocol_report_data,
+    TestSampleData(params, im_protocol_report_data,
                    "report_data\n"
                    "  attribute_reports\n"
                    "    Anonymous<>\n"
@@ -515,7 +513,7 @@
                    "  interaction_model_revison: 1\n");
 
     // Different content
-    TestSampleData(inSuite, params, im_protocol_report_data_acl,
+    TestSampleData(params, im_protocol_report_data_acl,
                    "report_data\n"
                    "  attribute_reports\n"
                    "    Anonymous<>\n"
@@ -530,14 +528,14 @@
                    "  interaction_model_revison: 1\n");
 }
 
-void TestEmptyClusterMetaDataDecode(nlTestSuite * inSuite, void * inContext)
+TEST(TestDecoding, TestEmptyClusterMetaDataDecode)
 {
     PayloadDecoderInitParams params;
 
     params.SetProtocolDecodeTree(chip::TLVMeta::protocols_meta).SetClusterDecodeTree(empty_meta);
 
-    TestSampleData(inSuite, params, secure_channel_mrp_ack, "mrp_ack: EMPTY\n");
-    TestSampleData(inSuite, params, im_protocol_report_data_acl,
+    TestSampleData(params, secure_channel_mrp_ack, "mrp_ack: EMPTY\n");
+    TestSampleData(params, im_protocol_report_data_acl,
                    "report_data\n"
                    "  attribute_reports\n"
                    "    Anonymous<>\n"
@@ -559,24 +557,24 @@
                    "  interaction_model_revison: 1\n");
 }
 
-void TestMissingDecodeData(nlTestSuite * inSuite, void * inContext)
+TEST(TestDecoding, TestMissingDecodeData)
 {
     PayloadDecoderInitParams params;
 
     params.SetProtocolDecodeTree(empty_meta).SetClusterDecodeTree(empty_meta);
 
-    TestSampleData(inSuite, params, secure_channel_mrp_ack, "PROTO(0x0, 0x10): UNKNOWN\n");
-    TestSampleData(inSuite, params, im_protocol_report_data_acl, "PROTO(0x1, 0x5): UNKNOWN\n");
+    TestSampleData(params, secure_channel_mrp_ack, "PROTO(0x0, 0x10): UNKNOWN\n");
+    TestSampleData(params, im_protocol_report_data_acl, "PROTO(0x1, 0x5): UNKNOWN\n");
 }
 
-void TestWrongDecodeData(nlTestSuite * inSuite, void * inContext)
+TEST(TestDecoding, TestWrongDecodeData)
 {
     PayloadDecoderInitParams params;
 
     params.SetProtocolDecodeTree(fake_protocols_meta).SetClusterDecodeTree(empty_meta);
 
-    TestSampleData(inSuite, params, secure_channel_mrp_ack, "proto16: EMPTY\n");
-    TestSampleData(inSuite, params, im_protocol_report_data_acl,
+    TestSampleData(params, secure_channel_mrp_ack, "proto16: EMPTY\n");
+    TestSampleData(params, im_protocol_report_data_acl,
                    "proto5\n"
                    "  ContextTag(0x1)\n"
                    "    AnonymousTag()\n"
@@ -598,7 +596,7 @@
                    "  ContextTag(0xFF): 1\n");
 }
 
-void TestNestingOverflow(nlTestSuite * inSuite, void * inContext)
+TEST(TestDecoding, TestNestingOverflow)
 {
     PayloadDecoderInitParams params;
     params.SetProtocolDecodeTree(fake_protocols_meta).SetClusterDecodeTree(empty_meta);
@@ -611,65 +609,62 @@
     chip::TLV::TLVType unusedType;
 
     // Protocols start with an anonymous tagged structure, after which lists can be of any tags
-    NL_TEST_ASSERT(inSuite, writer.StartContainer(AnonymousTag(), kTLVType_Structure, unusedType) == CHIP_NO_ERROR);
+    EXPECT_EQ(writer.StartContainer(AnonymousTag(), kTLVType_Structure, unusedType), CHIP_NO_ERROR);
 
     // nesting overflow here
     for (uint8_t i = 0; i < 32; i++)
     {
-        NL_TEST_ASSERT(inSuite, writer.StartContainer(ContextTag(i), kTLVType_List, unusedType) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.StartContainer(ContextTag(i), kTLVType_List, unusedType), CHIP_NO_ERROR);
     }
     // Go back to 24 (still too much nesting)
     for (uint8_t i = 0; i < 8; i++)
     {
-        NL_TEST_ASSERT(inSuite, writer.EndContainer(kTLVType_List) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.EndContainer(kTLVType_List), CHIP_NO_ERROR);
     }
     for (uint8_t i = 0; i < 4; i++)
     {
-        NL_TEST_ASSERT(
-            inSuite, writer.StartContainer(ContextTag(static_cast<uint8_t>(i + 0x10)), kTLVType_List, unusedType) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.StartContainer(ContextTag(static_cast<uint8_t>(i + 0x10)), kTLVType_List, unusedType), CHIP_NO_ERROR);
     }
     for (uint8_t i = 0; i < 4; i++)
     {
-        NL_TEST_ASSERT(inSuite, writer.EndContainer(kTLVType_List) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.EndContainer(kTLVType_List), CHIP_NO_ERROR);
     }
     // Go back to 8
     for (uint8_t i = 0; i < 16; i++)
     {
-        NL_TEST_ASSERT(inSuite, writer.EndContainer(kTLVType_List) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.EndContainer(kTLVType_List), CHIP_NO_ERROR);
     }
     for (uint8_t i = 0; i < 4; i++)
     {
-        NL_TEST_ASSERT(
-            inSuite, writer.StartContainer(ContextTag(static_cast<uint8_t>(i + 0x20)), kTLVType_List, unusedType) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.StartContainer(ContextTag(static_cast<uint8_t>(i + 0x20)), kTLVType_List, unusedType), CHIP_NO_ERROR);
     }
     for (uint8_t i = 0; i < 4; i++)
     {
-        NL_TEST_ASSERT(inSuite, writer.EndContainer(kTLVType_List) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.EndContainer(kTLVType_List), CHIP_NO_ERROR);
     }
     // Go back to 4
     for (uint8_t i = 0; i < 4; i++)
     {
-        NL_TEST_ASSERT(inSuite, writer.EndContainer(kTLVType_List) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.EndContainer(kTLVType_List), CHIP_NO_ERROR);
     }
     for (uint8_t i = 0; i < 4; i++)
     {
-        NL_TEST_ASSERT(
-            inSuite, writer.StartContainer(ContextTag(static_cast<uint8_t>(i + 0x30)), kTLVType_List, unusedType) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.StartContainer(ContextTag(static_cast<uint8_t>(i + 0x30)), kTLVType_List, unusedType), CHIP_NO_ERROR);
     }
     for (uint8_t i = 0; i < 4; i++)
     {
-        NL_TEST_ASSERT(inSuite, writer.EndContainer(kTLVType_List) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.EndContainer(kTLVType_List), CHIP_NO_ERROR);
     }
     // close everything
     for (uint8_t i = 0; i < 4; i++)
     {
-        NL_TEST_ASSERT(inSuite, writer.EndContainer(kTLVType_List) == CHIP_NO_ERROR);
+        EXPECT_EQ(writer.EndContainer(kTLVType_List), CHIP_NO_ERROR);
     }
-    NL_TEST_ASSERT(inSuite, writer.EndContainer(kTLVType_Structure) == CHIP_NO_ERROR);
+    EXPECT_EQ(writer.EndContainer(kTLVType_Structure), CHIP_NO_ERROR);
 
     SamplePayload fake_payload{ chip::Protocols::InteractionModel::Id, 5, chip::ByteSpan(data_buffer, writer.GetLengthWritten()) };
 
-    TestSampleData(inSuite, params, fake_payload,
+    TestSampleData(params, fake_payload,
                    "proto5\n"
                    "  ContextTag(0x0)\n"
                    "    ContextTag(0x1)\n"
@@ -696,24 +691,4 @@
                    "              ContextTag(0x32)\n"
                    "                ContextTag(0x33)\n");
 }
-
-const nlTest sTests[] = {
-    NL_TEST_DEF("TestFullDataDecoding", TestFullDataDecoding),                     //
-    NL_TEST_DEF("TestMetaDataOnlyDecoding", TestMetaDataOnlyDecoding),             //
-    NL_TEST_DEF("TestEmptyClusterMetaDataDecode", TestEmptyClusterMetaDataDecode), //
-    NL_TEST_DEF("TestMissingDecodeData", TestMissingDecodeData),                   //
-    NL_TEST_DEF("TestWrongDecodeData", TestWrongDecodeData),                       //
-    NL_TEST_DEF("TestNestingOverflow", TestNestingOverflow),                       //
-    NL_TEST_SENTINEL()                                                             //
-};
-
 } // namespace
-
-int TestDecode()
-{
-    nlTestSuite theSuite = { "TestDecode", sTests, nullptr, nullptr };
-    nlTestRunner(&theSuite, nullptr);
-    return nlTestRunnerStats(&theSuite);
-}
-
-CHIP_REGISTER_TEST_SUITE(TestDecode)
diff --git a/src/lib/format/tests/TestFlatTree.cpp b/src/lib/format/tests/TestFlatTree.cpp
index 8eebb98..fcf8e27 100644
--- a/src/lib/format/tests/TestFlatTree.cpp
+++ b/src/lib/format/tests/TestFlatTree.cpp
@@ -17,13 +17,12 @@
 #include <lib/format/FlatTree.h>
 
 #include <lib/core/TLVTags.h>
-#include <lib/support/UnitTestRegistration.h>
 
 #include <array>
 
 #include <string.h>
 
-#include <nlunit-test.h>
+#include <gtest/gtest.h>
 
 namespace {
 
@@ -82,43 +81,28 @@
     const char * mName;
 };
 
-void TestFlatTreeFind(nlTestSuite * inSuite, void * inContext)
+TEST(TestFlatTree, TestFlatTreeFind)
 {
-    NL_TEST_ASSERT(inSuite, strcmp(FindEntry(tree, 0, ByTag(ContextTag(1)))->data.name, "hello") == 0);
-    NL_TEST_ASSERT(inSuite, strcmp(FindEntry(tree, 0, ByTag(ContextTag(2)))->data.name, "world") == 0);
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 0, ByTag(ContextTag(3))) == nullptr);
+    EXPECT_STREQ(FindEntry(tree, 0, ByTag(ContextTag(1)))->data.name, "hello");
+    EXPECT_STREQ(FindEntry(tree, 0, ByTag(ContextTag(2)))->data.name, "world");
+    EXPECT_EQ(FindEntry(tree, 0, ByTag(ContextTag(3))), nullptr);
 
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 0, ByName("hello"))->data.tag == ContextTag(1));
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 0, ByName("world"))->data.tag == ContextTag(2));
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 0, ByName("foo")) == nullptr);
+    EXPECT_EQ(FindEntry(tree, 0, ByName("hello"))->data.tag, ContextTag(1));
+    EXPECT_EQ(FindEntry(tree, 0, ByName("world"))->data.tag, ContextTag(2));
+    EXPECT_EQ(FindEntry(tree, 0, ByName("foo")), nullptr);
 
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 1, ByTag(ContextTag(1))) == nullptr);
-    NL_TEST_ASSERT(inSuite, strcmp(FindEntry(tree, 1, ByTag(ProfileTag(234, 2)))->data.name, "b") == 0);
-    NL_TEST_ASSERT(inSuite, strcmp(FindEntry(tree, 1, ByTag(ProfileTag(345, 3)))->data.name, "c") == 0);
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 1, ByTag(AnonymousTag())) == nullptr);
+    EXPECT_EQ(FindEntry(tree, 1, ByTag(ContextTag(1))), nullptr);
+    EXPECT_STREQ(FindEntry(tree, 1, ByTag(ProfileTag(234, 2)))->data.name, "b");
+    EXPECT_STREQ(FindEntry(tree, 1, ByTag(ProfileTag(345, 3)))->data.name, "c");
+    EXPECT_EQ(FindEntry(tree, 1, ByTag(AnonymousTag())), nullptr);
 
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 2, ByTag(ContextTag(1))) == nullptr);
-    NL_TEST_ASSERT(inSuite, strcmp(FindEntry(tree, 2, ByTag(AnonymousTag()))->data.name, "foo") == 0);
+    EXPECT_EQ(FindEntry(tree, 2, ByTag(ContextTag(1))), nullptr);
+    EXPECT_STREQ(FindEntry(tree, 2, ByTag(AnonymousTag()))->data.name, "foo");
 
     // out of array
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 3, ByTag(AnonymousTag())) == nullptr);
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 100, ByTag(AnonymousTag())) == nullptr);
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 1000, ByTag(AnonymousTag())) == nullptr);
-    NL_TEST_ASSERT(inSuite, FindEntry(tree, 9999999, ByTag(AnonymousTag())) == nullptr);
+    EXPECT_EQ(FindEntry(tree, 3, ByTag(AnonymousTag())), nullptr);
+    EXPECT_EQ(FindEntry(tree, 100, ByTag(AnonymousTag())), nullptr);
+    EXPECT_EQ(FindEntry(tree, 1000, ByTag(AnonymousTag())), nullptr);
+    EXPECT_EQ(FindEntry(tree, 9999999, ByTag(AnonymousTag())), nullptr);
 }
-
-const nlTest sTests[] = {
-    NL_TEST_DEF("TestFlatTreeFind", TestFlatTreeFind), //
-    NL_TEST_SENTINEL()                                 //
-};
-
 } // namespace
-
-int TestFlatTree()
-{
-    nlTestSuite theSuite = { "FlatTree", sTests, nullptr, nullptr };
-    nlTestRunner(&theSuite, nullptr);
-    return nlTestRunnerStats(&theSuite);
-}
-
-CHIP_REGISTER_TEST_SUITE(TestFlatTree)
diff --git a/src/lib/format/tests/TestFlatTreePosition.cpp b/src/lib/format/tests/TestFlatTreePosition.cpp
index ee5f6b3..cf5a26e 100644
--- a/src/lib/format/tests/TestFlatTreePosition.cpp
+++ b/src/lib/format/tests/TestFlatTreePosition.cpp
@@ -18,14 +18,13 @@
 #include <lib/format/FlatTreePosition.h>
 
 #include <lib/core/TLVTags.h>
-#include <lib/support/UnitTestRegistration.h>
 
 #include <array>
 #include <vector>
 
 #include <string.h>
 
-#include <nlunit-test.h>
+#include <gtest/gtest.h>
 
 namespace {
 
@@ -94,16 +93,16 @@
 };
 
 #define ASSERT_HAS_NAME(p, n)                                                                                                      \
-    NL_TEST_ASSERT(inSuite, p.Get() != nullptr);                                                                                   \
-    NL_TEST_ASSERT(inSuite, strcmp(p.Get()->name, n) == 0)
+    EXPECT_NE(p.Get(), nullptr);                                                                                                   \
+    EXPECT_STREQ(p.Get()->name, n);
 
 #define ASSERT_HAS_CONTEXT_TAG(p, t)                                                                                               \
-    NL_TEST_ASSERT(inSuite, p.Get() != nullptr);                                                                                   \
-    NL_TEST_ASSERT(inSuite, p.Get()->tag == ContextTag(t))
+    EXPECT_NE(p.Get(), nullptr);                                                                                                   \
+    EXPECT_EQ(p.Get()->tag, ContextTag(t))
 
 #define ASSERT_HAS_PROFILE_TAG(p, a, b)                                                                                            \
-    NL_TEST_ASSERT(inSuite, p.Get() != nullptr);                                                                                   \
-    NL_TEST_ASSERT(inSuite, p.Get()->tag == ProfileTag(a, b))
+    EXPECT_NE(p.Get(), nullptr);                                                                                                   \
+    EXPECT_EQ(p.Get()->tag, ProfileTag(a, b))
 
 template <size_t N>
 std::vector<Tag> GetPath(Position<NamedTag, N> & position)
@@ -133,54 +132,54 @@
     return (v.size() == 3) && (v[0] == a) && (v[1] == b) && (v[2] == c);
 }
 
-void TestSimpleEnterExit(nlTestSuite * inSuite, void * inContext)
+TEST(TestFlatTreePosition, TestSimpleEnterExit)
 {
     Position<NamedTag, 10> position(tree.data(), tree.size());
 
     // at start, top of tree has no value
-    NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
-    NL_TEST_ASSERT(inSuite, GetPath(position).empty());
+    EXPECT_EQ(position.Get(), nullptr);
+    EXPECT_TRUE(GetPath(position).empty());
 
     // Go to hello, try going to invalid 2x, then go back
     position.Enter(ByTag(ContextTag(1)));
     ASSERT_HAS_NAME(position, "hello");
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(1)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(1)));
 
     position.Enter(ByTag(ContextTag(1)));
-    NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
-    NL_TEST_ASSERT(inSuite, GetPath(position).empty());
+    EXPECT_EQ(position.Get(), nullptr);
+    EXPECT_TRUE(GetPath(position).empty());
     position.Enter(ByTag(ContextTag(1)));
-    NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
+    EXPECT_EQ(position.Get(), nullptr);
     position.Exit();
-    NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
+    EXPECT_EQ(position.Get(), nullptr);
     position.Exit();
-    NL_TEST_ASSERT(inSuite, position.Get() != nullptr);
+    ASSERT_NE(position.Get(), nullptr);
     ASSERT_HAS_NAME(position, "hello");
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(1)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(1)));
     position.Exit();
-    NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
+    EXPECT_EQ(position.Get(), nullptr);
 }
 
-void TestDeeperEnter(nlTestSuite * inSuite, void * inContext)
+TEST(TestFlatTreePosition, TestDeeperEnter)
 {
     Position<NamedTag, 10> position(tree.data(), tree.size());
 
-    NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
+    EXPECT_EQ(position.Get(), nullptr);
 
     position.Enter(ByName("world"));
     ASSERT_HAS_CONTEXT_TAG(position, 2);
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2)));
 
     position.Enter(ByTag(ProfileTag(123, 1)));
     ASSERT_HAS_NAME(position, "a");
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2), ProfileTag(123, 1)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2), ProfileTag(123, 1)));
 
     position.Enter(ByTag(AnonymousTag()));
-    NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
-    NL_TEST_ASSERT(inSuite, GetPath(position).empty());
+    EXPECT_EQ(position.Get(), nullptr);
+    EXPECT_TRUE(GetPath(position).empty());
     position.Exit();
     ASSERT_HAS_NAME(position, "a");
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2), ProfileTag(123, 1)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2), ProfileTag(123, 1)));
 
     position.Exit();
     ASSERT_HAS_NAME(position, "world");
@@ -190,30 +189,30 @@
 
     position.Enter(ByTag(AnonymousTag()));
     ASSERT_HAS_NAME(position, "foo");
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2), ProfileTag(234, 2), AnonymousTag()));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2), ProfileTag(234, 2), AnonymousTag()));
 
     // test some unknown
     for (int i = 0; i < 100; i++)
     {
         position.Enter(ByTag(AnonymousTag()));
-        NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
-        NL_TEST_ASSERT(inSuite, GetPath(position).empty());
+        EXPECT_EQ(position.Get(), nullptr);
+        EXPECT_TRUE(GetPath(position).empty());
     }
     for (int i = 0; i < 100; i++)
     {
-        NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
-        NL_TEST_ASSERT(inSuite, GetPath(position).empty());
+        EXPECT_EQ(position.Get(), nullptr);
+        EXPECT_TRUE(GetPath(position).empty());
         position.Exit();
     }
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2), ProfileTag(234, 2), AnonymousTag()));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2), ProfileTag(234, 2), AnonymousTag()));
     ASSERT_HAS_NAME(position, "foo");
     position.Exit();
 
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2), ProfileTag(234, 2)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2), ProfileTag(234, 2)));
     ASSERT_HAS_NAME(position, "b");
     position.Exit();
 
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2)));
     ASSERT_HAS_NAME(position, "world");
 
     // root and stay there
@@ -221,15 +220,15 @@
     position.Exit();
     position.Exit();
     position.Exit();
-    NL_TEST_ASSERT(inSuite, GetPath(position).empty());
+    EXPECT_TRUE(GetPath(position).empty());
 
     // can still navigate from the root
     position.Enter(ByName("world"));
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2)));
     ASSERT_HAS_CONTEXT_TAG(position, 2);
 }
 
-void TestDescendLimit(nlTestSuite * inSuite, void * inContext)
+TEST(TestFlatTreePosition, TestDescendLimit)
 {
     Position<NamedTag, 2> position(tree.data(), tree.size());
 
@@ -241,34 +240,17 @@
 
     // only 2 positions can be remembered. Running out of space
     position.Enter(ByName("foo"));
-    NL_TEST_ASSERT(inSuite, position.Get() == nullptr);
-    NL_TEST_ASSERT(inSuite, GetPath(position).empty());
+    EXPECT_EQ(position.Get(), nullptr);
+    EXPECT_TRUE(GetPath(position).empty());
 
     position.Exit();
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2), ProfileTag(234, 2)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2), ProfileTag(234, 2)));
     ASSERT_HAS_NAME(position, "b");
     ASSERT_HAS_PROFILE_TAG(position, 234, 2);
 
     position.Exit();
-    NL_TEST_ASSERT(inSuite, HasPath(GetPath(position), ContextTag(2)));
+    EXPECT_TRUE(HasPath(GetPath(position), ContextTag(2)));
     ASSERT_HAS_NAME(position, "world");
     ASSERT_HAS_CONTEXT_TAG(position, 2);
 }
-
-const nlTest sTests[] = {
-    NL_TEST_DEF("TestSimpleEnterExit", TestSimpleEnterExit), //
-    NL_TEST_DEF("TestDeeperEnter", TestDeeperEnter),         //
-    NL_TEST_DEF("TestDescendLimit", TestDescendLimit),       //
-    NL_TEST_SENTINEL()                                       //
-};
-
 } // namespace
-
-int TestFlatTreePosition()
-{
-    nlTestSuite theSuite = { "FlatTree", sTests, nullptr, nullptr };
-    nlTestRunner(&theSuite, nullptr);
-    return nlTestRunnerStats(&theSuite);
-}
-
-CHIP_REGISTER_TEST_SUITE(TestFlatTreePosition)