Class TransformTestCase
-
- Direct Known Subclasses:
AffineTransformTest
,ParameterizedTransformTest
public abstract class TransformTestCase extends TestCase
Base class forMathTransform
implementation tests. Subclasses shall assign a value to thetransform
field before to invoke any method in this class. The specified math transform shall support the following mandatory operations:MathTransform.getSourceDimensions()
MathTransform.getTargetDimensions()
MathTransform.transform(DirectPosition, DirectPosition)
is<Operation>Supported
fields tofalse
.After
TransformTestCase
has been setup, subclasses can invoke any of theverify
methods in their JUnit test methods. Callers must supply the input coordinate points to be used for testing purpose, since the range of valid values is usually transform-dependent.Some general rules:
- Coordinate values, or information used for computing coordinate values, are always
specified as arguments to the
verify
methods. Everything else are fields in theTransformTestCase
object. - The methods in this class do not validate the transform. It is caller responsibility to validate the transform if wanted.
- Unless otherwise indicated, every
verify
methods are independent. For example invokingverifyConsistency(float[])
does not imply a call toverifyInverse(float[])
orverifyDerivative(double[])
. The later methods must be invoked explicitly if wanted.
- Since:
- 2.2
-
-
Field Summary
Fields Modifier and Type Field Description protected double[]
derivativeDeltas
The deltas to use for approximating math transform derivatives by the finite differences method.protected boolean
isDerivativeSupported
true
ifMathTransform.derivative(DirectPosition)
is supported.protected boolean
isDoubleToDoubleSupported
true
ifMathTransform.transform(double[],int,double[],int,int)
is supported.protected boolean
isDoubleToFloatSupported
true
ifMathTransform.transform(double[],int,float[],int,int)
is supported.protected boolean
isFloatToDoubleSupported
true
ifMathTransform.transform(float[],int,double[],int,int)
is supported.protected boolean
isFloatToFloatSupported
true
ifMathTransform.transform(float[],int,float[],int,int)
is supported.protected boolean
isInverseTransformSupported
true
ifMathTransform.inverse()
is supported.protected boolean
isOverlappingArraySupported
true
if the destination array can be the same than the source array, and the source and target region of the array can overlap.protected double
tolerance
Maximum difference to be accepted when comparing a transformed ordinate value with the expected value.protected ToleranceModifier
toleranceModifier
Optional modification to the tolerance threshold before to compare a coordinate points.protected MathTransform
transform
The transform being tested.-
Fields inherited from class TestCase
configurationTip, listener, units, validators
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TransformTestCase()
Creates a new test without factory.protected
TransformTestCase(Factory... factories)
Creates a test case initialized to default values.
-
Method Summary
Modifier and Type Method Description protected void
assertAllTestsEnabled()
Deprecated.No replacement.protected void
assertCoordinateEquals(String message, double[] expected, double[] actual, int index, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.protected void
assertCoordinateEquals(String message, double[] expected, double[] actual, int index, CalculationType mode)
Asserts that a single coordinate is equal to the expected one within a positive delta.protected void
assertCoordinateEquals(String message, double[] expected, float[] actual, int index, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.protected void
assertCoordinateEquals(String message, double[] expected, float[] actual, int index, CalculationType mode)
Asserts that a single coordinate is equal to the expected one within a positive delta.protected void
assertCoordinateEquals(String message, float[] expected, double[] actual, int index, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.protected void
assertCoordinateEquals(String message, float[] expected, double[] actual, int index, CalculationType mode)
Asserts that a single coordinate is equal to the expected one within a positive delta.protected void
assertCoordinateEquals(String message, float[] expected, float[] actual, int index, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.protected void
assertCoordinateEquals(String message, float[] expected, float[] actual, int index, CalculationType mode)
Asserts that a single coordinate is equal to the expected one within a positive delta.protected void
assertCoordinatesEqual(String message, int dimension, double[] expectedPts, int expectedOffset, double[] actualPts, int actualOffset, int numPoints, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.protected void
assertCoordinatesEqual(String message, int dimension, double[] expectedPts, int expectedOffset, double[] actualPts, int actualOffset, int numPoints, CalculationType mode)
Asserts that coordinate values are equal to the expected ones within a positive delta.protected void
assertCoordinatesEqual(String message, int dimension, double[] expectedPts, int expectedOffset, float[] actualPts, int actualOffset, int numPoints, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.protected void
assertCoordinatesEqual(String message, int dimension, double[] expectedPts, int expectedOffset, float[] actualPts, int actualOffset, int numPoints, CalculationType mode)
Asserts that coordinate values are equal to the expected ones within a positive delta.protected void
assertCoordinatesEqual(String message, int dimension, float[] expectedPts, int expectedOffset, double[] actualPts, int actualOffset, int numPoints, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.protected void
assertCoordinatesEqual(String message, int dimension, float[] expectedPts, int expectedOffset, double[] actualPts, int actualOffset, int numPoints, CalculationType mode)
Asserts that coordinate values are equal to the expected ones within a positive delta.protected void
assertCoordinatesEqual(String message, int dimension, float[] expectedPts, int expectedOffset, float[] actualPts, int actualOffset, int numPoints, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.protected void
assertCoordinatesEqual(String message, int dimension, float[] expectedPts, int expectedOffset, float[] actualPts, int actualOffset, int numPoints, CalculationType mode)
Asserts that coordinate values are equal to the expected ones within a positive delta.protected void
assertMatrixEquals(String message, Matrix expected, Matrix actual, Matrix tolmat)
Asserts that a matrix of derivatives is equals to the expected ones within a positive delta.Configuration
configuration()
Returns information about the configuration of the test which has been run.protected void
normalize(DirectPosition expected, DirectPosition actual, CalculationType mode)
Invoked by allassertCoordinateEqual(…)
methods before two positions are compared.protected double
tolerance(double ordinate)
Deprecated.Replaced bytoleranceModifier
.protected float[]
verifyConsistency(float... sourceFloats)
Transforms coordinates using various versions ofMathTransform.transform(…)
and verifies that they produce the same numerical values.protected void
verifyDerivative(double... coordinate)
Computes the derivative at the given point and compares the result with the finite differences approximation.protected float[]
verifyInDomain(double[] minOrdinates, double[] maxOrdinates, int[] numOrdinates, Random randomGenerator)
Verifies all supported transform operations in the given domain.protected void
verifyInverse(double... coordinates)
Transforms the given coordinates, applies the inverse transform and compares with the original values.protected void
verifyInverse(float... coordinates)
Transforms the given coordinates, applies the inverse transform and compares with the original values.protected void
verifyTransform(double[] coordinates, double[] expected)
Transforms the given coordinates and verifies that the result is equals (within a positive delta) to the expected ones.-
Methods inherited from class TestCase
factories, factories, getEnabledFlags
-
-
-
-
Field Detail
-
transform
protected MathTransform transform
The transform being tested. Subclasses should assign a value to this field, together with thetolerance
field, before any test is run.All
ParameterizedTransformTest
test methods will set this field to a non-null value. Implementors can use this value for their own assertions after any test method has been run.- See Also:
tolerance
-
isDoubleToDoubleSupported
protected boolean isDoubleToDoubleSupported
true
ifMathTransform.transform(double[],int,double[],int,int)
is supported. The default value istrue
. Vendor can set this value tofalse
in order to test a transform which is not fully implemented.
-
isFloatToFloatSupported
protected boolean isFloatToFloatSupported
true
ifMathTransform.transform(float[],int,float[],int,int)
is supported. The default value istrue
. Vendor can set this value tofalse
in order to test a transform which is not fully implemented.
-
isDoubleToFloatSupported
protected boolean isDoubleToFloatSupported
true
ifMathTransform.transform(double[],int,float[],int,int)
is supported. The default value istrue
. Vendor can set this value tofalse
in order to test a transform which is not fully implemented.
-
isFloatToDoubleSupported
protected boolean isFloatToDoubleSupported
true
ifMathTransform.transform(float[],int,double[],int,int)
is supported. The default value istrue
. Vendor can set this value tofalse
in order to test a transform which is not fully implemented.
-
isOverlappingArraySupported
protected boolean isOverlappingArraySupported
true
if the destination array can be the same than the source array, and the source and target region of the array can overlap. The default value istrue
. Vendor can set this value tofalse
in order to test a transform which is not fully implemented.- See Also:
verifyConsistency(float[])
-
isInverseTransformSupported
protected boolean isInverseTransformSupported
true
ifMathTransform.inverse()
is supported. The default value istrue
. Vendor can set this value tofalse
in order to test a transform which is not fully implemented.- See Also:
verifyTransform(double[], double[])
-
isDerivativeSupported
protected boolean isDerivativeSupported
true
ifMathTransform.derivative(DirectPosition)
is supported. The default value istrue
. Vendor can set this value tofalse
in order to test a transform which is not fully implemented.- Since:
- 3.1
- See Also:
derivativeDeltas
,verifyDerivative(double[])
-
derivativeDeltas
protected double[] derivativeDeltas
The deltas to use for approximating math transform derivatives by the finite differences method. Each value in this array is the delta to use for the corresponding dimension, in units of the source ordinates of the transform being tested. The array length is theoretically the number of source dimensions, but different lengths are accepted for developers convenience. If the array is smaller than the number of dimensions, then the last delta value will be reused for all remaining dimensions.Testers shall provide a non-null value if the
isDerivativeSupported
flag is set totrue
. Smaller delta would theoretically increase the finite difference precision. However in practice too small deltas decrease the precision, because of floating point errors when subtracting big numbers that are close in magnitude. In the particular case of map projections, experience suggests that a distance of 100 metres converted to decimal degrees is a good compromise. The conversion from metres to degrees can be done using the standard nautical mile length (1852.0 metres by minute of angle) as below:derivativeDeltas = new double[] {100.0 / (60 * 1852)}; // Approximately 100 metres.
- Since:
- 3.1
- See Also:
isDerivativeSupported
,verifyDerivative(double[])
-
tolerance
protected double tolerance
Maximum difference to be accepted when comparing a transformed ordinate value with the expected value. By default this threshold is constant for all dimensions of all coordinates to be compared. If a subclass needs to adjust the tolerance threshold according the dimension or the coordinates values, then it should assign a value to thetoleranceModifier
field in addition to this one.Example: the comparisons of geographic coordinates require increasing tolerance in longitude values as the latitude get closer to a pole. For such comparisons, this
tolerance
field shall be set to a threshold value in metres and thetoleranceModifier
field shall be assigned theToleranceModifier.GEOGRAPHIC
value. See theGEOGRAPHIC
modifier javadoc for more information.The default value is 0, which means that strict equality will be required. Subclasses should set a more suitable tolerance threshold when transform is assigned a value.
- See Also:
transform
,toleranceModifier
-
toleranceModifier
protected ToleranceModifier toleranceModifier
Optional modification to the tolerance threshold before to compare a coordinate points.ToleranceModifier
instance assigned to this field (if any) are transform-dependent. The modifications applied by a particularToleranceModifier
instance to the tolerance thresholds is position-dependent.Common values assigned to this field are
ToleranceModifier.PROJECTION
andToleranceModifier.GEOGRAPHIC
.- Since:
- 3.1
-
-
Constructor Detail
-
TransformTestCase
protected TransformTestCase()
Creates a new test without factory. This constructor is provided for subclasses that instantiate theirMathTransform
directly, without using any factory.
-
TransformTestCase
protected TransformTestCase(Factory... factories)
Creates a test case initialized to default values. The transform is initially null, the tolerance threshold is initially zero and allis<
Operation>Supported
are set totrue
unless at least oneImplementationDetails
object disabled some tests.- Parameters:
factories
- the factories to be used by the test. Those factories will be given toImplementationDetails.configuration(Factory[])
in order to decide which tests should be enabled.
-
-
Method Detail
-
configuration
public Configuration configuration()
Returns information about the configuration of the test which has been run. This method returns a map containing:- All the following keys defined in the
Configuration.Key
enumeration, associated to the valueBoolean.TRUE
orBoolean.FALSE
: - The
"isToleranceRelaxed"
key associated to the valueBoolean.TRUE
if theToleranceModifiers.getImplementationSpecific(MathTransform)
method found at least oneToleranceModifier
on the classpath, orBoolean.FALSE
otherwise.
- Overrides:
configuration
in classTestCase
- Returns:
- the configuration of the test being run, or an empty map if none. This method returns a modifiable map in order to allow subclasses to modify it.
- Since:
- 3.1
- See Also:
ImplementationDetails.configuration(Factory[])
- All the following keys defined in the
-
tolerance
@Deprecated protected double tolerance(double ordinate)
Deprecated.Replaced bytoleranceModifier
.Returns the tolerance threshold for comparing the given ordinate value. The default implementation returns thetolerance
value directly, thus implementing an absolute tolerance threshold. If a subclass needs a relative tolerance threshold instead, it can override this method as below:return tolerance * Math.abs(ordinate);
- Parameters:
ordinate
- the ordinate value being compared.- Returns:
- the absolute tolerance threshold to use for comparing the given ordinate.
-
assertAllTestsEnabled
@Deprecated protected void assertAllTestsEnabled()
Deprecated.No replacement.Ensures that allis<
Operation>Supported
fields are set totrue
. This method can be invoked before testing a math transform which is expected to be fully implemented.
-
verifyTransform
protected void verifyTransform(double[] coordinates, double[] expected) throws TransformException
Transforms the given coordinates and verifies that the result is equals (within a positive delta) to the expected ones. If the difference between an expected and actual ordinate value is greater than the tolerance threshold (after optional tolerance modification), then the assertion fails.If
isInverseTransformSupported
istrue
, then this method will also transform the expected coordinate points using the inverse transform and compare with the source coordinates.- Parameters:
coordinates
- the coordinate points to transform.expected
- the expect result of the transformation, ornull
ifcoordinates
is expected to be null.- Throws:
TransformException
- if the transformation failed.- See Also:
isInverseTransformSupported
-
verifyInverse
protected void verifyInverse(double... coordinates) throws TransformException
Transforms the given coordinates, applies the inverse transform and compares with the original values. If a difference between the expected and actual ordinate values is greater than the tolerance threshold (after optional tolerance modification), then the assertion fails.At the difference of
verifyTransform(double[],double[])
, this method does not require an array of expected values. The expected values are calculated from the transform itself.- Parameters:
coordinates
- the source coordinates to transform.- Throws:
TransformException
- if at least one coordinate can't be transformed.
-
verifyInverse
protected void verifyInverse(float... coordinates) throws TransformException
Transforms the given coordinates, applies the inverse transform and compares with the original values. If a difference between the expected and actual ordinate values is greater than the tolerance threshold (after optional tolerance modification), then the assertion fails.The default implementation delegates to
verifyInverse(double[])
.- Parameters:
coordinates
- the source coordinates to transform.- Throws:
TransformException
- if at least one coordinate can't be transformed.
-
verifyConsistency
protected float[] verifyConsistency(float... sourceFloats) throws TransformException
Transforms coordinates using various versions ofMathTransform.transform(…)
and verifies that they produce the same numerical values. The values calculated byMathTransform.transform(DirectPosition,DirectPosition)
are used as the reference. Other transform methods (operating on arrays) will be compared against that reference, unless their checks were disabled (see class javadoc for details).This method expects an array of
float
values instead thandouble
for making sure that theMathTransform.transform(float[], …)
andMathTransform.transform(double[], …)
methods produces the same numerical values. Thedouble
values may show extra digits when formatted in base 10, but this is not significant if their IEEE 754 representation (which use base 2) are equivalent.This method does not verify the inverse transform or the derivatives. If desired, those later methods can be verified with the
verifyInverse(float[])
andverifyDerivative(double[])
methods respectively.- Parameters:
sourceFloats
- the source coordinates to transform as an array offloat
values.- Returns:
- the transformed coordinates, returned for convenience.
- Throws:
TransformException
- if at least one coordinate can't be transformed.- See Also:
isDoubleToDoubleSupported
,isFloatToFloatSupported
,isDoubleToFloatSupported
,isFloatToDoubleSupported
,isOverlappingArraySupported
-
verifyDerivative
protected void verifyDerivative(double... coordinate) throws TransformException
Computes the derivative at the given point and compares the result with the finite differences approximation.All the three common forms of finite differences (forward difference, backward difference and central difference) are computed. If the finite difference method was a "perfect" approximation, all those three forms would produce identical results. In practice the results will differ, especially in areas where the derivative function varies fast. The difference between the results will be used as an estimation of the approximation accuracy.
The distance between the two points used by the central difference approximation shall be specified in the
derivativeDeltas
array, in units of the source CRS. If the length of thederivativeDeltas
array is smaller than the number of source dimensions, then the last delta value is used for all additional dimensions. This allows specifying a single delta value (in an array of length 1) for all dimensions.This method created the following objects:
expected
- the expected derivative result estimated by the central difference method.tolmat
- a tolerance matrix containing, for each matrix element, the largest difference found between the three approximation methods. The values in this matrix will not be lower than the modified tolerance threshold.
assertMatrixEquals(String, Matrix, Matrix, Matrix)
method. Implementors can override the later method, for example in order to overwrite the tolerance values.- Parameters:
coordinate
- the point where to compute the derivative, in units of the source CRS.- Throws:
TransformException
- if the derivative can not be computed, or a point can not be transformed.- Since:
- 3.1
- See Also:
MathTransform.derivative(DirectPosition)
,assertMatrixEquals(String, Matrix, Matrix, Matrix)
-
verifyInDomain
protected float[] verifyInDomain(double[] minOrdinates, double[] maxOrdinates, int[] numOrdinates, Random randomGenerator) throws TransformException
Verifies all supported transform operations in the given domain. First, this method creates a grid of regularly spaced points along all source dimensions in the given envelope. Next, if the given random number generator is non-null, then this method adds small random displacements to every points and shuffle the coordinates in random order. Finally this method delegates the resulting array of coordinates to the following methods: The generated coordinates array is returned in case callers want to perform more tests in addition to the above-cited verifications.- Parameters:
minOrdinates
- the minimal ordinate values of the domain where to test the transform.maxOrdinates
- the maximal ordinate values of the domain where to test the transform.numOrdinates
- the number of points along each dimension.randomGenerator
- an optional random number generator, ornull
for testing using a regular grid.- Returns:
- the generated random coordinates inside the given domain of validity.
- Throws:
TransformException
- if a transform or a derivative can not be computed.- Since:
- 3.1
-
assertCoordinateEquals
protected final void assertCoordinateEquals(String message, float[] expected, float[] actual, int index, CalculationType mode) throws TransformFailure
Asserts that a single coordinate is equal to the expected one within a positive delta. If the comparison fails, the given message is completed with the expected and actual values, and the index of the ordinate where the failure was found.- Parameters:
message
- the message to print in case of failure.expected
- the array of expected ordinate values.actual
- the array of ordinate values to check against the expected ones.index
- the index of the coordinate point being compared, for message formatting.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Throws:
TransformFailure
- if at least one ordinate value is not equal to the expected value.
-
assertCoordinateEquals
protected final void assertCoordinateEquals(String message, float[] expected, double[] actual, int index, CalculationType mode) throws TransformFailure
Asserts that a single coordinate is equal to the expected one within a positive delta. If the comparison fails, the given message is completed with the expected and actual values, and the index of the ordinate where the failure was found.- Parameters:
message
- the message to print in case of failure.expected
- the array of expected ordinate values.actual
- the array of ordinate values to check against the expected ones.index
- the index of the coordinate point being compared, for message formatting.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Throws:
TransformFailure
- if at least one ordinate value is not equal to the expected value.
-
assertCoordinateEquals
protected final void assertCoordinateEquals(String message, double[] expected, float[] actual, int index, CalculationType mode) throws TransformFailure
Asserts that a single coordinate is equal to the expected one within a positive delta. If the comparison fails, the given message is completed with the expected and actual values, and the index of the ordinate where the failure was found.- Parameters:
message
- the message to print in case of failure.expected
- the array of expected ordinate values.actual
- the array of ordinate values to check against the expected ones.index
- the index of the coordinate point being compared, for message formatting.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Throws:
TransformFailure
- if at least one ordinate value is not equal to the expected value.
-
assertCoordinateEquals
protected final void assertCoordinateEquals(String message, double[] expected, double[] actual, int index, CalculationType mode) throws TransformFailure
Asserts that a single coordinate is equal to the expected one within a positive delta. If the comparison fails, the given message is completed with the expected and actual values, and the index of the ordinate where the failure was found.- Parameters:
message
- the message to print in case of failure.expected
- the array of expected ordinate values.actual
- the array of ordinate values to check against the expected ones.index
- the index of the coordinate point being compared, for message formatting.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Throws:
TransformFailure
- if at least one ordinate value is not equal to the expected value.
-
assertCoordinatesEqual
protected final void assertCoordinatesEqual(String message, int dimension, float[] expectedPts, int expectedOffset, float[] actualPts, int actualOffset, int numPoints, CalculationType mode) throws TransformFailure
Asserts that coordinate values are equal to the expected ones within a positive delta. If the comparison fails, the given message is completed with the expected and actual values, and the index of the coordinate where the failure was found.- Parameters:
message
- the message to print in case of failure.dimension
- the dimension of each coordinate points in the arrays.expectedPts
- the array of expected coordinate values.expectedOffset
- index of the first valid ordinate in theexpectedPts
array.actualPts
- the array of coordinate values to check against the expected ones.actualOffset
- index of the first valid ordinate in theactualPts
array.numPoints
- number of coordinate points to compare.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Throws:
TransformFailure
- if at least one ordinate value is not equal to the expected value.
-
assertCoordinatesEqual
protected final void assertCoordinatesEqual(String message, int dimension, float[] expectedPts, int expectedOffset, double[] actualPts, int actualOffset, int numPoints, CalculationType mode) throws TransformFailure
Asserts that coordinate values are equal to the expected ones within a positive delta. If the comparison fails, the given message is completed with the expected and actual values, and the index of the coordinate where the failure was found.- Parameters:
message
- the message to print in case of failure.dimension
- the dimension of each coordinate points in the arrays.expectedPts
- the array of expected coordinate values.expectedOffset
- index of the first valid ordinate in theexpectedPts
array.actualPts
- the array of coordinate values to check against the expected ones.actualOffset
- index of the first valid ordinate in theactualPts
array.numPoints
- number of coordinate points to compare.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Throws:
TransformFailure
- if at least one ordinate value is not equal to the expected value.
-
assertCoordinatesEqual
protected final void assertCoordinatesEqual(String message, int dimension, double[] expectedPts, int expectedOffset, float[] actualPts, int actualOffset, int numPoints, CalculationType mode) throws TransformFailure
Asserts that coordinate values are equal to the expected ones within a positive delta. If the comparison fails, the given message is completed with the expected and actual values, and the index of the coordinate where the failure was found.- Parameters:
message
- the message to print in case of failure.dimension
- the dimension of each coordinate points in the arrays.expectedPts
- the array of expected coordinate values.expectedOffset
- index of the first valid ordinate in theexpectedPts
array.actualPts
- the array of coordinate values to check against the expected ones.actualOffset
- index of the first valid ordinate in theactualPts
array.numPoints
- number of coordinate points to compare.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Throws:
TransformFailure
- if at least one ordinate value is not equal to the expected value.
-
assertCoordinatesEqual
protected final void assertCoordinatesEqual(String message, int dimension, double[] expectedPts, int expectedOffset, double[] actualPts, int actualOffset, int numPoints, CalculationType mode) throws TransformFailure
Asserts that coordinate values are equal to the expected ones within a positive delta. If the comparison fails, the given message is completed with the expected and actual values, and the index of the coordinate where the failure was found.- Parameters:
message
- the message to print in case of failure.dimension
- the dimension of each coordinate points in the arrays.expectedPts
- the array of expected coordinate values.expectedOffset
- index of the first valid ordinate in theexpectedPts
array.actualPts
- the array of coordinate values to check against the expected ones.actualOffset
- index of the first valid ordinate in theactualPts
array.numPoints
- number of coordinate points to compare.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Throws:
TransformFailure
- if at least one ordinate value is not equal to the expected value.
-
assertCoordinateEquals
@Deprecated protected final void assertCoordinateEquals(String message, float[] expected, float[] actual, int index, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.- Parameters:
message
- the message to print in case of failure.expected
- the array of expected ordinate values.actual
- the array of ordinate values to check against the expected ones.index
- the index of the coordinate point being compared, for message formatting.strict
-true
for ignoring the tolerance threshold. In such case, ordinate values are checked for strict equality.
-
assertCoordinateEquals
@Deprecated protected final void assertCoordinateEquals(String message, float[] expected, double[] actual, int index, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.- Parameters:
message
- the message to print in case of failure.expected
- the array of expected ordinate values.actual
- the array of ordinate values to check against the expected ones.index
- the index of the coordinate point being compared, for message formatting.strict
-true
for ignoring the tolerance threshold. In such case, ordinate values are checked for strict equality.
-
assertCoordinateEquals
@Deprecated protected final void assertCoordinateEquals(String message, double[] expected, float[] actual, int index, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.- Parameters:
message
- the message to print in case of failure.expected
- the array of expected ordinate values.actual
- the array of ordinate values to check against the expected ones.index
- the index of the coordinate point being compared, for message formatting.strict
-true
for ignoring the tolerance threshold. In such case, ordinate values are checked for strict equality.
-
assertCoordinateEquals
@Deprecated protected final void assertCoordinateEquals(String message, double[] expected, double[] actual, int index, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.- Parameters:
message
- the message to print in case of failure.expected
- the array of expected ordinate values.actual
- the array of ordinate values to check against the expected ones.index
- he index of the coordinate point being compared, for message formatting.strict
-true
for ignoring the tolerance threshold. In such case, ordinate values are checked for strict equality.
-
assertCoordinatesEqual
@Deprecated protected final void assertCoordinatesEqual(String message, int dimension, float[] expectedPts, int expectedOffset, float[] actualPts, int actualOffset, int numPoints, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.- Parameters:
message
- the message to print in case of failure.dimension
- the dimension of each coordinate points in the arrays.expectedPts
- the array of expected coordinate values.expectedOffset
- index of the first valid ordinate in theexpectedPts
array.actualPts
- the array of coordinate values to check against the expected ones.actualOffset
- index of the first valid ordinate in theactualPts
array.numPoints
- number of coordinate points to compare.strict
-true
for ignoring the tolerance threshold. In such case, ordinate values are checked for strict equality.
-
assertCoordinatesEqual
@Deprecated protected final void assertCoordinatesEqual(String message, int dimension, float[] expectedPts, int expectedOffset, double[] actualPts, int actualOffset, int numPoints, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.- Parameters:
message
- the message to print in case of failure.dimension
- the dimension of each coordinate points in the arrays.expectedPts
- the array of expected coordinate values.expectedOffset
- index of the first valid ordinate in theexpectedPts
array.actualPts
- the array of coordinate values to check against the expected ones.actualOffset
- index of the first valid ordinate in theactualPts
array.numPoints
- number of coordinate points to compare.strict
-true
for ignoring the tolerance threshold. In such case, ordinate values are checked for strict equality.
-
assertCoordinatesEqual
@Deprecated protected final void assertCoordinatesEqual(String message, int dimension, double[] expectedPts, int expectedOffset, float[] actualPts, int actualOffset, int numPoints, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.- Parameters:
message
- the message to print in case of failure.dimension
- the dimension of each coordinate points in the arrays.expectedPts
- the array of expected coordinate values.expectedOffset
- index of the first valid ordinate in theexpectedPts
array.actualPts
- the array of coordinate values to check against the expected ones.actualOffset
- index of the first valid ordinate in theactualPts
array.numPoints
- number of coordinate points to compare.strict
-true
for ignoring the tolerance threshold. In such case, ordinate values are checked for strict equality.
-
assertCoordinatesEqual
@Deprecated protected final void assertCoordinatesEqual(String message, int dimension, double[] expectedPts, int expectedOffset, double[] actualPts, int actualOffset, int numPoints, boolean strict)
Deprecated.Theboolean
argument has been replaced by aCalculationType
argument.- Parameters:
message
- the message to print in case of failure.dimension
- the dimension of each coordinate points in the arrays.expectedPts
- the array of expected coordinate values.expectedOffset
- index of the first valid ordinate in theexpectedPts
array.actualPts
- the array of coordinate values to check against the expected ones.actualOffset
- index of the first valid ordinate in theactualPts
array.numPoints
- number of coordinate points to compare.strict
-true
for ignoring the tolerance threshold. In such case, ordinate values are checked for strict equality.
-
assertMatrixEquals
protected void assertMatrixEquals(String message, Matrix expected, Matrix actual, Matrix tolmat) throws DerivativeFailure
Asserts that a matrix of derivatives is equals to the expected ones within a positive delta. If the comparison fails, the given message is completed with the expected and actual matrixes values.For each matrix element, the tolerance value is given by the corresponding element in the
tolmat
matrix. This tolerance matrix is initialized by theverifyDerivative(double[])
method to the differences found between the 3 forms of finite difference (forward, backward, central). Developers can override this method and overwrite thetolmat
elements if they wish different tolerance values.- Parameters:
message
- the message to print in case of failure.expected
- the expected matrix of derivative values, estimated by finite differences.actual
- the actual matrix computed by the transform to be tested.tolmat
- the tolerance value for each matrix elements, ornull
for a strict comparison.- Throws:
DerivativeFailure
- if at least one matrix element is not equal to the expected value.- Since:
- 3.1
- See Also:
verifyDerivative(double[])
,Assert.assertMatrixEquals(String, Matrix, Matrix, double)
-
normalize
protected void normalize(DirectPosition expected, DirectPosition actual, CalculationType mode)
Invoked by allassertCoordinateEqual(…)
methods before two positions are compared. This method allows subclasses to replace some equivalent ordinate values by a unique value. For example implementations may ensure that longitude values are contained in the ±180° range, applying 360° shifts if needed.The default implementation does nothing. Subclasses can modify the
actual
ordinate values directly using theDirectPosition.setOrdinate(int, double)
method.- Parameters:
expected
- the expected ordinate value provided by the test case.actual
- the ordinate value computed by the transform being tested.mode
- indicates if the coordinates being compared are the result of a direct or inverse transform, or if strict equality is requested.- Since:
- 3.1
-
-