Skip to content

Commit

Permalink
Updated TestTLV test: Added IS1_CHAR define.
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis committed Jan 20, 2023
1 parent e8eaf18 commit aa1897d
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/lib/core/tests/TestTLV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2789,6 +2789,8 @@ void CheckTLVByteSpan(nlTestSuite * inSuite, void * inContext)
NL_TEST_ASSERT(inSuite, memcmp(readerSpan.data(), bytesBuffer, sizeof(bytesBuffer)) == 0);
}

#define IS1_CHAR "\x1F"

void CheckTLVCharSpan(nlTestSuite * inSuite, void * inContext)
{
struct CharSpanTestCase
Expand All @@ -2799,14 +2801,14 @@ void CheckTLVCharSpan(nlTestSuite * inSuite, void * inContext)

// clang-format off
static CharSpanTestCase sCharSpanTestCases[] = {
// Test String Expected String from Get()
// =========================================================================================
{ "This is a test case #0", "This is a test case #0" },
{ "This is a test case #1\x1fTest Localized String Identifier", "This is a test case #1" },
{ "This is a test case #2 \x1f abc \x1f def", "This is a test case #2 " },
{ "This is a test case #3\x1f", "This is a test case #3" },
{ "Thé\037", "Thé" },
{ "\x1f abc \x1f def", "" },
// Test String Expected String from Get()
// ==================================================================================================
{ "This is a test case #0", "This is a test case #0" },
{ "This is a test case #1" IS1_CHAR "Test Localized String Identifier", "This is a test case #1" },
{ "This is a test case #2 " IS1_CHAR "abc" IS1_CHAR "def", "This is a test case #2 " },
{ "This is a test case #3" IS1_CHAR, "This is a test case #3" },
{ "Thé" IS1_CHAR, "Thé" },
{ IS1_CHAR " abc " IS1_CHAR " def", "" },
};
// clang-format on

Expand Down Expand Up @@ -2848,21 +2850,21 @@ void CheckTLVGetLocalizedStringIdentifier(nlTestSuite * inSuite, void * inContex

// clang-format off
static CharSpanTestCase sCharSpanTestCases[] = {
// Test String Expected LocalizedStringIdentifier from Get()
// ==============================================================================================
{ "This is a test case #0", chip::Optional<LocalizedStringIdentifier>() },
{ "This is a test case #1\0370123", chip::Optional<LocalizedStringIdentifier>(0x0123) },
{ "This is a test case #2\0370123\0373210", chip::Optional<LocalizedStringIdentifier>(0x0123) },
{ "This is a test case #3\037012", chip::Optional<LocalizedStringIdentifier>(0x012) },
{ "Thé\037", chip::Optional<LocalizedStringIdentifier>() },
{ "Thé\0377", chip::Optional<LocalizedStringIdentifier>(0x7) },
{ "Thé\0371FA", chip::Optional<LocalizedStringIdentifier>(0x1FA) },
{ "\0371FA", chip::Optional<LocalizedStringIdentifier>(0x1FA) },
{ "Thé\0371FAB", chip::Optional<LocalizedStringIdentifier>(0x1FAB) },
{ "Thé\0371FAb", chip::Optional<LocalizedStringIdentifier>() },
{ "Thé\0371FABC", chip::Optional<LocalizedStringIdentifier>() },
{ "Thé\0371FA\037", chip::Optional<LocalizedStringIdentifier>(0x1FA) },
{ "Thé\0371FA\037F8sa===", chip::Optional<LocalizedStringIdentifier>(0x1FA) },
// Test String Expected LocalizedStringIdentifier from Get()
// ==============================================================================================================
{ "This is a test case #0", chip::Optional<LocalizedStringIdentifier>() },
{ "This is a test case #1" IS1_CHAR "0123", chip::Optional<LocalizedStringIdentifier>(0x0123) },
{ "This is a test case #2" IS1_CHAR "0123" IS1_CHAR "3210", chip::Optional<LocalizedStringIdentifier>(0x0123) },
{ "This is a test case #3" IS1_CHAR "012", chip::Optional<LocalizedStringIdentifier>(0x012) },
{ "Thé" IS1_CHAR "", chip::Optional<LocalizedStringIdentifier>() },
{ "Thé" IS1_CHAR "7", chip::Optional<LocalizedStringIdentifier>(0x7) },
{ "Thé" IS1_CHAR "1FA", chip::Optional<LocalizedStringIdentifier>(0x1FA) },
{ "" IS1_CHAR "1FA", chip::Optional<LocalizedStringIdentifier>(0x1FA) },
{ "Thé" IS1_CHAR "1FAB", chip::Optional<LocalizedStringIdentifier>(0x1FAB) },
{ "Thé" IS1_CHAR "1FAb", chip::Optional<LocalizedStringIdentifier>() },
{ "Thé" IS1_CHAR "1FABC", chip::Optional<LocalizedStringIdentifier>() },
{ "Thé" IS1_CHAR "1FA" IS1_CHAR "", chip::Optional<LocalizedStringIdentifier>(0x1FA) },
{ "Thé" IS1_CHAR "1FA" IS1_CHAR "F8sa===", chip::Optional<LocalizedStringIdentifier>(0x1FA) },
};
// clang-format on

Expand Down

0 comments on commit aa1897d

Please sign in to comment.