I have tried to run the JUnit test, but it keeps failing - even if the code is supposed to pass the test. Any ideas why? I have put the function, the conversion factor and the test
This is the test:
private static MathContext mc = new MathContext( 12, RoundingMode.HALF_EVEN );
public static final BigDecimal testValue = new BigDecimal( 123456.1234567 );
@Test
public final void testconvertFathomToMetersDM3() {
BigDecimal expectedResult = unitConverter.convertFathomToMetersDM3(testValue);
assertTrue( expectedResult.equals( new BigDecimal( 1.234561234567E+21, mc ) ) );
}
This is the method that is supposed to do the conversion:
private BigDecimal result;
private static MathContext mc = new MathContext( 12, RoundingMode.HALF_EVEN );
public final BigDecimal convertMetersToFathomDM3(BigDecimal value) {
result = value.divide( ConversionFactors.FATHOM_DMA3, mc );
return result;
}
Here is the conversion factor I have used:
public static final BigDecimal FATHOM_DMA3 = new BigDecimal( 1.875E+1 );