Commit 2bd83439 authored by Luc Maisonobe's avatar Luc Maisonobe

Fixed check for arrays containing NaNs.

parent 3762dfa0
......@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import org.hipparchus.complex.Quaternion;
import org.hipparchus.geometry.euclidean.threed.Vector3D;
import org.hipparchus.linear.RealMatrix;
import org.hipparchus.util.Precision;
......@@ -34,6 +35,8 @@ import org.orekit.Utils;
import org.orekit.data.DataSource;
import org.orekit.files.ccsds.definitions.BodyFacade;
import org.orekit.files.ccsds.definitions.FrameFacade;
import org.orekit.files.ccsds.ndm.adm.AttitudeEndoints;
import org.orekit.files.ccsds.ndm.adm.apm.ApmQuaternion;
import org.orekit.files.ccsds.ndm.tdm.Observation;
import org.orekit.files.ccsds.section.CommentsContainer;
import org.orekit.files.ccsds.section.Header;
......@@ -123,6 +126,12 @@ public abstract class AbstractNdmWriterTest<H extends Header, S extends Segment<
} else if (original instanceof CommentsContainer) {
checkContainer(original, rebuilt);
return true;
} else if (original instanceof ApmQuaternion) {
checkContainer(original, rebuilt);
return true;
} else if (original instanceof AttitudeEndoints) {
checkContainer(original, rebuilt);
return true;
} else if (original instanceof FrameFacade) {
checkFrameFacade((FrameFacade) original, (FrameFacade) rebuilt);
return true;
......@@ -141,6 +150,9 @@ public abstract class AbstractNdmWriterTest<H extends Header, S extends Segment<
} else if (original instanceof Vector3D) {
checkVector3D((Vector3D) original, (Vector3D) rebuilt);
return true;
} else if (original instanceof Quaternion) {
checkQuaternion((Quaternion) original, (Quaternion) rebuilt);
return true;
} else if (original instanceof RealMatrix) {
checkRealMatrix((RealMatrix) original, (RealMatrix) rebuilt);
return true;
......@@ -180,7 +192,7 @@ public abstract class AbstractNdmWriterTest<H extends Header, S extends Segment<
private void checkDoubleArray(final double[] original, final double[] rebuilt) {
Assert.assertEquals(original.length, rebuilt.length);
for (int i = 0; i < original.length; ++i) {
Assert.assertTrue(Precision.equals(original[i], rebuilt[i], 1));
Assert.assertTrue(Precision.equalsIncludingNaN(original[i], rebuilt[i], 1));
}
}
......@@ -249,6 +261,13 @@ public abstract class AbstractNdmWriterTest<H extends Header, S extends Segment<
Assert.assertTrue(Precision.equalsIncludingNaN(original.getZ(), rebuilt.getZ(), 1));
}
private void checkQuaternion(final Quaternion original, final Quaternion rebuilt) {
Assert.assertTrue(Precision.equalsIncludingNaN(original.getQ0(), rebuilt.getQ0(), 1));
Assert.assertTrue(Precision.equalsIncludingNaN(original.getQ1(), rebuilt.getQ1(), 1));
Assert.assertTrue(Precision.equalsIncludingNaN(original.getQ2(), rebuilt.getQ2(), 1));
Assert.assertTrue(Precision.equalsIncludingNaN(original.getQ3(), rebuilt.getQ3(), 1));
}
private void checkRealMatrix(final RealMatrix original, final RealMatrix rebuilt) {
Assert.assertEquals(original.getRowDimension(), rebuilt.getRowDimension());
Assert.assertEquals(original.getColumnDimension(), rebuilt.getColumnDimension());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment