Replace Get* methods returning unique_ptr with reference alternative
Existing code created temporarily objects and returned them to the
client. It was not efficient and error-prone as client code could
retrieve pointers to internal objects without keeping unique_ptr alive.
Change-Id: I9e17c8d9f66dfc9f52ce9ffc9a31992b16b00461
Reviewed-on: https://weave-review.googlesource.com/1672
Reviewed-by: Alex Vakulenko <avakulenko@google.com>
diff --git a/src/commands/command_instance_unittest.cc b/src/commands/command_instance_unittest.cc
index 1d32cd9..fb8fe84 100644
--- a/src/commands/command_instance_unittest.cc
+++ b/src/commands/command_instance_unittest.cc
@@ -82,8 +82,8 @@
EXPECT_EQ("robot.speak", instance.GetName());
EXPECT_EQ(Command::Origin::kCloud, instance.GetOrigin());
EXPECT_JSON_EQ("{'phrase': 'iPityDaFool', 'volume': 5}",
- *instance.GetParameters());
- EXPECT_JSON_EQ("{'foo': 239}", *instance.GetResults());
+ instance.GetParameters());
+ EXPECT_JSON_EQ("{'foo': 239}", instance.GetResults());
CommandInstance instance2{"base.reboot",
Command::Origin::kLocal,
@@ -118,7 +118,7 @@
EXPECT_EQ("abcd", instance->GetID());
EXPECT_EQ("robot.jump", instance->GetName());
EXPECT_JSON_EQ("{'height': 53, '_jumpType': '_withKick'}",
- *instance->GetParameters());
+ instance->GetParameters());
}
TEST_F(CommandInstanceTest, FromJson_ParamsOmitted) {
@@ -126,7 +126,7 @@
auto instance = CommandInstance::FromJson(json.get(), Command::Origin::kCloud,
dict_, nullptr, nullptr);
EXPECT_EQ("base.reboot", instance->GetName());
- EXPECT_JSON_EQ("{}", *instance->GetParameters());
+ EXPECT_JSON_EQ("{}", instance->GetParameters());
}
TEST_F(CommandInstanceTest, FromJson_NotObject) {