mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpilib, examples] Cleanup PotentiometerPID, Ultrasonic, UltrasonicPID examples (#4893)
Fix C++ Ultrasonic to return correct units.
This commit is contained in:
@@ -4,12 +4,15 @@
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import edu.wpi.first.wpilibj.simulation.UltrasonicSim;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
class UltrasonicTest {
|
||||
@Test
|
||||
@@ -28,4 +31,23 @@ class UltrasonicTest {
|
||||
assertEquals(0, ultrasonic.getRangeInches());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void automaticModeToggle() {
|
||||
try (@SuppressWarnings("unused")
|
||||
Ultrasonic ultrasonic = new Ultrasonic(0, 1)) {
|
||||
assertDoesNotThrow(
|
||||
() -> {
|
||||
Ultrasonic.setAutomaticMode(true);
|
||||
Ultrasonic.setAutomaticMode(false);
|
||||
Ultrasonic.setAutomaticMode(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ValueSource(booleans = {true, false})
|
||||
@ParameterizedTest
|
||||
void automaticModeWithZeroInstances(boolean enabling) {
|
||||
assertDoesNotThrow(() -> Ultrasonic.setAutomaticMode(enabling));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user