mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[wpilibc] Clean up integration tests (#3400)
The command and shuffleboard integration tests were removed because their unit tests counterparts already provide adequate coverage. Java already removed these.
This commit is contained in:
@@ -11,52 +11,55 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
class SuppliedValueWidgetTest : public testing::Test {
|
||||
void SetUp() override {
|
||||
m_ntInstance = nt::NetworkTableInstance::Create();
|
||||
m_instance = std::make_unique<detail::ShuffleboardInstance>(m_ntInstance);
|
||||
m_tab = &(m_instance->GetTab("Tab"));
|
||||
}
|
||||
class NTWrapper {
|
||||
public:
|
||||
NTWrapper() { inst = nt::NetworkTableInstance::Create(); }
|
||||
|
||||
~NTWrapper() { nt::NetworkTableInstance::Destroy(inst); }
|
||||
|
||||
nt::NetworkTableInstance inst;
|
||||
};
|
||||
|
||||
class SuppliedValueWidgetTest : public testing::Test {
|
||||
protected:
|
||||
nt::NetworkTableInstance m_ntInstance;
|
||||
ShuffleboardTab* m_tab;
|
||||
std::unique_ptr<detail::ShuffleboardInstance> m_instance;
|
||||
NTWrapper m_ntInst;
|
||||
frc::detail::ShuffleboardInstance m_shuffleboardInst{m_ntInst.inst};
|
||||
frc::ShuffleboardTab* m_tab = &(m_shuffleboardInst.GetTab("Tab"));
|
||||
};
|
||||
|
||||
TEST_F(SuppliedValueWidgetTest, AddString) {
|
||||
std::string str = "foo";
|
||||
m_tab->AddString("String", [&str]() { return str; });
|
||||
auto entry = m_ntInstance.GetEntry("/Shuffleboard/Tab/String");
|
||||
auto entry = m_ntInst.inst.GetEntry("/Shuffleboard/Tab/String");
|
||||
|
||||
m_instance->Update();
|
||||
m_shuffleboardInst.Update();
|
||||
EXPECT_EQ("foo", entry.GetValue()->GetString());
|
||||
}
|
||||
|
||||
TEST_F(SuppliedValueWidgetTest, AddNumber) {
|
||||
int num = 0;
|
||||
m_tab->AddNumber("Num", [&num]() { return ++num; });
|
||||
auto entry = m_ntInstance.GetEntry("/Shuffleboard/Tab/Num");
|
||||
auto entry = m_ntInst.inst.GetEntry("/Shuffleboard/Tab/Num");
|
||||
|
||||
m_instance->Update();
|
||||
m_shuffleboardInst.Update();
|
||||
EXPECT_FLOAT_EQ(1.0, entry.GetValue()->GetDouble());
|
||||
}
|
||||
|
||||
TEST_F(SuppliedValueWidgetTest, AddBoolean) {
|
||||
bool value = true;
|
||||
m_tab->AddBoolean("Bool", [&value]() { return value; });
|
||||
auto entry = m_ntInstance.GetEntry("/Shuffleboard/Tab/Bool");
|
||||
auto entry = m_ntInst.inst.GetEntry("/Shuffleboard/Tab/Bool");
|
||||
|
||||
m_instance->Update();
|
||||
m_shuffleboardInst.Update();
|
||||
EXPECT_EQ(true, entry.GetValue()->GetBoolean());
|
||||
}
|
||||
|
||||
TEST_F(SuppliedValueWidgetTest, AddStringArray) {
|
||||
std::vector<std::string> strings = {"foo", "bar"};
|
||||
m_tab->AddStringArray("Strings", [&strings]() { return strings; });
|
||||
auto entry = m_ntInstance.GetEntry("/Shuffleboard/Tab/Strings");
|
||||
auto entry = m_ntInst.inst.GetEntry("/Shuffleboard/Tab/Strings");
|
||||
|
||||
m_instance->Update();
|
||||
m_shuffleboardInst.Update();
|
||||
auto actual = entry.GetValue()->GetStringArray();
|
||||
|
||||
EXPECT_EQ(strings.size(), actual.size());
|
||||
@@ -68,9 +71,9 @@ TEST_F(SuppliedValueWidgetTest, AddStringArray) {
|
||||
TEST_F(SuppliedValueWidgetTest, AddNumberArray) {
|
||||
std::vector<double> nums = {0, 1, 2, 3};
|
||||
m_tab->AddNumberArray("Numbers", [&nums]() { return nums; });
|
||||
auto entry = m_ntInstance.GetEntry("/Shuffleboard/Tab/Numbers");
|
||||
auto entry = m_ntInst.inst.GetEntry("/Shuffleboard/Tab/Numbers");
|
||||
|
||||
m_instance->Update();
|
||||
m_shuffleboardInst.Update();
|
||||
auto actual = entry.GetValue()->GetDoubleArray();
|
||||
|
||||
EXPECT_EQ(nums.size(), actual.size());
|
||||
@@ -82,9 +85,9 @@ TEST_F(SuppliedValueWidgetTest, AddNumberArray) {
|
||||
TEST_F(SuppliedValueWidgetTest, AddBooleanArray) {
|
||||
std::vector<int> bools = {true, false};
|
||||
m_tab->AddBooleanArray("Booleans", [&bools]() { return bools; });
|
||||
auto entry = m_ntInstance.GetEntry("/Shuffleboard/Tab/Booleans");
|
||||
auto entry = m_ntInst.inst.GetEntry("/Shuffleboard/Tab/Booleans");
|
||||
|
||||
m_instance->Update();
|
||||
m_shuffleboardInst.Update();
|
||||
auto actual = entry.GetValue()->GetBooleanArray();
|
||||
|
||||
EXPECT_EQ(bools.size(), actual.size());
|
||||
@@ -96,9 +99,9 @@ TEST_F(SuppliedValueWidgetTest, AddBooleanArray) {
|
||||
TEST_F(SuppliedValueWidgetTest, AddRaw) {
|
||||
wpi::StringRef bytes = "\1\2\3";
|
||||
m_tab->AddRaw("Raw", [&bytes]() { return bytes; });
|
||||
auto entry = m_ntInstance.GetEntry("/Shuffleboard/Tab/Raw");
|
||||
auto entry = m_ntInst.inst.GetEntry("/Shuffleboard/Tab/Raw");
|
||||
|
||||
m_instance->Update();
|
||||
m_shuffleboardInst.Update();
|
||||
auto actual = entry.GetValue()->GetRaw();
|
||||
EXPECT_EQ(bytes, actual);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user