2021-08-12 02:04:14 -04:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
2025-11-07 19:55:43 -05:00
|
|
|
package org.wpilib.simulation;
|
2021-08-12 02:04:14 -04:00
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
2023-07-19 20:24:09 -04:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
2021-08-12 02:04:14 -04:00
|
|
|
|
2025-11-07 19:55:43 -05:00
|
|
|
import org.wpilib.hardware.hal.HAL;
|
|
|
|
|
import org.wpilib.hardware.rotation.DutyCycleEncoder;
|
2021-08-12 02:04:14 -04:00
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
class DutyCycleEncoderSimTest {
|
|
|
|
|
@Test
|
|
|
|
|
void setTest() {
|
2024-05-24 11:53:56 -07:00
|
|
|
try (DutyCycleEncoder encoder = new DutyCycleEncoder(0, 5.67, 0)) {
|
2021-08-12 02:04:14 -04:00
|
|
|
DutyCycleEncoderSim sim = new DutyCycleEncoderSim(encoder);
|
|
|
|
|
|
|
|
|
|
sim.set(5.67);
|
|
|
|
|
assertEquals(5.67, encoder.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-19 20:24:09 -04:00
|
|
|
@Test
|
|
|
|
|
void setIsConnectedTest() {
|
|
|
|
|
HAL.initialize(500, 0);
|
|
|
|
|
|
|
|
|
|
try (DutyCycleEncoder encoder = new DutyCycleEncoder(0)) {
|
|
|
|
|
DutyCycleEncoderSim sim = new DutyCycleEncoderSim(encoder);
|
|
|
|
|
|
|
|
|
|
sim.setConnected(true);
|
|
|
|
|
assertTrue(encoder.isConnected());
|
|
|
|
|
sim.setConnected(false);
|
|
|
|
|
assertFalse(encoder.isConnected());
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-12 02:04:14 -04:00
|
|
|
}
|