mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilibc] Alert: Fix first alert in group not publishing data (#7711)
This commit is contained in:
@@ -87,9 +87,9 @@ class Alert::SendableAlerts : public nt::NTSendable,
|
||||
wpi::SendableRegistry::EnsureInitialized();
|
||||
static wpi::StringMap<Alert::SendableAlerts> groups;
|
||||
|
||||
auto [iter, exists] = groups.try_emplace(group);
|
||||
auto [iter, inserted] = groups.try_emplace(group);
|
||||
SendableAlerts& sendable = iter->second;
|
||||
if (!exists) {
|
||||
if (inserted) {
|
||||
frc::SmartDashboard::PutData(group, &iter->second);
|
||||
}
|
||||
return sendable;
|
||||
|
||||
@@ -33,8 +33,7 @@ class AlertsTest : public ::testing::Test {
|
||||
std::string GetGroupName() {
|
||||
const ::testing::TestInfo* testInfo =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
return fmt::format("{}_{}", testInfo->test_suite_name(),
|
||||
testInfo->test_case_name());
|
||||
return fmt::format("{}_{}", testInfo->test_suite_name(), testInfo->name());
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
@@ -80,7 +79,16 @@ class AlertsTest : public ::testing::Test {
|
||||
#define EXPECT_STATE(type, ...) \
|
||||
EXPECT_EQ(GetActiveAlerts(type), (std::vector<std::string>{__VA_ARGS__}))
|
||||
|
||||
TEST_F(AlertsTest, SetUnset) {
|
||||
TEST_F(AlertsTest, SetUnsetSingle) {
|
||||
auto one = MakeAlert("one", kInfo);
|
||||
EXPECT_FALSE(IsAlertActive("one", kInfo));
|
||||
one.Set(true);
|
||||
EXPECT_TRUE(IsAlertActive("one", kInfo));
|
||||
one.Set(false);
|
||||
EXPECT_FALSE(IsAlertActive("one", kInfo));
|
||||
}
|
||||
|
||||
TEST_F(AlertsTest, SetUnsetMultiple) {
|
||||
auto one = MakeAlert("one", kError);
|
||||
auto two = MakeAlert("two", kInfo);
|
||||
EXPECT_FALSE(IsAlertActive("one", kError));
|
||||
|
||||
@@ -81,7 +81,18 @@ class AlertTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void setUnset() {
|
||||
void setUnsetSingle() {
|
||||
try (var one = makeAlert("one", AlertType.kInfo)) {
|
||||
assertFalse(isAlertActive("one", AlertType.kInfo));
|
||||
one.set(true);
|
||||
assertTrue(isAlertActive("one", AlertType.kInfo));
|
||||
one.set(false);
|
||||
assertFalse(isAlertActive("one", AlertType.kInfo));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void setUnsetMultiple() {
|
||||
try (var one = makeAlert("one", AlertType.kError);
|
||||
var two = makeAlert("two", AlertType.kInfo)) {
|
||||
assertFalse(isAlertActive("one", AlertType.kError));
|
||||
|
||||
Reference in New Issue
Block a user