X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fresource-encapsulation%2Fsrc%2Fcommon%2FprimitiveResource%2Funittests%2FResourceAttributesTest.cpp;h=37f4bca124a9d5b96d0889e7c9051a193430146c;hb=7f00f942c39b7bc27c7eeecf213a239c3fe4173c;hp=a2a7876858d544d5edb7467600cb008a5953ffb4;hpb=edcfc3d2329da7b914771c0dcff5f42c9b74fd93;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/resource-encapsulation/src/common/primitiveResource/unittests/ResourceAttributesTest.cpp b/service/resource-encapsulation/src/common/primitiveResource/unittests/ResourceAttributesTest.cpp index a2a7876..37f4bca 100644 --- a/service/resource-encapsulation/src/common/primitiveResource/unittests/ResourceAttributesTest.cpp +++ b/service/resource-encapsulation/src/common/primitiveResource/unittests/ResourceAttributesTest.cpp @@ -343,6 +343,48 @@ TEST(ResourceAttributesConverterTest, OCRepresentationCanBeConvertedIntoResource ASSERT_TRUE(value == resourceAttributes[KEY]); } +TEST(ResourceAttributesConverterTest, OCRepresentationCanBeConvertedIntoResourceAttributesTypeBinary) +{ + static uint8_t binval[] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, + 0x9, 0x0, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}; + + OCByteString value {binval, sizeof(binval)}; + OC::OCRepresentation ocRep; + ocRep[KEY] = value; + + RCSResourceAttributes resourceAttributes{ + ResourceAttributesConverter::fromOCRepresentation(ocRep) }; + + auto rcsValue = resourceAttributes[KEY].get(); + for (size_t i = 0; i < rcsValue.size(); ++i) + { + ASSERT_EQ(binval[i], rcsValue[i]); + } +} + +TEST(ResourceAttributesConverterTest, ResourceAttributesCanBeConvertedIntoOCRepresentationTypeBinary) +{ + static RCSByteString::DataType binval {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, + 0x9, 0x0, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}; + RCSResourceAttributes resourceAttributes; + RCSByteString value {binval}; + resourceAttributes[KEY] = value; + + OC::OCRepresentation ocRep{ + ResourceAttributesConverter::toOCRepresentation(resourceAttributes) }; + + auto rcsValue = resourceAttributes[KEY].get(); + auto ocValue = ocRep[KEY].getValue(); + + ASSERT_EQ(rcsValue.size(), ocValue.len); + ASSERT_EQ(rcsValue.size(), binval.size()); + ASSERT_EQ(binval.size(), ocValue.len); + + for (size_t i = 0; i < rcsValue.size(); ++i) + { + ASSERT_EQ(ocValue.bytes[i], rcsValue[i]); + } +} TEST(ResourceAttributesConverterTest, NestedOCRepresentationCanBeConvertedIntoResourceAttributes) {