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:
Jonathan Leitschuh
2016-05-20 12:07:40 -04:00
committed by Peter Johnson
parent 64ab6e51fe
commit a834fff7b2
266 changed files with 15574 additions and 14718 deletions

View File

@@ -7,18 +7,12 @@
package edu.wpi.first.wpilibj;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import edu.wpi.first.wpilibj.Relay.Direction;
import edu.wpi.first.wpilibj.Relay.InvalidValueException;
import edu.wpi.first.wpilibj.Relay.Value;
@@ -27,87 +21,90 @@ import edu.wpi.first.wpilibj.networktables.NetworkTable;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* @author jonathanleitschuh
* Tests the {@link RelayCrossConnectFixture}.
*
* @author jonathanleitschuh
*/
public class RelayCrossConnectTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(RelayCrossConnectTest.class.getName());
private static final NetworkTable table = NetworkTable.getTable("_RELAY_CROSS_CONNECT_TEST_");
private RelayCrossConnectFixture relayFixture;
private RelayCrossConnectFixture m_relayFixture;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
relayFixture = TestBench.getRelayCrossConnectFixture();
relayFixture.setup();
relayFixture.getRelay().initTable(table);
m_relayFixture = TestBench.getRelayCrossConnectFixture();
m_relayFixture.setup();
m_relayFixture.getRelay().initTable(table);
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
relayFixture.reset();
relayFixture.teardown();
m_relayFixture.reset();
m_relayFixture.teardown();
}
@Test
public void testBothHigh() {
relayFixture.getRelay().setDirection(Direction.kBoth);
relayFixture.getRelay().set(Value.kOn);
relayFixture.getRelay().updateTable();
assertTrue("Input one was not high when relay set both high", relayFixture.getInputOne().get());
assertTrue("Input two was not high when relay set both high", relayFixture.getInputTwo().get());
m_relayFixture.getRelay().setDirection(Direction.kBoth);
m_relayFixture.getRelay().set(Value.kOn);
m_relayFixture.getRelay().updateTable();
assertTrue("Input one was not high when relay set both high", m_relayFixture.getInputOne()
.get());
assertTrue("Input two was not high when relay set both high", m_relayFixture.getInputTwo()
.get());
assertEquals("On", table.getString("Value"));
}
@Test
public void testFirstHigh() {
relayFixture.getRelay().setDirection(Direction.kBoth);
relayFixture.getRelay().set(Value.kForward);
relayFixture.getRelay().updateTable();
assertFalse("Input one was not low when relay set Value.kForward", relayFixture.getInputOne()
m_relayFixture.getRelay().setDirection(Direction.kBoth);
m_relayFixture.getRelay().set(Value.kForward);
m_relayFixture.getRelay().updateTable();
assertFalse("Input one was not low when relay set Value.kForward", m_relayFixture.getInputOne()
.get());
assertTrue("Input two was not high when relay set Value.kForward", relayFixture.getInputTwo()
assertTrue("Input two was not high when relay set Value.kForward", m_relayFixture
.getInputTwo()
.get());
assertEquals("Forward", table.getString("Value"));
}
@Test
public void testSecondHigh() {
relayFixture.getRelay().setDirection(Direction.kBoth);
relayFixture.getRelay().set(Value.kReverse);
relayFixture.getRelay().updateTable();
assertTrue("Input one was not high when relay set Value.kReverse", relayFixture.getInputOne()
m_relayFixture.getRelay().setDirection(Direction.kBoth);
m_relayFixture.getRelay().set(Value.kReverse);
m_relayFixture.getRelay().updateTable();
assertTrue("Input one was not high when relay set Value.kReverse", m_relayFixture.getInputOne()
.get());
assertFalse("Input two was not low when relay set Value.kReverse", relayFixture.getInputTwo()
assertFalse("Input two was not low when relay set Value.kReverse", m_relayFixture
.getInputTwo()
.get());
assertEquals("Reverse", table.getString("Value"));
}
@Test(expected = InvalidValueException.class)
public void testSetValueForwardWithDirectionReverseThrowingException() {
relayFixture.getRelay().setDirection(Direction.kForward);
relayFixture.getRelay().set(Value.kReverse);
m_relayFixture.getRelay().setDirection(Direction.kForward);
m_relayFixture.getRelay().set(Value.kReverse);
}
@Test(expected = InvalidValueException.class)
public void testSetValueReverseWithDirectionForwardThrowingException() {
relayFixture.getRelay().setDirection(Direction.kReverse);
relayFixture.getRelay().set(Value.kForward);
m_relayFixture.getRelay().setDirection(Direction.kReverse);
m_relayFixture.getRelay().set(Value.kForward);
}
@Test
public void testInitialSettings() {
assertEquals(Value.kOff, relayFixture.getRelay().get());
assertEquals(Value.kOff, m_relayFixture.getRelay().get());
// Initially both outputs should be off
assertFalse(relayFixture.getInputOne().get());
assertFalse(relayFixture.getInputTwo().get());
assertFalse(m_relayFixture.getInputOne().get());
assertFalse(m_relayFixture.getInputTwo().get());
assertEquals("Off", table.getString("Value"));
}