Skip to content

Commit

Permalink
Added toSquareWeek converter test
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmjr committed May 6, 2023
1 parent b49aa71 commit c2952f4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app/src/test/java/com/mjr/code/physic/units/SquareTimeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,36 @@ public void toSquareDayTest() throws PhysicException {
}
}

@Test
public void toSquareWeekTest() throws PhysicException {
double squareSecondValue = getRandomDouble();
double squareMinuteValue = getRandomDouble();
double squareHourValue = getRandomDouble();
double squareDayValue = getRandomDouble();
double squareWeekValue = getRandomDouble();
try {
Time squareSecondTestResult = new Time(BigDecimal.valueOf(squareSecondValue).multiply(SQUARE_TIME_SCALES[SQUARE_SECOND - 26]).divide(SQUARE_TIME_SCALES[SQUARE_WEEK - 26], ROUND_SCALE, RoundingMode.HALF_UP), SQUARE_SECOND);
Time squareMinuteTestResult = new Time(BigDecimal.valueOf(squareMinuteValue).multiply(SQUARE_TIME_SCALES[SQUARE_MINUTE - 26]).divide(SQUARE_TIME_SCALES[SQUARE_WEEK - 26], ROUND_SCALE, RoundingMode.HALF_UP), SQUARE_MINUTE);
Time squareHourTestResult = new Time(BigDecimal.valueOf(squareHourValue).multiply(SQUARE_TIME_SCALES[SQUARE_HOUR - 26]).divide(SQUARE_TIME_SCALES[SQUARE_WEEK - 26], ROUND_SCALE, RoundingMode.HALF_UP), SQUARE_HOUR);
Time squareDayTestResult = new Time(BigDecimal.valueOf(squareDayValue).multiply(SQUARE_TIME_SCALES[SQUARE_DAY - 26]).divide(SQUARE_TIME_SCALES[SQUARE_WEEK - 26], ROUND_SCALE, RoundingMode.HALF_UP), SQUARE_DAY);
Time squareWeekTestResult = new Time(BigDecimal.valueOf(squareWeekValue).multiply(SQUARE_TIME_SCALES[SQUARE_WEEK - 26]).divide(SQUARE_TIME_SCALES[SQUARE_WEEK - 26], ROUND_SCALE, RoundingMode.HALF_UP), SQUARE_WEEK);

Time squareSecondResult = toSquareWeek(squareSecondValue, SQUARE_SECOND);
Time squareMinuteResult = toSquareWeek(squareMinuteValue, SQUARE_MINUTE);
Time squareHourResult = toSquareWeek(squareHourValue, SQUARE_HOUR);
Time squareDayResult = toSquareWeek(squareDayValue, SQUARE_DAY);
Time squareWeekResult = toSquareWeek(squareWeekValue, SQUARE_WEEK);

assertEquals(squareSecondTestResult, squareSecondResult);
assertEquals(squareMinuteTestResult, squareMinuteResult);
assertEquals(squareHourTestResult, squareHourResult);
assertEquals(squareDayTestResult, squareDayResult);
assertEquals(squareWeekTestResult, squareWeekResult);
} catch (PhysicException e) {
throw e;
}
}

private double getRandomDouble() {
return random.nextDouble();
}
Expand Down

0 comments on commit c2952f4

Please sign in to comment.