mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
This is a major restructuring of the WPILib repository to simply build procedures and remove the remnants of Maven from everything except the eclipse plugins. Gradle files have been largely simplified or rewritten, taking advantage of splitting up parts of the build into separate build files for ease of reading. The eclipse plugins are now in a separate project, as is ntcore. All dependencies are resolved via Maven dependencies, with the Jenkins-maintained WPILib repo. Project structures have also been simplified: we no longer have separate subprojects inside wpilibc and wpilibj. Where possible, these changes hav been done with git renames, to make sure we still have full history for all repositories. Other unrelated subprojects have also been broken out: OutlineViewer is now a separate project. Change-Id: Ib4e2a6e1a2f66427a14f16612b0e0d69ed661878
77 lines
2.1 KiB
Java
77 lines
2.1 KiB
Java
/*----------------------------------------------------------------------------*/
|
|
/* Copyright (c) FIRST 2008-2014. All Rights Reserved. */
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
/* the project. */
|
|
/*----------------------------------------------------------------------------*/
|
|
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 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;
|
|
|
|
/**
|
|
* @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 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);
|
|
|
|
}
|
|
|
|
/**
|
|
* @throws java.lang.Exception
|
|
*/
|
|
@After
|
|
public void tearDown() throws Exception {
|
|
potSource.reset();
|
|
pot.free();
|
|
analogIO.teardown();
|
|
}
|
|
|
|
@Override
|
|
protected Logger getClassLogger() {
|
|
return logger;
|
|
}
|
|
|
|
@Test
|
|
public void testInitialSettings() {
|
|
assertEquals(0, 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());
|
|
Timer.delay(.02);
|
|
assertEquals(i, pot.get(), DOUBLE_COMPARISON_DELTA);
|
|
}
|
|
}
|
|
|
|
|
|
}
|