mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[wpilibc] Change DriverStationSim to use a C++ enum for alliance station (#8991)
This commit is contained in:
@@ -43,7 +43,8 @@ class DigitalCommunicationTest : public testing::TestWithParam<T> {
|
||||
}
|
||||
};
|
||||
|
||||
class AllianceTest : public DigitalCommunicationTest<HAL_AllianceStationID> {};
|
||||
class AllianceTest
|
||||
: public DigitalCommunicationTest<wpi::hal::AllianceStationID> {};
|
||||
|
||||
TEST_P(AllianceTest, Alliance) {
|
||||
auto alliance = GetParam();
|
||||
@@ -57,15 +58,15 @@ TEST_P(AllianceTest, Alliance) {
|
||||
|
||||
bool isRed = false;
|
||||
switch (alliance) {
|
||||
case HAL_ALLIANCE_STATION_BLUE_1:
|
||||
case HAL_ALLIANCE_STATION_BLUE_2:
|
||||
case HAL_ALLIANCE_STATION_BLUE_3:
|
||||
case HAL_ALLIANCE_STATION_UNKNOWN:
|
||||
case wpi::hal::AllianceStationID::BLUE_1:
|
||||
case wpi::hal::AllianceStationID::BLUE_2:
|
||||
case wpi::hal::AllianceStationID::BLUE_3:
|
||||
case wpi::hal::AllianceStationID::UNKNOWN:
|
||||
isRed = false;
|
||||
break;
|
||||
case HAL_ALLIANCE_STATION_RED_1:
|
||||
case HAL_ALLIANCE_STATION_RED_2:
|
||||
case HAL_ALLIANCE_STATION_RED_3:
|
||||
case wpi::hal::AllianceStationID::RED_1:
|
||||
case wpi::hal::AllianceStationID::RED_2:
|
||||
case wpi::hal::AllianceStationID::RED_3:
|
||||
isRed = true;
|
||||
break;
|
||||
}
|
||||
@@ -74,26 +75,27 @@ TEST_P(AllianceTest, Alliance) {
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
DigitalCommunicationTests, AllianceTest,
|
||||
testing::Values<HAL_AllianceStationID>(
|
||||
HAL_ALLIANCE_STATION_RED_1, HAL_ALLIANCE_STATION_RED_2,
|
||||
HAL_ALLIANCE_STATION_RED_3, HAL_ALLIANCE_STATION_BLUE_1,
|
||||
HAL_ALLIANCE_STATION_BLUE_2, HAL_ALLIANCE_STATION_BLUE_3,
|
||||
HAL_ALLIANCE_STATION_UNKNOWN),
|
||||
testing::Values<wpi::hal::AllianceStationID>(
|
||||
wpi::hal::AllianceStationID::RED_1, wpi::hal::AllianceStationID::RED_2,
|
||||
wpi::hal::AllianceStationID::RED_3, wpi::hal::AllianceStationID::BLUE_1,
|
||||
wpi::hal::AllianceStationID::BLUE_2,
|
||||
wpi::hal::AllianceStationID::BLUE_3,
|
||||
wpi::hal::AllianceStationID::UNKNOWN),
|
||||
[](const testing::TestParamInfo<AllianceTest::ParamType>& info) {
|
||||
switch (info.param) {
|
||||
case HAL_ALLIANCE_STATION_BLUE_1:
|
||||
case wpi::hal::AllianceStationID::BLUE_1:
|
||||
return std::string{"Blue1"};
|
||||
case HAL_ALLIANCE_STATION_BLUE_2:
|
||||
case wpi::hal::AllianceStationID::BLUE_2:
|
||||
return std::string{"Blue2"};
|
||||
case HAL_ALLIANCE_STATION_BLUE_3:
|
||||
case wpi::hal::AllianceStationID::BLUE_3:
|
||||
return std::string{"Blue3"};
|
||||
case HAL_ALLIANCE_STATION_RED_1:
|
||||
case wpi::hal::AllianceStationID::RED_1:
|
||||
return std::string{"Red1"};
|
||||
case HAL_ALLIANCE_STATION_RED_2:
|
||||
case wpi::hal::AllianceStationID::RED_2:
|
||||
return std::string{"Red2"};
|
||||
case HAL_ALLIANCE_STATION_RED_3:
|
||||
case wpi::hal::AllianceStationID::RED_3:
|
||||
return std::string{"Red3"};
|
||||
case HAL_ALLIANCE_STATION_UNKNOWN:
|
||||
case wpi::hal::AllianceStationID::UNKNOWN:
|
||||
return std::string{"Unknown"};
|
||||
}
|
||||
return std::string{"Error"};
|
||||
|
||||
@@ -52,7 +52,8 @@ class I2CCommunicationTest : public testing::TestWithParam<T> {
|
||||
}
|
||||
};
|
||||
|
||||
class AllianceTest : public I2CCommunicationTest<HAL_AllianceStationID> {};
|
||||
class AllianceTest : public I2CCommunicationTest<wpi::hal::AllianceStationID> {
|
||||
};
|
||||
|
||||
TEST_P(AllianceTest, Alliance) {
|
||||
auto alliance = GetParam();
|
||||
@@ -65,17 +66,17 @@ TEST_P(AllianceTest, Alliance) {
|
||||
|
||||
char expected = 'U';
|
||||
switch (alliance) {
|
||||
case HAL_ALLIANCE_STATION_BLUE_1:
|
||||
case HAL_ALLIANCE_STATION_BLUE_2:
|
||||
case HAL_ALLIANCE_STATION_BLUE_3:
|
||||
case wpi::hal::AllianceStationID::BLUE_1:
|
||||
case wpi::hal::AllianceStationID::BLUE_2:
|
||||
case wpi::hal::AllianceStationID::BLUE_3:
|
||||
expected = 'B';
|
||||
break;
|
||||
case HAL_ALLIANCE_STATION_RED_1:
|
||||
case HAL_ALLIANCE_STATION_RED_2:
|
||||
case HAL_ALLIANCE_STATION_RED_3:
|
||||
case wpi::hal::AllianceStationID::RED_1:
|
||||
case wpi::hal::AllianceStationID::RED_2:
|
||||
case wpi::hal::AllianceStationID::RED_3:
|
||||
expected = 'R';
|
||||
break;
|
||||
case HAL_ALLIANCE_STATION_UNKNOWN:
|
||||
case wpi::hal::AllianceStationID::UNKNOWN:
|
||||
expected = 'U';
|
||||
break;
|
||||
}
|
||||
@@ -84,26 +85,27 @@ TEST_P(AllianceTest, Alliance) {
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
I2CCommunicationTests, AllianceTest,
|
||||
testing::Values<HAL_AllianceStationID>(
|
||||
HAL_ALLIANCE_STATION_RED_1, HAL_ALLIANCE_STATION_RED_2,
|
||||
HAL_ALLIANCE_STATION_RED_3, HAL_ALLIANCE_STATION_BLUE_1,
|
||||
HAL_ALLIANCE_STATION_BLUE_2, HAL_ALLIANCE_STATION_BLUE_3,
|
||||
HAL_ALLIANCE_STATION_UNKNOWN),
|
||||
testing::Values<wpi::hal::AllianceStationID>(
|
||||
wpi::hal::AllianceStationID::RED_1, wpi::hal::AllianceStationID::RED_2,
|
||||
wpi::hal::AllianceStationID::RED_3, wpi::hal::AllianceStationID::BLUE_1,
|
||||
wpi::hal::AllianceStationID::BLUE_2,
|
||||
wpi::hal::AllianceStationID::BLUE_3,
|
||||
wpi::hal::AllianceStationID::UNKNOWN),
|
||||
[](const testing::TestParamInfo<AllianceTest::ParamType>& info) {
|
||||
switch (info.param) {
|
||||
case HAL_ALLIANCE_STATION_BLUE_1:
|
||||
case wpi::hal::AllianceStationID::BLUE_1:
|
||||
return std::string{"Blue1"};
|
||||
case HAL_ALLIANCE_STATION_BLUE_2:
|
||||
case wpi::hal::AllianceStationID::BLUE_2:
|
||||
return std::string{"Blue2"};
|
||||
case HAL_ALLIANCE_STATION_BLUE_3:
|
||||
case wpi::hal::AllianceStationID::BLUE_3:
|
||||
return std::string{"Blue3"};
|
||||
case HAL_ALLIANCE_STATION_RED_1:
|
||||
case wpi::hal::AllianceStationID::RED_1:
|
||||
return std::string{"Red1"};
|
||||
case HAL_ALLIANCE_STATION_RED_2:
|
||||
case wpi::hal::AllianceStationID::RED_2:
|
||||
return std::string{"Red2"};
|
||||
case HAL_ALLIANCE_STATION_RED_3:
|
||||
case wpi::hal::AllianceStationID::RED_3:
|
||||
return std::string{"Red3"};
|
||||
case HAL_ALLIANCE_STATION_UNKNOWN:
|
||||
case wpi::hal::AllianceStationID::UNKNOWN:
|
||||
return std::string{"Unknown"};
|
||||
}
|
||||
return std::string{"Error"};
|
||||
|
||||
Reference in New Issue
Block a user