Skip to content

Commit

Permalink
add tests for the color sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
MEFThunders7035 committed Feb 26, 2024
1 parent 05f26db commit 3249118
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/test/java/ColorSensorV3WrapperTests.java
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());
}
}

0 comments on commit 3249118

Please sign in to comment.