TEST_F(UnitTest, DeviceClonePositiveTest) {
// need to get device
- capmgr_device_h clone;
- ASSERT_EQ(capmgr_device_clone(env->device_, &clone), CAPMGR_ERROR_NONE);
+ capmgr_device_h clone = nullptr;
+ int ret;
+ ret = capmgr_device_clone(env->device_, &clone);
+ if (clone && ret == CAPMGR_ERROR_NONE)
+ capmgr_device_destroy(clone);
+
+ ASSERT_EQ(ret, CAPMGR_ERROR_NONE);
}
TEST_F(UnitTest, DeviceCloneNegativeTest) {
}
TEST_F(UnitTest, DeviceDestroyPositiveTest) {
- capmgr_device_h clone;
- ASSERT_EQ(capmgr_device_clone(env->device_, &clone),
- CAPMGR_ERROR_NONE);
- ASSERT_EQ(capmgr_device_destroy(clone), CAPMGR_ERROR_NONE);
+ capmgr_device_h clone = nullptr;
+ int ret1 = CAPMGR_ERROR_INVALID_PARAMETER;
+ int ret2 = CAPMGR_ERROR_INVALID_PARAMETER;
+ ret1 = capmgr_device_clone(env->device_, &clone);
+ if (clone && ret1 == CAPMGR_ERROR_NONE)
+ ret2 = capmgr_device_destroy(clone);
+
+ ASSERT_EQ(ret1, CAPMGR_ERROR_NONE);
+ ASSERT_EQ(ret2, CAPMGR_ERROR_NONE);
}
TEST_F(UnitTest, DeviceDestroyNegativeTest) {
#define DEVICE_GET_TEST_BLOCK(POSITIVE_TESTNAME, NEGATIVE_TESTNAME, ATTR) \
TEST_F(UnitTest, POSITIVE_TESTNAME) { \
char* ATTR = nullptr; \
- ASSERT_EQ(capmgr_device_get_##ATTR(env->device_, &ATTR), CAPMGR_ERROR_NONE); \
+ int ret = capmgr_device_get_##ATTR(env->device_, &ATTR); \
ASSERT_NE(ATTR, nullptr); \
free(ATTR); \
+ ASSERT_EQ(ret, CAPMGR_ERROR_NONE); \
} \
\
TEST_F(UnitTest, NEGATIVE_TESTNAME) { \
DeviceGetSWVerNegativeTest, sw_ver)
TEST_F(UnitTest, AppControlCreatePositiveTest) {
- capmgr_app_control_h app_control;
- ASSERT_EQ(capmgr_app_control_create(&app_control), CAPMGR_ERROR_NONE);
- capmgr_app_control_destroy(app_control);
+ capmgr_app_control_h app_control = nullptr;
+ int ret = capmgr_app_control_create(&app_control);
+ if (app_control && ret == CAPMGR_ERROR_NONE)
+ capmgr_app_control_destroy(app_control);
+ ASSERT_EQ(ret, CAPMGR_ERROR_NONE);
}
TEST_F(UnitTest, AppControlCreateNegativeTest) {
}
TEST_F(UnitTest, AppControlDestroyPositiveTest) {
- capmgr_app_control_h app_control;
- ASSERT_EQ(capmgr_app_control_create(&app_control), CAPMGR_ERROR_NONE);
+ capmgr_app_control_h app_control = nullptr;
+ int ret = capmgr_app_control_create(&app_control);
ASSERT_EQ(capmgr_app_control_destroy(app_control), CAPMGR_ERROR_NONE);
+ ASSERT_EQ(ret, CAPMGR_ERROR_NONE);
}
TEST_F(UnitTest, AppControlDestroyNegativeTest) {
#define APP_CONTROL_GET_TEST_BLOCK(POSITIVE_TESTNAME, NEGATIVE_TESTNAME, ATTR) \
TEST_F(UnitTest, POSITIVE_TESTNAME) { \
char* ATTR = nullptr; \
- ASSERT_EQ(capmgr_app_control_get_##ATTR(env->app_control_, &ATTR), \
- CAPMGR_ERROR_NONE); \
+ int ret = capmgr_app_control_get_##ATTR(env->app_control_, &ATTR); \
ASSERT_NE(ATTR, nullptr); \
free(ATTR); \
+ ASSERT_EQ(ret, CAPMGR_ERROR_NONE); \
} \
\
TEST_F(UnitTest, NEGATIVE_TESTNAME) { \
TEST_F(UnitTest, AppControlGetExtraDataPositiveTest) {
char* value = nullptr;
- ASSERT_EQ(capmgr_app_control_get_extra_data(env->app_control_,
- kExtraDataKeyStr, &value), CAPMGR_ERROR_NONE);
+ int ret = capmgr_app_control_get_extra_data(env->app_control_,
+ kExtraDataKeyStr, &value);
ASSERT_NE(value, nullptr);
free(value);
+ ASSERT_EQ(ret, CAPMGR_ERROR_NONE);
}
TEST_F(UnitTest, AppControlGetExtraDataNegativeTest) {
capmgr_app_control_remove_extra_data(env->app_control_, "key2"),
CAPMGR_ERROR_NONE);
// should return such as CAPMGR_ERROR_NO_SUCH_KEY?
- char* value;
- ASSERT_EQ(capmgr_app_control_get_extra_data(env->app_control_,
- "key2", &value), CAPMGR_ERROR_INVALID_PARAMETER);
+ char* value = nullptr;
+ int ret = capmgr_app_control_get_extra_data(env->app_control_, "key2",
+ &value);
+ free(value);
+ ASSERT_EQ(ret, CAPMGR_ERROR_INVALID_PARAMETER);
}
TEST_F(UnitTest, AppControlRemoveExtraDataNegativeTest) {
POSITIVE_TESTNAME, NEGATIVE_TESTNAME, ATTR) \
TEST_F(UnitTest, POSITIVE_TESTNAME) { \
char* ATTR = nullptr; \
- ASSERT_EQ(capmgr_app_info_get_##ATTR(env->app_, &ATTR), \
- CAPMGR_ERROR_NONE); \
+ int ret = capmgr_app_info_get_##ATTR(env->app_, &ATTR); \
ASSERT_NE(ATTR, nullptr); \
free(ATTR); \
+ ASSERT_EQ(ret, CAPMGR_ERROR_NONE); \
} \
\
TEST_F(UnitTest, NEGATIVE_TESTNAME) { \