mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Add AlertSim function to get only active alerts (#8732)
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user