mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Applies Google Styleguide to Java parts of the library (#23)
This was partially applied to simulation but simulation is a bit of a mess and has a lot of duplicated code.
This commit is contained in:
committed by
Peter Johnson
parent
64ab6e51fe
commit
a834fff7b2
@@ -7,50 +7,45 @@
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
|
||||
import edu.wpi.first.wpilibj.mockhardware.FakePotentiometerSource;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
import edu.wpi.first.wpilibj.test.TestBench;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author jonathanleitschuh
|
||||
* Tests the {@link AnalogPotentiometer}.
|
||||
*
|
||||
* @author jonathanleitschuh
|
||||
*/
|
||||
public class AnalogPotentiometerTest extends AbstractComsSetup {
|
||||
private static final Logger logger = Logger.getLogger(AnalogPotentiometerTest.class.getName());
|
||||
private AnalogCrossConnectFixture analogIO;
|
||||
private FakePotentiometerSource potSource;
|
||||
private AnalogPotentiometer pot;
|
||||
private AnalogCrossConnectFixture m_analogIO;
|
||||
private FakePotentiometerSource m_potSource;
|
||||
private AnalogPotentiometer m_pot;
|
||||
|
||||
private static final double DOUBLE_COMPARISON_DELTA = 2.0;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
analogIO = TestBench.getAnalogCrossConnectFixture();
|
||||
potSource = new FakePotentiometerSource(analogIO.getOutput(), 360);
|
||||
pot = new AnalogPotentiometer(analogIO.getInput(), 360.0, 0);
|
||||
m_analogIO = TestBench.getAnalogCrossConnectFixture();
|
||||
m_potSource = new FakePotentiometerSource(m_analogIO.getOutput(), 360);
|
||||
m_pot = new AnalogPotentiometer(m_analogIO.getInput(), 360.0, 0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
potSource.reset();
|
||||
pot.free();
|
||||
analogIO.teardown();
|
||||
m_potSource.reset();
|
||||
m_pot.free();
|
||||
m_analogIO.teardown();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,16 +55,16 @@ public class AnalogPotentiometerTest extends AbstractComsSetup {
|
||||
|
||||
@Test
|
||||
public void testInitialSettings() {
|
||||
assertEquals(0, pot.get(), DOUBLE_COMPARISON_DELTA);
|
||||
assertEquals(0, m_pot.get(), DOUBLE_COMPARISON_DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRangeValues() {
|
||||
for (double i = 0.0; i < 360.0; i = i + 1.0) {
|
||||
potSource.setAngle(i);
|
||||
potSource.setMaxVoltage(ControllerPower.getVoltage5V());
|
||||
m_potSource.setAngle(i);
|
||||
m_potSource.setMaxVoltage(ControllerPower.getVoltage5V());
|
||||
Timer.delay(.02);
|
||||
assertEquals(i, pot.get(), DOUBLE_COMPARISON_DELTA);
|
||||
assertEquals(i, m_pot.get(), DOUBLE_COMPARISON_DELTA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user