[wpilib] Fix PowerDistribution.GetAllCurrents() (#6025)

This commit is contained in:
scarmain
2024-05-24 19:31:19 -04:00
committed by GitHub
parent f42bc45ee8
commit c62396ce4e
6 changed files with 104 additions and 7 deletions

View File

@@ -79,4 +79,26 @@ TEST(PowerDistributionSimTest, SetCurrent) {
EXPECT_TRUE(callback.GetLastValue());
}
}
TEST(PowerDistributionSimTest, GetAllCurrents) {
HAL_Initialize(500, 0);
PowerDistribution pdp{2, frc::PowerDistribution::ModuleType::kRev};
PowerDistributionSim sim(pdp);
// setup
for (int channel = 0; channel < pdp.GetNumChannels(); ++channel) {
const double kTestCurrent = 24 - channel;
sim.SetCurrent(channel, kTestCurrent);
}
// run it
std::vector<double> currents = pdp.GetAllCurrents();
// verify
for (int channel = 0; channel < pdp.GetNumChannels(); ++channel) {
const double kTestCurrent = 24 - channel;
EXPECT_EQ(kTestCurrent, currents[channel]);
}
}
} // namespace frc::sim