[wpilib] Add AlertSim function to get only active alerts (#8732)

This commit is contained in:
Sam Freund
2026-04-10 00:25:26 -05:00
committed by GitHub
parent 02c6030251
commit ece8001b1e
7 changed files with 105 additions and 2 deletions

View File

@@ -157,4 +157,29 @@ class AlertSimTest {
assertTrue(isAlertActive("AFTER", Level.LOW));
}
}
@Test
void getActive() {
try (var a = makeAlert("A", Level.HIGH);
var b = makeAlert("B", Level.HIGH);
var c = makeAlert("C", Level.HIGH)) {
a.set(true);
b.set(true);
c.set(false);
var active = AlertSim.getActive();
var all = AlertSim.getAll();
assertEquals(2, active.length);
assertEquals(3, all.length);
assertTrue(Arrays.stream(active).anyMatch(x -> "A".equals(x.text)));
assertTrue(Arrays.stream(active).anyMatch(x -> "B".equals(x.text)));
a.set(false);
active = AlertSim.getActive();
all = AlertSim.getAll();
assertEquals(1, active.length);
assertEquals(3, all.length);
assertEquals(active[0].text, "B");
}
}
}