*/
TEST_F(AppControlTest, app_control_create_from_uri_handle_p) {
app_control_h app_control;
- char *uri;
- char *query_tag;
int r = app_control_create_from_uri_handle(&app_control, uri_);
EXPECT_EQ(r, APP_CONTROL_ERROR_NONE);
- r = app_control_get_uri(app_control, &uri);
+ std::unique_ptr<std::remove_pointer<app_control_h>::type,
+ decltype(app_control_destroy)*> handle(app_control, app_control_destroy);
+
+ char *v;
+ r = app_control_get_uri(handle.get(), &v);
EXPECT_EQ(r, APP_CONTROL_ERROR_NONE);
- EXPECT_STREQ(uri, EXAM_URI1);
+ auto value = std::unique_ptr<char, decltype(std::free)*>(v, std::free);
+ EXPECT_EQ(std::string(value.get()), EXAM_URI1);
- r = app_control_get_extra_data(app_control, "tag", &query_tag);
+ r = app_control_get_extra_data(handle.get(), "tag", &v);
EXPECT_EQ(r, APP_CONTROL_ERROR_NONE);
- EXPECT_STREQ(query_tag, "networking");
+ value = std::unique_ptr<char, decltype(std::free)*>(v, std::free);
+ EXPECT_EQ(std::string(value.get()), "networking");
}
/*
*/
TEST_F(AppControlTest, app_control_set_uri_by_handle_p) {
app_control_h app_control;
- char *uri;
int r = app_control_create(&app_control);
EXPECT_EQ(r, APP_CONTROL_URI_ERROR_NONE);
- r = app_control_set_uri_by_handle(app_control, uri_);
+ std::unique_ptr<std::remove_pointer<app_control_h>::type,
+ decltype(app_control_destroy)*> handle(app_control, app_control_destroy);
+
+ r = app_control_set_uri_by_handle(handle.get(), uri_);
EXPECT_EQ(r, APP_CONTROL_URI_ERROR_NONE);
- r = app_control_get_uri(app_control, &uri);
+ char *v;
+ r = app_control_get_uri(handle.get(), &v);
EXPECT_EQ(r, APP_CONTROL_ERROR_NONE);
- EXPECT_STREQ(uri, EXAM_URI1);
+ auto value = std::unique_ptr<char, decltype(std::free)*>(v, std::free);
+ EXPECT_EQ(std::string(value.get()), EXAM_URI1);
}