OICFree(payload_cbor);
OCPayloadDestroy(payload_out);
}
+
+TEST(CborEmptyArrayTest, EmptyArrayArraySetGetTest)
+{
+ OCRepPayload* payload_in = OCRepPayloadCreate();
+ ASSERT_TRUE(payload_in != NULL);
+
+ OCRepPayloadSetUri(payload_in, "/a/quake_sensor");
+ OCRepPayloadSetPropInt(payload_in, "scale", 4);
+
+ size_t dimensions_in[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
+
+ EXPECT_EQ(true, OCRepPayloadSetIntArray(payload_in, "quakedata",
+ NULL, dimensions_in));
+
+ int64_t* quakedata_out = NULL;
+ size_t dimensions_out[MAX_REP_ARRAY_DEPTH] = {0};
+
+ ///TODO: Change Assert to true after fixing OCRepPayloadGetIntArray behaviour
+ ASSERT_EQ(false, OCRepPayloadGetIntArray(payload_in, "quakedata",
+ &quakedata_out, dimensions_out));
+
+ ASSERT_TRUE(quakedata_out == NULL);
+
+ for(size_t i = 0; i < MAX_REP_ARRAY_DEPTH; i++)
+ {
+ EXPECT_EQ(0, dimensions_out[i]);
+ }
+
+ // Cleanup
+ OCRepPayloadDestroy(payload_in);
+}
+
(ehRequest->query && !strcmp(ehRequest->query, "")) ||
(ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_DEFAULT)))
{
- OIC_LOG(DEBUG, ES_RH_TAG, "constructResponse EasySetup res");
+ OIC_LOG(DEBUG, ES_RH_TAG, "constructResponse EasySetup res (Default interface)");
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_EASYSETUP);
OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_DEFAULT);
OCRepPayloadAddInterface(payload, OC_RSRVD_INTERFACE_LL);
{
connectRequest[i] = g_ESEasySetupResource.connectRequest[i];
}
- OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_CONNECT, (int64_t *)connectRequest, dimensions);
+
+ bool b = OCRepPayloadSetIntArrayAsOwner(payload, OC_RSRVD_ES_CONNECT, (int64_t *)connectRequest, dimensions);
+ if (!b)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to set array value for Connect property");
+ OICFree(connectRequest);
+ }
}
else
{
OIC_LOG(DEBUG, ES_RH_TAG, "g_ESEasySetupResource.numRequest is 0");
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
- OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
+ OCRepPayloadSetIntArrayAsOwner(payload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
}
if (gWriteUserdataCb)
ehRequest->query && CompareResourceInterface(ehRequest->query, OC_RSRVD_INTERFACE_BATCH))
{
- OIC_LOG(DEBUG, ES_RH_TAG, "constructResponse EasySetup res");
+ OIC_LOG(DEBUG, ES_RH_TAG, "constructResponse EasySetup res (Batch Interface)");
OCRepPayloadSetUri(payload, OC_RSRVD_ES_URI_EASYSETUP);
OCRepPayload* repPayload = NULL;
{
connectRequest[i] = g_ESEasySetupResource.connectRequest[i];
}
- OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_CONNECT, (int64_t *)connectRequest, dimensions);
+
+ bool b = OCRepPayloadSetIntArrayAsOwner(repPayload, OC_RSRVD_ES_CONNECT, (int64_t *)connectRequest, dimensions);
+ if (!b)
+ {
+ OIC_LOG(ERROR, ES_RH_TAG, "Failed to set array value for Connect property");
+ OICFree(connectRequest);
+ }
}
else
{
OIC_LOG(DEBUG, ES_RH_TAG, "g_ESEasySetupResource.numRequest is 0");
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
- OCRepPayloadSetIntArray(payload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
+ OCRepPayloadSetIntArrayAsOwner(repPayload, OC_RSRVD_ES_CONNECT, NULL, dimensions);
}
if (gWriteUserdataCb)