From 417a45d686183413f6b4ed8c31c567e3775e9664 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe <luc@orekit.org> Date: Tue, 8 Feb 2022 15:20:24 +0100 Subject: [PATCH] Improved test coverage. --- .../org/orekit/rugged/api/RuggedTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/org/orekit/rugged/api/RuggedTest.java b/src/test/java/org/orekit/rugged/api/RuggedTest.java index a8804beb..cfb7c1d0 100644 --- a/src/test/java/org/orekit/rugged/api/RuggedTest.java +++ b/src/test/java/org/orekit/rugged/api/RuggedTest.java @@ -905,6 +905,28 @@ public class RuggedTest { Assert.assertNotNull(sensorPixel); + Assert.assertFalse(inside(rugged, null, lineSensor)); + Assert.assertFalse(inside(rugged, new SensorPixel(-100, -100), lineSensor)); + Assert.assertFalse(inside(rugged, new SensorPixel(-100, +100), lineSensor)); + Assert.assertFalse(inside(rugged, new SensorPixel(+100, -100), lineSensor)); + Assert.assertFalse(inside(rugged, new SensorPixel(+100, +100), lineSensor)); + Assert.assertTrue(inside(rugged, new SensorPixel(0.2, 0.3), lineSensor)); + + } + + private boolean inside(final Rugged rugged, final SensorPixel sensorPixel, LineSensor lineSensor) { + try { + final Method inside = + Rugged.class.getDeclaredMethod("pixelIsInside", + SensorPixel.class, + LineSensor.class); + inside.setAccessible(true); + return ((Boolean) inside.invoke(rugged, sensorPixel, lineSensor)).booleanValue(); + } catch (NoSuchMethodException | IllegalAccessException | + IllegalArgumentException | InvocationTargetException e) { + Assert.fail(e.getLocalizedMessage()); + return false; + } } @Test -- GitLab