<commit_before>package org._2585robophiles.frc2015.tests;

import org._2585robophiles.frc2015.RobotMap;
import org._2585robophiles.frc2015.input.InputMethod;
import org._2585robophiles.frc2015.systems.WheelSystem;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import edu.wpi.first.wpilibj.Joystick;

/**
 * Unit test for the WheelSystem class
 */
public class WheelSystemTest {

	private TestWheelSystem wheelSystem;
	private double currentForwardMovement, currentSidewaysMovement,
			currentRotation;

	/**
	 * Set up the unit test
	 */
	@Before
	public void setUp() {
		wheelSystem = new TestWheelSystem();
	}

	/**
	 * Test the run() method of the WheelSystem class
	 */
	@Test
	public void testRun() {
		// first make sure we aren't moving without input
		Assert.assertEquals(0, currentSidewaysMovement, 0);
		Assert.assertEquals(0, currentForwardMovement, 0);
		Assert.assertEquals(0, currentRotation, 0);

		// test forward ramping
		wheelSystem.setInput(new InputMethod() {

			@Override
			public double sidewaysMovement() {
				return 0;
			}

			@Override
			public double rotation() {
				return 0;
			}

			@Override
			public double forwardMovement() {
				return 1;
			}

			@Override
			public Joystick[] joysticks() {
				return null;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(0, currentRotation, 0);
		Assert.assertEquals(0, currentSidewaysMovement, 0);
		Assert.assertEquals(RobotMap.FORWARD_RAMPING, currentForwardMovement, 0);
		wheelSystem.setInput(new InputMethod() {

			@Override
			public double sidewaysMovement() {
				return 0;
			}

			@Override
			public double rotation() {
				return 0;
			}

			@Override
			public double forwardMovement() {
				return -1;
			}

			@Override
			public Joystick[] joysticks() {
				return null;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(0, currentRotation, 0);
		Assert.assertEquals(0, currentSidewaysMovement, 0);
		Assert.assertEquals(RobotMap.FORWARD_RAMPING
				+ (-1 - RobotMap.FORWARD_RAMPING) * RobotMap.FORWARD_RAMPING,
				currentForwardMovement, 0);
		
		// test sideways ramping
				wheelSystem.setInput(new InputMethod() {

					@Override
					public double sidewaysMovement() {
						return 1;
					}

					@Override
					public double rotation() {
						return 0;
					}

					@Override
					public double forwardMovement() {
						return 0;
					}

					@Override
					public Joystick[] joysticks() {
						return null;
					}
				});
				wheelSystem.run();
				Assert.assertEquals(0, currentRotation, 0);
				Assert.assertEquals(RobotMap.SIDEWAYS_RAMPING, currentSidewaysMovement, 0);
				wheelSystem.setInput(new InputMethod() {

					@Override
					public double sidewaysMovement() {
						return -1;
					}

					@Override
					public double rotation() {
						return 0;
					}

					@Override
					public double forwardMovement() {
						return 0;
					}

					@Override
					public Joystick[] joysticks() {
						return null;
					}
				});
				wheelSystem.run();
				Assert.assertEquals(0, currentRotation, 0);
				Assert.assertEquals(RobotMap.SIDEWAYS_RAMPING
						+ (-1 - RobotMap.SIDEWAYS_RAMPING) * RobotMap.SIDEWAYS_RAMPING,
						currentSidewaysMovement, 0);

		// test squared rotation
		wheelSystem.setInput(new InputMethod() {

			@Override
			public double sidewaysMovement() {
				return 0;
			}

			@Override
			public double rotation() {
				return -1;
			}

			@Override
			public Joystick[] joysticks() {
				return null;
			}

			@Override
			public double forwardMovement() {
				return 0;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(-1, currentRotation, 0);
		wheelSystem.setInput(new InputMethod() {

			@Override
			public double sidewaysMovement() {
				return 0;
			}

			@Override
			public double rotation() {
				return 0.5;
			}

			@Override
			public Joystick[] joysticks() {
				return null;
			}

			@Override
			public double forwardMovement() {
				return 0;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(0.25, currentRotation, 0);
	}

	/**
	 * WheelSystem subclass for the purpose of unit testing
	 */
	private class TestWheelSystem extends WheelSystem {

		/*
		 * (non-Javadoc)
		 * 
		 * @see org._2585robophiles.frc2015.systems.WheelSystem#drive(double,
		 * double, double)
		 */
		@Override
		public void drive(double normalMovement, double sidewaysMovement,
				double rotation) {
			currentForwardMovement = normalMovement;
			currentSidewaysMovement = sidewaysMovement;
			currentRotation = rotation;
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see org._2585robophiles.frc2015.systems.WheelSystem#setInput(org.
		 * _2585robophiles.frc2015.input.InputMethod)
		 */
		@Override
		protected synchronized void setInput(InputMethod input) {
			super.setInput(input);
		}

	}
}
<commit_msg>test deadzone<commit_after>package org._2585robophiles.frc2015.tests;

import org._2585robophiles.frc2015.RobotMap;
import org._2585robophiles.frc2015.input.InputMethod;
import org._2585robophiles.frc2015.systems.WheelSystem;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import edu.wpi.first.wpilibj.Joystick;

/**
 * Unit test for the WheelSystem class
 */
public class WheelSystemTest {

	private TestWheelSystem wheelSystem;
	private double currentForwardMovement, currentSidewaysMovement,
			currentRotation;

	/**
	 * Set up the unit test
	 */
	@Before
	public void setUp() {
		wheelSystem = new TestWheelSystem();
	}

	/**
	 * Test the run() method of the WheelSystem class
	 */
	@Test
	public void testRun() {
		
		// first make sure we aren't moving without input
		Assert.assertEquals(0, currentSidewaysMovement, 0);
		Assert.assertEquals(0, currentForwardMovement, 0);
		Assert.assertEquals(0, currentRotation, 0);

		// test forward ramping
		wheelSystem.setInput(new InputMethod() {

			@Override
			public double sidewaysMovement() {
				return 0;
			}

			@Override
			public double rotation() {
				return 0;
			}

			@Override
			public double forwardMovement() {
				return 1;
			}

			@Override
			public Joystick[] joysticks() {
				return null;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(0, currentRotation, 0);
		Assert.assertEquals(0, currentSidewaysMovement, 0);
		Assert.assertEquals(RobotMap.FORWARD_RAMPING, currentForwardMovement, 0);
		wheelSystem.setInput(new InputMethod() {

			@Override
			public double sidewaysMovement() {
				return 0;
			}

			@Override
			public double rotation() {
				return 0;
			}

			@Override
			public double forwardMovement() {
				return -1;
			}

			@Override
			public Joystick[] joysticks() {
				return null;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(0, currentRotation, 0);
		Assert.assertEquals(0, currentSidewaysMovement, 0);
		Assert.assertEquals(RobotMap.FORWARD_RAMPING
				+ (-1 - RobotMap.FORWARD_RAMPING) * RobotMap.FORWARD_RAMPING,
				currentForwardMovement, 0);
		
		// test sideways ramping
				wheelSystem.setInput(new InputMethod() {

					@Override
					public double sidewaysMovement() {
						return 1;
					}

					@Override
					public double rotation() {
						return 0;
					}

					@Override
					public double forwardMovement() {
						return 0;
					}

					@Override
					public Joystick[] joysticks() {
						return null;
					}
				});
				wheelSystem.run();
				Assert.assertEquals(0, currentRotation, 0);
				Assert.assertEquals(RobotMap.SIDEWAYS_RAMPING, currentSidewaysMovement, 0);
				wheelSystem.setInput(new InputMethod() {

					@Override
					public double sidewaysMovement() {
						return -1;
					}

					@Override
					public double rotation() {
						return 0;
					}

					@Override
					public double forwardMovement() {
						return 0;
					}

					@Override
					public Joystick[] joysticks() {
						return null;
					}
				});
				wheelSystem.run();
				Assert.assertEquals(0, currentRotation, 0);
				Assert.assertEquals(RobotMap.SIDEWAYS_RAMPING
						+ (-1 - RobotMap.SIDEWAYS_RAMPING) * RobotMap.SIDEWAYS_RAMPING,
						currentSidewaysMovement, 0);

		// test squared rotation
		wheelSystem.setInput(new InputMethod() {

			@Override
			public double sidewaysMovement() {
				return 0;
			}

			@Override
			public double rotation() {
				return -1;
			}

			@Override
			public Joystick[] joysticks() {
				return null;
			}

			@Override
			public double forwardMovement() {
				return 0;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(-1, currentRotation, 0);
		wheelSystem.setInput(new InputMethod() {

			@Override
			public double sidewaysMovement() {
				return 0;
			}

			@Override
			public double rotation() {
				return 0.5;
			}

			@Override
			public Joystick[] joysticks() {
				return null;
			}

			@Override
			public double forwardMovement() {
				return 0;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(0.25, currentRotation, 0);
		
		// test deadzone
		wheelSystem.setInput(new InputMethod() {
			
			@Override
			public double forwardMovement() {
				return 0.05;
			}
			
			@Override
			public double sidewaysMovement() {
				return 0.3;
			}
			
			@Override
			public double rotation() {
				return 0;
			}
			
			@Override
			public Joystick[] joysticks() {
				return null;
			}
		});
		wheelSystem.run();
		Assert.assertTrue(currentSidewaysMovement > 0);
		Assert.assertEquals(0, currentForwardMovement, 0);
		
		wheelSystem.setInput(new InputMethod() {
			
			@Override
			public double sidewaysMovement() {
				return 0.07;
			}
			
			@Override
			public double rotation() {
				return 0;
			}
			
			@Override
			public Joystick[] joysticks() {
				return null;
			}
			
			@Override
			public double forwardMovement() {
				return 0.3;
			}
		});
		wheelSystem.run();
		Assert.assertTrue(currentForwardMovement > 0);
		Assert.assertEquals(0, currentSidewaysMovement, 0);
		
		wheelSystem.setInput(new InputMethod() {
			
			@Override
			public double sidewaysMovement() {
				return 0.09;
			}
			
			@Override
			public double rotation() {
				return 0;
			}
			
			@Override
			public Joystick[] joysticks() {
				return null;
			}
			
			@Override
			public double forwardMovement() {
				return 0.09;
			}
		});
		wheelSystem.run();
		Assert.assertEquals(0, currentSidewaysMovement, 0);
		Assert.assertEquals(0, currentForwardMovement, 0);
	}

	/**
	 * WheelSystem subclass for the purpose of unit testing
	 */
	private class TestWheelSystem extends WheelSystem {

		/*
		 * (non-Javadoc)
		 * 
		 * @see org._2585robophiles.frc2015.systems.WheelSystem#drive(double,
		 * double, double)
		 */
		@Override
		public void drive(double normalMovement, double sidewaysMovement,
				double rotation) {
			currentForwardMovement = normalMovement;
			currentSidewaysMovement = sidewaysMovement;
			currentRotation = rotation;
		}

		/*
		 * (non-Javadoc)
		 * 
		 * @see org._2585robophiles.frc2015.systems.WheelSystem#setInput(org.
		 * _2585robophiles.frc2015.input.InputMethod)
		 */
		@Override
		protected synchronized void setInput(InputMethod input) {
			super.setInput(input);
		}

	}
}

{'fraction_non_alphanumeric': 0.10548331363099027, 'fraction_numerical': 0.021733199963626444, 'mean_word_length': 3.010940919037199, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2273963', 'n_tokens_mistral': 4668, 'n_tokens_neox': 3392, 'n_words': 762}