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,11 +7,6 @@
package edu.wpi.first.wpilibj;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import java.util.logging.Logger;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -20,23 +15,28 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import java.util.Collection;
import java.util.logging.Logger;
import edu.wpi.first.wpilibj.fixtures.FakeCounterFixture;
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.assertTrue;
/**
* Tests to see if the Counter is working properly
*$
* @author Jonathan Leitschuh
* Tests to see if the Counter is working properly.
*
* @author Jonathan Leitschuh
*/
@RunWith(Parameterized.class)
public class CounterTest extends AbstractComsSetup {
private static FakeCounterFixture counter = null;
private static final Logger logger = Logger.getLogger(CounterTest.class.getName());
Integer input;
Integer output;
Integer m_input;
Integer m_output;
@Override
protected Logger getClassLogger() {
@@ -44,29 +44,29 @@ public class CounterTest extends AbstractComsSetup {
}
/**
* Constructs a Counter Test with the given inputs
*$
* @param input The input Port
* Constructs a Counter Test with the given inputs.
*
* @param input The input Port
* @param output The output Port
*/
public CounterTest(Integer input, Integer output) {
assert input != null;
assert output != null;
this.input = input;
this.output = output;
m_input = input;
m_output = output;
// System.out.println("Counter Test: Input: " + input + " Output: " +
// output);
if (counter != null)
if (counter != null) {
counter.teardown();
}
counter = new FakeCounterFixture(input, output);
}
/**
* Test data generator. This method is called the the JUnit parameterized test
* runner and returns a Collection of Arrays. For each Array in the
* Collection, each array element corresponds to a parameter in the
* constructor.
* Test data generator. This method is called the the JUnit parameterized test runner and returns
* a Collection of Arrays. For each Array in the Collection, each array element corresponds to a
* parameter in the constructor.
*/
@Parameters
public static Collection<Integer[]> generateData() {
@@ -79,48 +79,39 @@ public class CounterTest extends AbstractComsSetup {
}
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {}
public static void setUpBeforeClass() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@AfterClass
public static void tearDownAfterClass() throws Exception {
counter.teardown();
counter = null;
}
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
counter.setup();
}
/**
* Tests the default state of the counter immediately after reset
* Tests the default state of the counter immediately after reset.
*/
@Test
public void testDefault() {
assertTrue("Counter did not reset to 0", counter.getCounter().get() == 0);
assertEquals("Counter did not reset to 0", 0, counter.getCounter().get());
}
@Test(timeout = 5000)
public void testCount() {
int goal = 100;
final int goal = 100;
counter.getFakeCounterSource().setCount(goal);
counter.getFakeCounterSource().execute();
int count = counter.getCounter().get();
final int count = counter.getCounter().get();
assertTrue("Fake Counter, Input: " + input + ", Output: " + output + ", did not return " + goal
+ " instead got: " + count, count == goal);
assertTrue("Fake Counter, Input: " + m_input + ", Output: " + m_output + ", did not return "
+ goal + " instead got: " + count, count == goal);
}
}