This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 01c6baf548 Add tests about internal consistency of the `Number[]` 
array returned by `getElementAsNumbers()`. Fix a bug in the interaction between 
`GridGeometry` et `ProjectiveTransform` constructors and a NullPointerException.
01c6baf548 is described below

commit 01c6baf548a267926ca793e6f1c235f2c85a326a
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Sun Jan 8 20:36:34 2023 +0100

    Add tests about internal consistency of the `Number[]` array returned by 
`getElementAsNumbers()`.
    Fix a bug in the interaction between `GridGeometry` et 
`ProjectiveTransform` constructors and a NullPointerException.
---
 .../apache/sis/coverage/grid/GridGeometryTest.java | 34 +++++++++++-
 .../sis/internal/referencing/Arithmetic.java       |  3 +-
 .../referencing/ExtendedPrecisionMatrix.java       |  3 ++
 .../operation/transform/ProjectiveTransform.java   |  3 +-
 .../operation/matrix/GeneralMatrixTest.java        | 20 ++++---
 .../referencing/operation/matrix/Matrix1Test.java  |  8 +--
 .../referencing/operation/matrix/Matrix2Test.java  |  6 +--
 .../referencing/operation/matrix/Matrix3Test.java  |  8 +--
 .../referencing/operation/matrix/Matrix4Test.java  |  8 +--
 .../operation/matrix/MatrixTestCase.java           | 61 ++++++++++++++++++----
 .../operation/matrix/NonSquareMatrixTest.java      |  4 +-
 .../operation/transform/MathTransformTestCase.java |  2 +
 12 files changed, 125 insertions(+), 35 deletions(-)

diff --git 
a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
 
b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
index 1ad5734cb8..85b5bfac4d 100644
--- 
a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
+++ 
b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridGeometryTest.java
@@ -33,6 +33,7 @@ import 
org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.referencing.operation.HardCodedConversions;
 import org.apache.sis.referencing.crs.HardCodedCRS;
 import org.apache.sis.geometry.GeneralEnvelope;
+import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -45,7 +46,7 @@ import static org.apache.sis.test.ReferencingAssert.*;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Johann Sorel (Geomatys)
- * @version 1.3
+ * @version 1.4
  * @since   1.0
  */
 @DependsOn(GridExtentTest.class)
@@ -434,6 +435,37 @@ public final class GridGeometryTest extends TestCase {
         verifyGridToCRS(grid);
     }
 
+    /**
+     * Verifies "grid to CRS" coefficients of a simple grid geometry.
+     */
+    @Test
+    public void testGetGridToCRS() {
+        final var extent = new GridExtent(null, new long[3], new long[3], 
true);
+        final var bbox   = new GeneralEnvelope(new double[] {-180, -90, 
-1000}, new double[] {180, 90, 2000});
+        final var grid   = new GridGeometry(extent, bbox, 
GridOrientation.HOMOTHETY);
+        assertEquals(extent, grid.getExtent());
+        assertEnvelopeEquals(bbox, grid.getEnvelope());
+        /*
+         * Verify internal consistency of the "grid to CRS" matrix.
+         * This consistency is violated if `ProjectiveTransform` constructor 
takes an `Number[]`
+         * array which is not protected against changes in the `GeneralMatrix` 
that own that array.
+         */
+        final Matrix   gridToCRS = 
MathTransforms.getMatrix(grid.getGridToCRS(PixelInCell.CELL_CORNER));
+        final Number[] numbers   = ((ExtendedPrecisionMatrix) 
gridToCRS).getElementAsNumbers(false);
+        final double[] elements  = 
MatrixSIS.castOrCopy(gridToCRS).getElements();
+        assertArrayEquals(new double[] {360, 0, 0, -180, 0, 180, 0, -90, 0, 0, 
3000, -1000, 0, 0, 0, 1}, elements, STRICT);
+        assertEquals(elements.length, numbers.length);
+        for (int i=0; i<elements.length; i++) {
+            final double expected = elements[i];
+            final Number actual   = numbers [i];
+            if (expected == 0) {
+                assertNull(actual);
+            } else {
+                assertEquals(expected, actual.doubleValue(), STRICT);
+            }
+        }
+    }
+
     /**
      * Tests {@link GridGeometry#getEnvelope(CoordinateReferenceSystem)}.
      *
diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Arithmetic.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Arithmetic.java
index fc0e1f4bc9..57a56e74aa 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Arithmetic.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Arithmetic.java
@@ -167,7 +167,8 @@ public enum Arithmetic {
      * @return the inverse result, or {@code null} for zero.
      */
     public static Number inverse(final Number a) {
-        if (isOne(a)) return a;
+        if (a == null) return Double.POSITIVE_INFINITY;
+        if (isOne(a))  return a;
         return INVERSE.apply(a, null);
     }
 
diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.java
index d1c626ff61..a0b9872581 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ExtendedPrecisionMatrix.java
@@ -76,6 +76,9 @@ public interface ExtendedPrecisionMatrix extends Matrix {
      * If {@code false}, then the returned array shall be considered read-only 
because it may be a reference
      * to the array stored internally by this matrix.</p>
      *
+     * <p>Note that if the {@code writable} argument is {@code false}, then 
the values of the returned array
+     * may change if the matrix is mutable. If the caller need a stable array, 
use {@code true}.</p>
+     *
      * @param  writable  whether the caller may write in the returned array.
      * @return a copy of all current matrix elements in a row-major array.
      */
diff --git 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
index 44163eaa1a..5188c12e66 100644
--- 
a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
+++ 
b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ProjectiveTransform.java
@@ -82,7 +82,8 @@ class ProjectiveTransform extends AbstractLinearTransform 
implements ExtendedPre
         numCol = matrix.getNumCol();
         Number[] numbers = null;
         if (matrix instanceof ExtendedPrecisionMatrix) {
-            numbers = ((ExtendedPrecisionMatrix) 
matrix).getElementAsNumbers(false);
+            // Use `writable = true` because we need a copy protected from 
changes.
+            numbers = ((ExtendedPrecisionMatrix) 
matrix).getElementAsNumbers(true);
         }
         if (matrix instanceof MatrixSIS) {
             final MatrixSIS m = (MatrixSIS) matrix;
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java
index 7a1163a941..eb52a5f499 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/GeneralMatrixTest.java
@@ -54,8 +54,8 @@ public final class GeneralMatrixTest extends MatrixTestCase {
      * Ensures that the given matrix is an instance of the expected type.
      */
     @Override
-    void validate(final MatrixSIS matrix) {
-        super.validate(matrix);
+    void validateImplementation(final MatrixSIS matrix) {
+        super.validateImplementation(matrix);
         assertEquals(GeneralMatrix.class, matrix.getClass());
     }
 
@@ -65,14 +65,16 @@ public final class GeneralMatrixTest extends MatrixTestCase 
{
      */
     @Test
     public void testExtendedPrecision() {
+        size = 1;
         final long value = 1000000000000010000L;
         assertNotEquals(value, StrictMath.round((double) value));       // 
Otherwise the test would be useless.
-        final GeneralMatrix m = new GeneralMatrix(1, 1, false);
+        final GeneralMatrix matrix = new GeneralMatrix(1, 1, false);
         final DoubleDouble ddval = DoubleDouble.of(value);
-        m.setNumber(0, 0, ddval);
+        matrix.setNumber(0, 0, ddval);
         assertEquals(value, ddval.longValue());
-        assertEquals(ddval, m.getNumber (0, 0));
-        assertEquals(value, m.getInteger(0, 0));
+        assertEquals(ddval, matrix.getNumber (0, 0));
+        assertEquals(value, matrix.getInteger(0, 0));
+        validateImplementation(matrix);
     }
 
     /**
@@ -81,6 +83,7 @@ public final class GeneralMatrixTest extends MatrixTestCase {
      */
     @Test
     public void testGetElementAsNumbers() {
+        size = 2;
         final Number[] numbers = {
                 DoubleDouble.DEGREES_TO_RADIANS,
                 DoubleDouble.RADIANS_TO_DEGREES,
@@ -96,6 +99,7 @@ public final class GeneralMatrixTest extends MatrixTestCase {
         assertEquals(0, numbers[2]);
         numbers[2] = null;
         assertArrayEquals(numbers, elements);
+        validateImplementation(matrix);
     }
 
     /**
@@ -106,6 +110,7 @@ public final class GeneralMatrixTest extends MatrixTestCase 
{
      */
     @Test
     public void testConvertBefore() {
+        size = 3;
         testConvertBefore(new GeneralMatrix(3, 3, true), true);
     }
 
@@ -117,6 +122,7 @@ public final class GeneralMatrixTest extends MatrixTestCase 
{
      */
     @Test
     public void testConvertAfter() {
+        size = 3;
         testConvertAfter(new GeneralMatrix(3, 3, true));
     }
 
@@ -128,6 +134,7 @@ public final class GeneralMatrixTest extends MatrixTestCase 
{
      */
     @Test
     public void testMultiplyVector() {
+        size = 3;
         testMultiplyVector(new GeneralMatrix(3, 3, true));
     }
 
@@ -139,6 +146,7 @@ public final class GeneralMatrixTest extends MatrixTestCase 
{
      */
     @Test
     public void testTranslateVector() {
+        size = 3;
         testTranslateVector(new GeneralMatrix(3, 3, true));
     }
 }
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix1Test.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix1Test.java
index 90287a3f56..a6583c430a 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix1Test.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix1Test.java
@@ -28,7 +28,7 @@ import static 
org.apache.sis.referencing.operation.matrix.Matrix1.SIZE;
  * This class inherits all tests defined in {@link MatrixTestCase}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.4
+ * @version 1.4
  * @since   0.4
  */
 @DependsOn(SolverTest.class)
@@ -43,8 +43,8 @@ public final class Matrix1Test extends MatrixTestCase {
      * Ensures that the given matrix is an instance of the expected type.
      */
     @Override
-    void validate(final MatrixSIS matrix) {
-        super.validate(matrix);
+    void validateImplementation(final MatrixSIS matrix) {
+        super.validateImplementation(matrix);
         assertEquals(Matrix1.class, matrix.getClass());
     }
 
@@ -58,7 +58,7 @@ public final class Matrix1Test extends MatrixTestCase {
         final double[] elements = createRandomPositiveValues(SIZE * SIZE);
         final Matrix1 matrix = new Matrix1(
                 elements[0]);
-        validate(matrix);
+        validateImplementation(matrix);
         assertArrayEquals(elements, matrix.getElements(), STRICT);
     }
 }
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java
index 06efef6c97..dec14c13c0 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix2Test.java
@@ -43,8 +43,8 @@ public final class Matrix2Test extends MatrixTestCase {
      * Ensures that the given matrix is an instance of the expected type.
      */
     @Override
-    void validate(final MatrixSIS matrix) {
-        super.validate(matrix);
+    void validateImplementation(final MatrixSIS matrix) {
+        super.validateImplementation(matrix);
         assertEquals(Matrix2.class, matrix.getClass());
     }
 
@@ -59,7 +59,7 @@ public final class Matrix2Test extends MatrixTestCase {
         final Matrix2 matrix = new Matrix2(
                 elements[0], elements[1],
                 elements[2], elements[3]);
-        validate(matrix);
+        validateImplementation(matrix);
         assertArrayEquals(elements, matrix.getElements(), STRICT);
     }
 }
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java
index f47f5fd424..295044601a 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix3Test.java
@@ -28,7 +28,7 @@ import static 
org.apache.sis.referencing.operation.matrix.Matrix3.SIZE;
  * This class inherits all tests defined in {@link MatrixTestCase}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.4
  * @since   0.4
  */
 @DependsOn(SolverTest.class)
@@ -43,8 +43,8 @@ public final class Matrix3Test extends MatrixTestCase {
      * Ensures that the given matrix is an instance of the expected type.
      */
     @Override
-    void validate(final MatrixSIS matrix) {
-        super.validate(matrix);
+    void validateImplementation(final MatrixSIS matrix) {
+        super.validateImplementation(matrix);
         assertEquals(Matrix3.class, matrix.getClass());
     }
 
@@ -61,7 +61,7 @@ public final class Matrix3Test extends MatrixTestCase {
                 elements[0], elements[1], elements[2],
                 elements[3], elements[4], elements[5],
                 elements[6], elements[7], elements[8]);
-        validate(matrix);
+        validateImplementation(matrix);
         assertArrayEquals(elements, matrix.getElements(), STRICT);
     }
 
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
index 2fc37b74a1..cbb5ca03f2 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/Matrix4Test.java
@@ -29,7 +29,7 @@ import static 
org.apache.sis.referencing.operation.matrix.Matrix4.SIZE;
  * This class inherits all tests defined in {@link MatrixTestCase}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.4
  * @since   0.4
  */
 @DependsOn(SolverTest.class)
@@ -44,8 +44,8 @@ public final class Matrix4Test extends MatrixTestCase {
      * Ensures that the given matrix is an instance of the expected type.
      */
     @Override
-    void validate(final MatrixSIS matrix) {
-        super.validate(matrix);
+    void validateImplementation(final MatrixSIS matrix) {
+        super.validateImplementation(matrix);
         assertEquals(Matrix4.class, matrix.getClass());
     }
 
@@ -63,7 +63,7 @@ public final class Matrix4Test extends MatrixTestCase {
                 elements[ 4], elements[ 5], elements[ 6], elements[ 7],
                 elements[ 8], elements[ 9], elements[10], elements[11],
                 elements[12], elements[13], elements[14], elements[15]);
-        validate(matrix);
+        validateImplementation(matrix);
         assertArrayEquals(elements, matrix.getElements(), STRICT);
     }
 
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
index 120667f6c3..86585e9a3b 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/MatrixTestCase.java
@@ -21,6 +21,7 @@ import java.awt.geom.AffineTransform;
 import Jama.Matrix;
 import org.apache.sis.math.Statistics;
 import org.apache.sis.internal.util.DoubleDouble;
+import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
 import org.apache.sis.test.TestCase;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.DependsOnMethod;
@@ -140,12 +141,46 @@ public abstract class MatrixTestCase extends TestCase {
 
     /**
      * Validates the given matrix.
-     * The default implementation verifies only the matrix size. Subclasses 
should override this method
+     * The default implementation verifies the matrix size. Subclasses should 
override this method
      * for additional checks, typically ensuring that it is an instance of the 
expected class.
      */
-    void validate(final MatrixSIS matrix) {
+    void validateImplementation(final MatrixSIS matrix) {
         assertEquals("numRow", getNumRow(), matrix.getNumRow());
         assertEquals("numCol", getNumCol(), matrix.getNumCol());
+        validate(matrix);
+    }
+
+    /**
+     * Validates the given matrix by comparing the outcome of different 
methods.
+     * This is an internal consistency check.
+     *
+     * @param  matrix  the matrix to validate, or {@code null} if none.
+     */
+    public static void validate(final org.opengis.referencing.operation.Matrix 
matrix) {
+        if (matrix == null) {
+            return;
+        }
+        final int numRow = matrix.getNumRow();
+        final int numCol = matrix.getNumCol();
+        final var extend = GeneralMatrix.asExtendedPrecision(matrix);
+        final Number[] numbers  = extend.getElementAsNumbers(false);
+        final double[] elements = (matrix instanceof MatrixSIS) ? ((MatrixSIS) 
matrix).getElements() : null;
+        assertEquals("getElementAsNumbers", numRow * numCol, numbers.length);
+        if (elements != null) {
+            assertEquals("getElements", numbers.length, elements.length);
+        }
+        for (int k=0; k<numbers.length; k++) {
+            final int j = k / numCol;
+            final int i = k % numCol;
+            final Number number  = numbers[k];
+            final double element = matrix.getElement(j, i);
+            assertEquals("getElementOrNull", number, 
extend.getElementOrNull(j, i));
+            assertEquals("isZero", number == null, 
ExtendedPrecisionMatrix.isZero(number));
+            assertEquals("getElement", (number != null) ? number.doubleValue() 
: 0, element, STRICT);
+            if (elements != null) {
+                assertEquals("getElements", element, elements[k], STRICT);
+            }
+        }
     }
 
     /**
@@ -241,7 +276,7 @@ public abstract class MatrixTestCase extends TestCase {
         final int numCol = getNumCol();
         final double[] elements = createRandomPositiveValues(numRow * numCol);
         final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
-        validate(matrix);
+        validateImplementation(matrix);
         /*
          * The JAMA constructor uses column-major array (FORTRAN convention), 
while SIS uses
          * row-major array. So we have to transpose the JAMA matrix after 
construction.
@@ -263,7 +298,7 @@ public abstract class MatrixTestCase extends TestCase {
         final int numRow = getNumRow();
         final int numCol = getNumCol();
         final MatrixSIS matrix = Matrices.createZero(numRow, numCol);
-        validate(matrix);
+        validateImplementation(matrix);
         final Matrix reference = new Matrix(numRow, numCol);
         /*
          * End of initialization - now perform the actual test.
@@ -294,7 +329,7 @@ public abstract class MatrixTestCase extends TestCase {
         final int numRow = getNumRow();
         final int numCol = getNumCol();
         final MatrixSIS matrix = Matrices.createDiagonal(numRow, numCol);
-        validate(matrix);
+        validateImplementation(matrix);
         /*
          * End of initialization - now perform the actual test.
          */
@@ -327,8 +362,8 @@ public abstract class MatrixTestCase extends TestCase {
         final double[] elements = createRandomPositiveValues(numRow * numCol);
         final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
         final MatrixSIS clone  = matrix.clone();
-        validate(matrix);
-        validate(clone);
+        validateImplementation(matrix);
+        validateImplementation(clone);
         assertNotSame("clone", matrix, clone);
         assertEquals("equals", matrix, clone);
         assertEquals("hashCode", matrix.hashCode(), clone.hashCode());
@@ -356,7 +391,7 @@ public abstract class MatrixTestCase extends TestCase {
         final int numCol = getNumCol();
         final double[] elements = createRandomPositiveValues(numRow * numCol);
         final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
-        validate(matrix);
+        validateImplementation(matrix);
         /*
          * The JAMA constructor uses column-major array (FORTRAN convention) 
while SIS uses row-major
          * array. In other words, the JAMA matrix is already transposed from 
the SIS point of view.
@@ -377,7 +412,7 @@ public abstract class MatrixTestCase extends TestCase {
         final int numCol = getNumCol();
         final double[] elements = createRandomPositiveValues(numRow * numCol);
         final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
-        validate(matrix);
+        validateImplementation(matrix);
         final double[] expected = new double[numCol];
         for (int i=0; i<numCol; i++) {
             expected[i] = magnitude(matrix, i, numRow);
@@ -454,6 +489,7 @@ public abstract class MatrixTestCase extends TestCase {
              */
             matrix.convertBefore(srcDim, scale, offset);
             assertCoefficientsEqual(at, matrix);
+            validateImplementation(matrix);
         }
     }
 
@@ -506,6 +542,7 @@ public abstract class MatrixTestCase extends TestCase {
             at.preConcatenate(pre);
             matrix.convertAfter(tgtDim, scale, offset);
             assertCoefficientsEqual(at, matrix);
+            validateImplementation(matrix);
         }
     }
 
@@ -530,6 +567,7 @@ public abstract class MatrixTestCase extends TestCase {
                          vector[1] = fma(random.nextDouble(), 50, -25));
             matrix.translate(vector);
             assertMatrixEquals("translate", AffineTransforms2D.toMatrix(at), 
matrix, TOLERANCE);
+            validateImplementation(matrix);
         }
     }
 
@@ -572,6 +610,7 @@ public abstract class MatrixTestCase extends TestCase {
             at.transform(vector, 0, vector, 0, 1);                  // The 
expected result.
             assertEquals("x", vector[0], result[0], TOLERANCE);
             assertEquals("y", vector[1], result[1], TOLERANCE);
+            validateImplementation(matrix);
         }
     }
 
@@ -607,6 +646,7 @@ public abstract class MatrixTestCase extends TestCase {
             final Matrix referenceResult = reference.times(referenceArg);
             final MatrixSIS matrixResult = matrix.multiply(matrixArg);
             assertEqualsJAMA(referenceResult, matrixResult, TOLERANCE);
+            validateImplementation(matrix);
         }
     }
 
@@ -647,6 +687,7 @@ public abstract class MatrixTestCase extends TestCase {
             final Matrix referenceResult = reference.solve(referenceArg);
             final MatrixSIS matrixResult = matrix.solve(matrixArg);
             assertEqualsJAMA(referenceResult, matrixResult, 
SolverTest.TOLERANCE);
+            validateImplementation(matrix);
         }
     }
 
@@ -671,6 +712,7 @@ public abstract class MatrixTestCase extends TestCase {
             }
             final MatrixSIS matrix = Matrices.create(numRow, numCol, elements);
             assertEqualsJAMA(reference.inverse(), matrix.inverse(), TOLERANCE);
+            validateImplementation(matrix);
         }
     }
 
@@ -685,5 +727,6 @@ public abstract class MatrixTestCase extends TestCase {
         final int numCol = getNumCol();
         final MatrixSIS matrix = Matrices.create(numRow, numCol, 
createRandomPositiveValues(numRow * numCol));
         assertNotSame(matrix, assertSerializedEquals(matrix));
+        validateImplementation(matrix);
     }
 }
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
index 6baae345e9..0c509f11ce 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/matrix/NonSquareMatrixTest.java
@@ -68,8 +68,8 @@ public final class NonSquareMatrixTest extends MatrixTestCase 
{
      * Ensures that the given matrix is an instance of the expected type.
      */
     @Override
-    void validate(final MatrixSIS matrix) {
-        super.validate(matrix);
+    void validateImplementation(final MatrixSIS matrix) {
+        super.validateImplementation(matrix);
         assertEquals(NonSquareMatrix.class, matrix.getClass());
     }
 
diff --git 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
index c9715f8ad7..77206da5f1 100644
--- 
a/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
+++ 
b/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformTestCase.java
@@ -43,6 +43,7 @@ import org.opengis.test.Validators;
 import org.opengis.test.referencing.TransformTestCase;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.ReferencingAssert;
+import org.apache.sis.referencing.operation.matrix.MatrixTestCase;
 import static org.opengis.test.Assert.*;
 
 // Branch-dependent imports
@@ -214,6 +215,7 @@ public abstract class MathTransformTestCase extends 
TransformTestCase {
             assertFalse("transform instanceof MathTransform2D:", transform 
instanceof MathTransform2D);
         }
         assertInstanceOf("The transform does not implement all expected 
interfaces.", Parameterized.class, transform);
+        MatrixTestCase.validate(MathTransforms.getMatrix(transform));
     }
 
     /**

Reply via email to