mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] Fix PowerDistribution.GetAllCurrents() (#6025)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user