From eb59f4d0061f04d61125d59f7eda5e0022c4b83d Mon Sep 17 00:00:00 2001
From: Guylaine Prat <guylaine.prat@c-s.fr>
Date: Fri, 15 Feb 2019 14:45:40 +0100
Subject: [PATCH] Improve tests coverage

---
 .../org/orekit/rugged/api/RuggedTest.java     | 29 +++++++++++++++++++
 .../duvenhage/MinMaxTreeTileTest.java         | 22 ++++++++++++--
 2 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/orekit/rugged/api/RuggedTest.java b/src/test/java/org/orekit/rugged/api/RuggedTest.java
index aaf25147..0b2b555a 100644
--- a/src/test/java/org/orekit/rugged/api/RuggedTest.java
+++ b/src/test/java/org/orekit/rugged/api/RuggedTest.java
@@ -18,6 +18,7 @@ package org.orekit.rugged.api;
 
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -1479,6 +1480,34 @@ public class RuggedTest {
         
         assertEquals(sp.getPixelNumber(), spChangeLines.getPixelNumber(), 1.e-9);
         assertEquals(sp.getLineNumber(), spChangeLines.getLineNumber(), 1.e-9);
+        
+        // For computeInverseLocOnGridWithoutAtmosphere special cases
+        try {
+            java.lang.reflect.Method computeWithoutAtmosphere = 
+                    rugged.getClass().getDeclaredMethod("computeInverseLocOnGridWithoutAtmosphere",
+                                                        GeodeticPoint[][].class,
+                                                        Integer.TYPE, Integer.TYPE,
+                                                        LineSensor.class, Integer.TYPE, Integer.TYPE);
+            computeWithoutAtmosphere.setAccessible(true);
+            final int nbPixelGrid = 2; 
+            final int nbLineGrid = 2;
+            GeodeticPoint[][] groundGridWithAtmosphere = new GeodeticPoint[nbPixelGrid][nbLineGrid];
+            for (int i = 0; i < nbPixelGrid; i++) {
+                for (int j = 0; j < nbLineGrid; j++) {
+                    groundGridWithAtmosphere[i][j] = null;
+                }
+            }
+             
+            SensorPixel[][] spNull = (SensorPixel[][]) computeWithoutAtmosphere.invoke(rugged, groundGridWithAtmosphere, nbPixelGrid, nbLineGrid, lineSensor, minLine, maxLine);
+            for (int i = 0; i < nbPixelGrid; i++) {
+                for (int j = 0; j < nbLineGrid; j++) {
+                    assertNull(spNull[i][j]);
+                }
+            }
+        } catch (NoSuchMethodException | SecurityException | 
+                IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+            Assert.fail(e.getLocalizedMessage());
+        }
     }
     
     
diff --git a/src/test/java/org/orekit/rugged/intersection/duvenhage/MinMaxTreeTileTest.java b/src/test/java/org/orekit/rugged/intersection/duvenhage/MinMaxTreeTileTest.java
index 63ccd155..78b87a52 100644
--- a/src/test/java/org/orekit/rugged/intersection/duvenhage/MinMaxTreeTileTest.java
+++ b/src/test/java/org/orekit/rugged/intersection/duvenhage/MinMaxTreeTileTest.java
@@ -16,13 +16,17 @@
  */
 package org.orekit.rugged.intersection.duvenhage;
 
-import java.lang.reflect.Field;
-
 import org.hipparchus.random.RandomGenerator;
 import org.hipparchus.random.Well1024a;
 import org.hipparchus.util.FastMath;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
 import org.junit.Assert;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 public class MinMaxTreeTileTest {
 
@@ -264,6 +268,17 @@ public class MinMaxTreeTileTest {
         }
     }
 
+    @Test
+    public void testForCoverage() throws IOException {
+        
+        org.orekit.rugged.errors.DumpManager.activate(tempFolder.newFile());
+
+        MinMaxTreeTile tile = createTile(1201, 1201);
+        tile.getMinElevation(100, 100, 0);
+        
+        org.orekit.rugged.errors.DumpManager.deactivate();
+    }
+    
     private int[] neighbors(int row, int column, int nbRows, int nbColumns, int stages) {
 
         // poor man identification of neighbors cells merged together with specified cell
@@ -345,5 +360,8 @@ public class MinMaxTreeTileTest {
         tile.tileUpdateCompleted();
         return tile;
     }
+    
+    @Rule
+    public TemporaryFolder tempFolder = new TemporaryFolder();
 
 }
-- 
GitLab