-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05f26db
commit 3249118
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import edu.wpi.first.hal.HAL; | ||
import edu.wpi.first.wpilibj.I2C.Port; | ||
import frc.utils.sim_utils.ColorSensorV3Wrapped; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ColorSensorV3WrapperTests { | ||
private ColorSensorV3Wrapped colorSensor; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
HAL.initialize(500, 0); // init HAL just in case | ||
colorSensor = new ColorSensorV3Wrapped(Port.kMXP); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
colorSensor.close(); | ||
} | ||
|
||
@Test | ||
void testColorSensorV3Wrapping() { | ||
ColorSensorV3Wrapped.setRGBD(2500, 300, 100, 900); | ||
assertEquals(2500, colorSensor.getRed()); | ||
assertEquals(300, colorSensor.getGreen()); | ||
assertEquals(100, colorSensor.getBlue()); | ||
assertEquals(900, colorSensor.getProximity()); | ||
|
||
ColorSensorV3Wrapped.setRGBD(0, 0, 0, 0); | ||
assertEquals(0, colorSensor.getRed()); | ||
assertEquals(0, colorSensor.getGreen()); | ||
assertEquals(0, colorSensor.getBlue()); | ||
assertEquals(0, colorSensor.getProximity()); | ||
} | ||
} |