use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class AngleFormatTest method testFormatToCharacterIterator.
/**
* Tests the {@link AngleFormat#formatToCharacterIterator(Object)} method.
*/
@Test
@DependsOnMethod("testFieldPosition")
public void testFormatToCharacterIterator() {
final Latitude latitude = new Latitude(FormattedCharacterIteratorTest.LATITUDE_VALUE);
final AngleFormat f = new AngleFormat("DD°MM′SS.s″", Locale.CANADA);
final AttributedCharacterIterator it = f.formatToCharacterIterator(latitude);
assertEquals(FormattedCharacterIteratorTest.LATITUDE_STRING, it.toString());
FormattedCharacterIteratorTest.testAttributes(it, true);
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class ConventionalUnitTest method verifyPrefixes.
/**
* Ensures that the characters in the {@link ConventionalUnit#PREFIXES} array match
* the prefixes recognized by {@link LinearConverter#forPrefix(char)}.
*
* @throws ReflectiveOperationException if this test can not access the private fields of {@link LinearConverter}.
*
* @see LinearConverterTest#verifyPrefixes()
*/
@Test
@DependsOnMethod("testPrefix")
public void verifyPrefixes() throws ReflectiveOperationException {
Field f = ConventionalUnit.class.getDeclaredField("PREFIXES");
f.setAccessible(true);
double previousScale = StrictMath.pow(1000, -(ConventionalUnit.MAX_POWER + 1));
for (final char prefix : (char[]) f.get(null)) {
final LinearConverter lc = LinearConverter.forPrefix(prefix);
final String asString = String.valueOf(prefix);
assertNotNull(asString, lc);
/*
* Ratio of previous scale with current scale shall be a power of 10.
*/
final double scale = lc.derivative(0);
final double power = StrictMath.log10(scale / previousScale);
assertTrue(asString, power >= 1);
assertEquals(asString, 0, power % 1, STRICT);
/*
* At this point we got the LinearConverter to use for the test,
* and we know the expected prefix. Verify that we get that value.
*/
assertEquals("ConventionalUnit.prefix(double)", asString, String.valueOf(ConventionalUnit.prefix(scale)));
previousScale = scale;
}
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class LinearConverterTest method testConvertBigDecimal.
/**
* Tests {@link LinearConverter#convert(Number)} with a value of type {@link BigDecimal}.
*/
@Test
@DependsOnMethod("testConvertDouble")
public void testConvertBigDecimal() {
LinearConverter c = LinearConverter.offset(27315, 100);
final Number n = c.convert(new BigDecimal("27.01"));
assertInstanceOf("convert(BigDecimal)", BigDecimal.class, n);
assertEquals(new BigDecimal("300.16"), n);
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class DoubleDoubleTest method testMultiply.
/**
* Tests {@link DoubleDouble#multiply(DoubleDouble)}.
*/
@Test
@DependsOnMethod({ "testSetToProduct", "testNormalize" })
public void testMultiply() {
final DoubleDouble dd = new DoubleDouble();
final DoubleDouble op = new DoubleDouble();
for (int i = 0; i < NUMBER_OF_REPETITIONS; i++) {
nextRandom(dd);
nextRandom(op);
final BigDecimal expected = toBigDecimal(dd).multiply(toBigDecimal(op), MathContext.DECIMAL128);
// Must be after 'expected' computation.
dd.multiply(op);
assertExtendedEquals(expected, dd, PRODUCT_TOLERANCE_FACTOR);
}
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class DoubleDoubleTest method testAdd.
/**
* Tests {@link DoubleDouble#add(DoubleDouble)}.
*/
@Test
@DependsOnMethod({ "testSetToSum", "testNormalize" })
public void testAdd() {
final DoubleDouble dd = new DoubleDouble();
final DoubleDouble op = new DoubleDouble();
for (int i = 0; i < NUMBER_OF_REPETITIONS; i++) {
nextRandom(dd);
nextRandom(op);
final BigDecimal expected = toBigDecimal(dd).add(toBigDecimal(op));
// Must be after 'expected' computation.
dd.add(op);
assertExtendedEquals(expected, dd, ADD_TOLERANCE_FACTOR);
}
}
Aggregations