@@ -705,7 +705,8 @@ void TestConverter_Array_Empty_ImplicitProfileTag4(nlTestSuite * inSuite, void *
705
705
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.StartContainer (TLV::AnonymousTag (), TLV::kTLVType_Structure , containerType));
706
706
NL_TEST_ASSERT (gSuite ,
707
707
CHIP_NO_ERROR ==
708
- writer.StartContainer (TLV::ProfileTag (kImplicitProfileId , 1000000 ), TLV::kTLVType_Array , containerType2));
708
+ writer.StartContainer (TLV::ProfileTag ((1000000 >> 16 ) & 0xFFFF , 0 , 1000000 & 0xFFFF ), TLV::kTLVType_Array ,
709
+ containerType2));
709
710
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.EndContainer (containerType2));
710
711
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.EndContainer (containerType));
711
712
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Finalize ());
@@ -1070,7 +1071,8 @@ void TestConverter_Array_Strings(nlTestSuite * inSuite, void * inContext)
1070
1071
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.StartContainer (TLV::AnonymousTag (), TLV::kTLVType_Structure , containerType));
1071
1072
NL_TEST_ASSERT (gSuite ,
1072
1073
CHIP_NO_ERROR ==
1073
- writer.StartContainer (TLV::ProfileTag (kImplicitProfileId , 100000 ), TLV::kTLVType_Array , containerType2));
1074
+ writer.StartContainer (TLV::ProfileTag ((100000 >> 16 ) & 0xFFFF , 0 , 100000 & 0xFFFF ), TLV::kTLVType_Array ,
1075
+ containerType2));
1074
1076
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.PutString (TLV::AnonymousTag (), " ABC" ));
1075
1077
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.PutString (TLV::AnonymousTag (), " Options" ));
1076
1078
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.PutString (TLV::AnonymousTag (), " more" ));
@@ -1202,11 +1204,10 @@ void TestConverter_Struct_MixedTags(nlTestSuite * inSuite, void * inContext)
1202
1204
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.StartContainer (TLV::AnonymousTag (), TLV::kTLVType_Structure , containerType));
1203
1205
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.StartContainer (TLV::ContextTag (0 ), TLV::kTLVType_Structure , containerType2));
1204
1206
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ContextTag (255 ), static_cast <uint64_t >(42 )));
1207
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (0x0001u , 0 , 0 ), static_cast <uint64_t >(345678 )));
1205
1208
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (kImplicitProfileId , 256 ), static_cast <uint64_t >(17000 )));
1209
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (0xFFFFu , 0 , 0xFFFFu ), static_cast <uint64_t >(500000000000 )));
1206
1210
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (kImplicitProfileId , 65535 ), static_cast <uint64_t >(1 )));
1207
- NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (kImplicitProfileId , 65536 ), static_cast <uint64_t >(345678 )));
1208
- NL_TEST_ASSERT (
1209
- gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (kImplicitProfileId , 4294967295 ), static_cast <uint64_t >(500000000000 )));
1210
1211
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.EndContainer (containerType2));
1211
1212
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.EndContainer (containerType));
1212
1213
NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Finalize ());
@@ -1706,7 +1707,7 @@ void TestConverter_TlvToJson_ErrorCases(nlTestSuite * inSuite, void * inContext)
1706
1707
uint8_t buf9[32 ];
1707
1708
writer.Init (buf9);
1708
1709
NL_TEST_ASSERT (inSuite, CHIP_NO_ERROR == writer.StartContainer (TLV::AnonymousTag (), TLV::kTLVType_Structure , containerType));
1709
- NL_TEST_ASSERT (inSuite, CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (0xAA55FEED , 234 ), static_cast <uint64_t >(42 )));
1710
+ NL_TEST_ASSERT (inSuite, CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (0xFEED , 234 ), static_cast <uint64_t >(42 )));
1710
1711
NL_TEST_ASSERT (inSuite, CHIP_NO_ERROR == writer.EndContainer (containerType));
1711
1712
NL_TEST_ASSERT (inSuite, CHIP_NO_ERROR == writer.Finalize ());
1712
1713
ByteSpan useFullyQualifiedTag (buf9, writer.GetLengthWritten ());
@@ -1773,10 +1774,6 @@ void TestConverter_JsonToTlv_ErrorCases(nlTestSuite * inSuite, void * inContext)
1773
1774
" \" UINT\" : 42\n "
1774
1775
" }\n " ;
1775
1776
1776
- std::string invalidNameTagValueTooBig = " {\n "
1777
- " \" invalid:4294967296:UINT\" : 42\n "
1778
- " }\n " ;
1779
-
1780
1777
std::string invalidNameWithNegativeTag = " {\n "
1781
1778
" \" -1:UINT\" : 42\n "
1782
1779
" }\n " ;
@@ -1814,7 +1811,6 @@ void TestConverter_JsonToTlv_ErrorCases(nlTestSuite * inSuite, void * inContext)
1814
1811
{ arrayElementsWithName, CHIP_ERROR_INTERNAL, " Array Elements With Json Name" },
1815
1812
{ invalidNameWithoutTagField, CHIP_ERROR_INVALID_ARGUMENT, " Invalid Name String Without Tag Field" },
1816
1813
{ invalidNameWithoutTagField2, CHIP_ERROR_INVALID_ARGUMENT, " Invalid Name String Without Tag Field 2" },
1817
- { invalidNameTagValueTooBig, CHIP_ERROR_INVALID_ARGUMENT, " Invalid Name String Tag Value Larger than UINT32_MAX" },
1818
1814
{ invalidNameWithNegativeTag, CHIP_ERROR_INVALID_ARGUMENT, " Invalid Name With Negative Tag Value" },
1819
1815
{ invalidNameWithInvalidTypeField, CHIP_ERROR_INVALID_ARGUMENT, " Invalid Name With Invalid Type Field" },
1820
1816
{ invalidBytesBase64Value1, CHIP_ERROR_INVALID_ARGUMENT, " Invalid Base64 Encoding: Invalid Character" },
@@ -1834,6 +1830,40 @@ void TestConverter_JsonToTlv_ErrorCases(nlTestSuite * inSuite, void * inContext)
1834
1830
}
1835
1831
}
1836
1832
1833
+ // Full Qualified Profile tags, Unsigned Integer structure: {65536 = 42, 4294901760 = 17000, 4294967295 = 500000000000}
1834
+ void TestConverter_Struct_MEITags (nlTestSuite * inSuite, void * inContext)
1835
+ {
1836
+ gSuite = inSuite;
1837
+
1838
+ uint8_t buf[256 ];
1839
+ TLV::TLVWriter writer;
1840
+ TLV::TLVType containerType;
1841
+ TLV::TLVType containerType2;
1842
+
1843
+ writer.Init (buf);
1844
+ writer.ImplicitProfileId = kImplicitProfileId ;
1845
+
1846
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.StartContainer (TLV::AnonymousTag (), TLV::kTLVType_Structure , containerType));
1847
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.StartContainer (TLV::ContextTag (0 ), TLV::kTLVType_Structure , containerType2));
1848
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (0xFFFFu , 0 , 0 ), static_cast <uint64_t >(17000 )));
1849
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (0x0001u , 0 , 0 ), static_cast <uint64_t >(42 )));
1850
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Put (TLV::ProfileTag (0xFFFFu , 0 , 0xFFFFu ), static_cast <uint64_t >(500000000000 )));
1851
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.EndContainer (containerType2));
1852
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.EndContainer (containerType));
1853
+ NL_TEST_ASSERT (gSuite , CHIP_NO_ERROR == writer.Finalize ());
1854
+
1855
+ std::string jsonString = " {\n "
1856
+ " \" 0:STRUCT\" : {\n "
1857
+ " \" 65536:UINT\" : 42,\n "
1858
+ " \" 4294901760:UINT\" : 17000,\n "
1859
+ " \" 4294967295:UINT\" : \" 500000000000\"\n "
1860
+ " }\n "
1861
+ " }\n " ;
1862
+
1863
+ ByteSpan tlvSpan (buf, writer.GetLengthWritten ());
1864
+ CheckValidConversion (jsonString, tlvSpan, jsonString);
1865
+ }
1866
+
1837
1867
int Initialize (void * apSuite)
1838
1868
{
1839
1869
VerifyOrReturnError (chip::Platform::MemoryInit () == CHIP_NO_ERROR, FAILURE);
@@ -1899,6 +1929,7 @@ const nlTest sTests[] = {
1899
1929
NL_TEST_DEF (" Test Json Tlv Converter - Complex Structure from the README File" , TestConverter_Structure_FromReadme),
1900
1930
NL_TEST_DEF (" Test Json Tlv Converter - Tlv to Json Error Cases" , TestConverter_TlvToJson_ErrorCases),
1901
1931
NL_TEST_DEF (" Test Json Tlv Converter - Json To Tlv Error Cases" , TestConverter_JsonToTlv_ErrorCases),
1932
+ NL_TEST_DEF (" Test Json Tlv Converter - Structure with MEI Elements" , TestConverter_Struct_MEITags),
1902
1933
NL_TEST_SENTINEL ()
1903
1934
};
1904
1935
0 commit comments