Search in sources :

Example 51 with DependsOnMethod

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);
}
Also used : AttributedCharacterIterator(java.text.AttributedCharacterIterator) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 52 with DependsOnMethod

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;
    }
}
Also used : Field(java.lang.reflect.Field) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 53 with DependsOnMethod

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);
}
Also used : BigDecimal(java.math.BigDecimal) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 54 with DependsOnMethod

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);
    }
}
Also used : BigDecimal(java.math.BigDecimal) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 55 with DependsOnMethod

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);
    }
}
Also used : BigDecimal(java.math.BigDecimal) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

DependsOnMethod (org.apache.sis.test.DependsOnMethod)298 Test (org.junit.Test)296 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)27 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)23 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)21 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)21 Rectangle (java.awt.Rectangle)19 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)19 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)18 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)15 Random (java.util.Random)11 Matrix (org.opengis.referencing.operation.Matrix)11 HashMap (java.util.HashMap)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)8 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)8 MathTransform (org.opengis.referencing.operation.MathTransform)8 DefaultFeatureType (org.apache.sis.feature.DefaultFeatureType)7 DefaultFeatureTypeTest (org.apache.sis.feature.DefaultFeatureTypeTest)7 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)7 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7