[commands] Allow BooleanSupplier for Trigger operations (#4103)

This commit is contained in:
ohowe
2022-04-24 08:20:46 -06:00
committed by GitHub
parent 9d20ab3024
commit b3aee28388
3 changed files with 22 additions and 10 deletions

View File

@@ -16,6 +16,7 @@ import edu.wpi.first.wpilibj.simulation.SimHooks;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj2.command.CommandTestBase;
import java.util.function.BooleanSupplier;
import org.junit.jupiter.api.Test;
class ButtonTest extends CommandTestBase {
@@ -174,6 +175,17 @@ class ButtonTest extends CommandTestBase {
assertTrue(button1.and(button2.negate()).get());
}
@Test
void buttonCompositionSupplierTest() {
InternalButton button1 = new InternalButton();
BooleanSupplier booleanSupplier = () -> false;
button1.setPressed(true);
assertFalse(button1.and(booleanSupplier).get());
assertTrue(button1.or(booleanSupplier).get());
}
@Test
void debounceTest() {
CommandScheduler scheduler = CommandScheduler.getInstance();