[wpilibc] Shuffleboard SimpleWidget: Return pointer instead of reference (#4703)

Based on beta test feedback, returning a pointer is more intuitive, as
typically the return value is late bound to an instance variable.
This commit is contained in:
Peter Johnson
2022-11-24 09:05:37 -08:00
committed by GitHub
parent e15200068d
commit 34ec89c041
5 changed files with 35 additions and 33 deletions

View File

@@ -25,14 +25,14 @@ TEST(ShuffleboardInstanceTest, PathFluent) {
NTWrapper ntInst;
frc::detail::ShuffleboardInstance shuffleboardInst{ntInst.inst};
auto& entry = shuffleboardInst.GetTab("Tab Title")
.GetLayout("List", "List Layout")
.Add("Data", "string")
.WithWidget("Text View")
.GetEntry();
auto entry = shuffleboardInst.GetTab("Tab Title")
.GetLayout("List", "List Layout")
.Add("Data", "string")
.WithWidget("Text View")
.GetEntry();
EXPECT_EQ("string", entry.GetString("")) << "Wrong entry value";
EXPECT_EQ("/Shuffleboard/Tab Title/List/Data", entry.GetTopic().GetName())
EXPECT_EQ("string", entry->GetString("")) << "Wrong entry value";
EXPECT_EQ("/Shuffleboard/Tab Title/List/Data", entry->GetTopic().GetName())
<< "Entry path generated incorrectly";
}
@@ -40,17 +40,17 @@ TEST(ShuffleboardInstanceTest, NestedLayoutsFluent) {
NTWrapper ntInst;
frc::detail::ShuffleboardInstance shuffleboardInst{ntInst.inst};
auto& entry = shuffleboardInst.GetTab("Tab")
.GetLayout("First", "List")
.GetLayout("Second", "List")
.GetLayout("Third", "List")
.GetLayout("Fourth", "List")
.Add("Value", "string")
.GetEntry();
auto entry = shuffleboardInst.GetTab("Tab")
.GetLayout("First", "List")
.GetLayout("Second", "List")
.GetLayout("Third", "List")
.GetLayout("Fourth", "List")
.Add("Value", "string")
.GetEntry();
EXPECT_EQ("string", entry.GetString("")) << "Wrong entry value";
EXPECT_EQ("string", entry->GetString("")) << "Wrong entry value";
EXPECT_EQ("/Shuffleboard/Tab/First/Second/Third/Fourth/Value",
entry.GetTopic().GetName())
entry->GetTopic().GetName())
<< "Entry path generated incorrectly";
}
@@ -64,11 +64,11 @@ TEST(ShuffleboardInstanceTest, NestedLayoutsOop) {
frc::ShuffleboardLayout& third = second.GetLayout("Third", "List");
frc::ShuffleboardLayout& fourth = third.GetLayout("Fourth", "List");
frc::SimpleWidget& widget = fourth.Add("Value", "string");
auto& entry = widget.GetEntry();
auto entry = widget.GetEntry();
EXPECT_EQ("string", entry.GetString("")) << "Wrong entry value";
EXPECT_EQ("string", entry->GetString("")) << "Wrong entry value";
EXPECT_EQ("/Shuffleboard/Tab/First/Second/Third/Fourth/Value",
entry.GetTopic().GetName())
entry->GetTopic().GetName())
<< "Entry path generated incorrectly";
}