DesiredPitchRollCalculator { public int getAbsolute(int value) { if (value > MID) { return value - MID; } else { int absolute = value - MID; return absolute * -1; } } DesiredPitchRollCalculator(int limit); void setLimit(int limit); int getValue(int value); int getAbsolute(int value); static final int MID; static final int MIN_LIMIT; static final int MAX_LIMIT; }
@Test public void getAbsoluteShouldReturn500for2000() { assertThat(calculator.getAbsolute(2000)).isEqualTo(500); }
@Test public void getAbsoluteShouldReturn500for1000() { assertThat(calculator.getAbsolute(1000)).isEqualTo(500); }
@Test public void getAbsoluteShouldReturn100for1600() { assertThat(calculator.getAbsolute(1600)).isEqualTo(100); }