|
25 | 25 | */
|
26 | 26 |
|
27 | 27 | #include <ble/BleUUID.h>
|
28 |
| -#include <lib/support/UnitTestRegistration.h> |
29 | 28 |
|
30 |
| -#include <nlunit-test.h> |
| 29 | +#include <gtest/gtest.h> |
31 | 30 |
|
32 | 31 | using namespace chip;
|
33 | 32 | using namespace chip::Ble;
|
34 | 33 |
|
35 | 34 | namespace {
|
36 | 35 |
|
37 |
| -void CheckStringToUUID_ChipUUID(nlTestSuite * inSuite, void * inContext) |
| 36 | +TEST(TestBleUUID, CheckStringToUUID_ChipUUID) |
38 | 37 | {
|
39 | 38 | // Test positive scenario - CHIP Service UUID
|
40 | 39 | ChipBleUUID uuid;
|
41 |
| - NL_TEST_ASSERT(inSuite, StringToUUID("0000FFF6-0000-1000-8000-00805F9B34FB", uuid)); |
42 |
| - NL_TEST_ASSERT(inSuite, UUIDsMatch(&uuid, &CHIP_BLE_SVC_ID)); |
| 40 | + EXPECT_TRUE(StringToUUID("0000FFF6-0000-1000-8000-00805F9B34FB", uuid)); |
| 41 | + EXPECT_TRUE(UUIDsMatch(&uuid, &CHIP_BLE_SVC_ID)); |
43 | 42 | }
|
44 | 43 |
|
45 |
| -void CheckStringToUUID_ChipUUID_RandomCase(nlTestSuite * inSuite, void * inContext) |
| 44 | +TEST(TestBleUUID, CheckStringToUUID_ChipUUID_RandomCase) |
46 | 45 | {
|
47 | 46 | // Test that letter case doesn't matter
|
48 | 47 | ChipBleUUID uuid;
|
49 |
| - NL_TEST_ASSERT(inSuite, StringToUUID("0000FfF6-0000-1000-8000-00805f9B34Fb", uuid)); |
50 |
| - NL_TEST_ASSERT(inSuite, UUIDsMatch(&uuid, &CHIP_BLE_SVC_ID)); |
| 48 | + EXPECT_TRUE(StringToUUID("0000FfF6-0000-1000-8000-00805f9B34Fb", uuid)); |
| 49 | + EXPECT_TRUE(UUIDsMatch(&uuid, &CHIP_BLE_SVC_ID)); |
51 | 50 | }
|
52 | 51 |
|
53 |
| -void CheckStringToUUID_ChipUUID_NoSeparators(nlTestSuite * inSuite, void * inContext) |
| 52 | +TEST(TestBleUUID, CheckStringToUUID_ChipUUID_NoSeparators) |
54 | 53 | {
|
55 | 54 | // Test that separators don't matter
|
56 | 55 | ChipBleUUID uuid;
|
57 |
| - NL_TEST_ASSERT(inSuite, StringToUUID("0000FFF600001000800000805F9B34FB", uuid)); |
58 |
| - NL_TEST_ASSERT(inSuite, UUIDsMatch(&uuid, &CHIP_BLE_SVC_ID)); |
| 56 | + EXPECT_TRUE(StringToUUID("0000FFF600001000800000805F9B34FB", uuid)); |
| 57 | + EXPECT_TRUE(UUIDsMatch(&uuid, &CHIP_BLE_SVC_ID)); |
59 | 58 | }
|
60 | 59 |
|
61 |
| -void CheckStringToUUID_TooLong(nlTestSuite * inSuite, void * inContext) |
| 60 | +TEST(TestBleUUID, CheckStringToUUID_TooLong) |
62 | 61 | {
|
63 | 62 | // Test that even one more digit is too much
|
64 | 63 | ChipBleUUID uuid;
|
65 |
| - NL_TEST_ASSERT(inSuite, !StringToUUID("0000FFF600001000800000805F9B34FB0", uuid)); |
| 64 | + EXPECT_FALSE(StringToUUID("0000FFF600001000800000805F9B34FB0", uuid)); |
66 | 65 | }
|
67 | 66 |
|
68 |
| -void CheckStringToUUID_TooShort(nlTestSuite * inSuite, void * inContext) |
| 67 | +TEST(TestBleUUID, CheckStringToUUID_TooShort) |
69 | 68 | {
|
70 | 69 | // Test that even one less digit is too little
|
71 | 70 | ChipBleUUID uuid;
|
72 |
| - NL_TEST_ASSERT(inSuite, !StringToUUID("0000FFF600001000800000805F9B34F", uuid)); |
| 71 | + EXPECT_FALSE(StringToUUID("0000FFF600001000800000805F9B34F", uuid)); |
73 | 72 | }
|
74 | 73 |
|
75 |
| -void CheckStringToUUID_InvalidChar(nlTestSuite * inSuite, void * inContext) |
| 74 | +TEST(TestBleUUID, CheckStringToUUID_InvalidChar) |
76 | 75 | {
|
77 | 76 | // Test that non-hex digits don't pass
|
78 | 77 | ChipBleUUID uuid;
|
79 |
| - NL_TEST_ASSERT(inSuite, !StringToUUID("0000GFF6-0000-1000-8000-00805F9B34FB0", uuid)); |
| 78 | + EXPECT_FALSE(StringToUUID("0000GFF6-0000-1000-8000-00805F9B34FB0", uuid)); |
80 | 79 | }
|
81 | 80 |
|
82 |
| -// clang-format off |
83 |
| -const nlTest sTests[] = |
84 |
| -{ |
85 |
| - NL_TEST_DEF("CheckStringToUUID_ChipUUID", CheckStringToUUID_ChipUUID), |
86 |
| - NL_TEST_DEF("CheckStringToUUID_ChipUUID_RandomCase", CheckStringToUUID_ChipUUID_RandomCase), |
87 |
| - NL_TEST_DEF("CheckStringToUUID_ChipUUID_NoSeparators", CheckStringToUUID_ChipUUID_NoSeparators), |
88 |
| - NL_TEST_DEF("CheckStringToUUID_TooLong", CheckStringToUUID_TooLong), |
89 |
| - NL_TEST_DEF("CheckStringToUUID_TooShort", CheckStringToUUID_TooShort), |
90 |
| - NL_TEST_DEF("CheckStringToUUID_InvalidChar", CheckStringToUUID_InvalidChar), |
91 |
| - NL_TEST_SENTINEL() |
92 |
| -}; |
93 |
| -// clang-format on |
94 |
| - |
95 | 81 | } // namespace
|
96 |
| - |
97 |
| -int TestBleUUID() |
98 |
| -{ |
99 |
| - nlTestSuite theSuite = { "BleUUID", &sTests[0], nullptr, nullptr }; |
100 |
| - nlTestRunner(&theSuite, nullptr); |
101 |
| - return nlTestRunnerStats(&theSuite); |
102 |
| -} |
103 |
| - |
104 |
| -CHIP_REGISTER_TEST_SUITE(TestBleUUID) |
0 commit comments