Index: trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java	(revision 9349)
+++ trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java	(revision 9370)
@@ -3,4 +3,6 @@
 
 import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.Random;
 
@@ -19,33 +21,33 @@
 
     @Test
-    public void proj() {
+    public void projections() {
         error = false;
         text = "";
 
-        testProj(Projections.getProjectionByCode("EPSG:4326")); // WGS 84
-        testProj(Projections.getProjectionByCode("EPSG:3857")); // Mercator
-        testProj(Projections.getProjectionByCode("EPSG:3301")); // Lambert EST
+        testProjection(Projections.getProjectionByCode("EPSG:4326")); // WGS 84
+        testProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
+        testProjection(Projections.getProjectionByCode("EPSG:3301")); // Lambert EST
 
         for (int i = 0; i <= 3; ++i) {
-            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(27561+i))); // Lambert 4 Zones France
+            testProjection(Projections.getProjectionByCode("EPSG:"+Integer.toString(27561+i))); // Lambert 4 Zones France
         }
 
         for (int i = 0; i <= 4; ++i) {
-            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(2176+i))); // PUWG Poland
+            testProjection(Projections.getProjectionByCode("EPSG:"+Integer.toString(2176+i))); // PUWG Poland
         }
 
-        testProj(Projections.getProjectionByCode("EPSG:21781")); // Swiss grid
+        testProjection(Projections.getProjectionByCode("EPSG:21781")); // Swiss grid
 
         for (int i = 0; i <= 60; ++i) {
-            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(32601+i))); // UTM North
-            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(32701+i))); // UTM South
+            testProjection(Projections.getProjectionByCode("EPSG:"+Integer.toString(32601+i))); // UTM North
+            testProjection(Projections.getProjectionByCode("EPSG:"+Integer.toString(32701+i))); // UTM South
         }
 
         for (String c : Arrays.asList("2969", "2970", "2972", "2973")) {
-            testProj(Projections.getProjectionByCode("EPSG:"+c)); // UTM France DOM
+            testProjection(Projections.getProjectionByCode("EPSG:"+c)); // UTM France DOM
         }
 
         for (int i = 0; i <= 8; ++i) {
-            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(3942+i))); // Lambert CC9 Zones France
+            testProjection(Projections.getProjectionByCode("EPSG:"+Integer.toString(3942+i))); // Lambert CC9 Zones France
         }
 
@@ -56,5 +58,5 @@
     }
 
-    private void testProj(Projection p) {
+    private void testProjection(Projection p) {
         if (p != null) {
             double maxErrLat = 0, maxErrLon = 0;
@@ -64,8 +66,6 @@
             for (int num = 0; num < 1000; ++num) {
 
-                double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat();
-                double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon();
-
-                LatLon ll = new LatLon(lat, lon);
+                LatLon ll0 = random(b);
+                LatLon ll = ll0;
 
                 for (int i = 0; i < 10; ++i) {
@@ -73,6 +73,6 @@
                     ll = p.eastNorth2latlon(en);
                 }
-                maxErrLat = Math.max(maxErrLat, Math.abs(lat - ll.lat()));
-                maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon()));
+                maxErrLat = Math.max(maxErrLat, Math.abs(ll0.lat() - ll.lat()));
+                maxErrLon = Math.max(maxErrLon, Math.abs(ll0.lon() - ll.lon()));
             }
 
@@ -85,3 +85,65 @@
         }
     }
+
+    private LatLon random(Bounds b) {
+        for (int i=0; i<20; i++) {
+            double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat();
+            double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon();
+            LatLon result = new LatLon(lat, lon);
+            if (result.isValid()) return result;
+        }
+        throw new RuntimeException();
+    }
+
+    boolean error2;
+    String text2;
+    Collection<String> projIds;
+
+    @Test
+    public void projs() {
+        error2 = false;
+        text2 = "";
+
+        projIds = new HashSet<>(Projections.getAllBaseProjectionIds());
+
+        final double EPS = 1e-6;
+        testProj("lonlat", EPS, "");
+        testProj("josm:smerc", EPS, "");
+        testProj("lcc", EPS, "+lat_0=34");
+        testProj("lcc", EPS, "+lat_1=87 +lat_2=83.6 +lat_0=85.43");
+        testProj("somerc", EPS, "+lat_0=47");
+        testProj("tmerc", 2e-3, "");
+        testProj("sterea", EPS, "+lat_0=52");
+
+        if (error2) {
+            System.err.println(text2);
+            Assert.fail();
+        }
+        Assert.assertTrue("missing test: "+projIds, projIds.isEmpty());
+    }
+
+    private void testProj(String id, double eps, String prefAdd) {
+        final int NUM_IT = 1000;
+        projIds.remove(id);
+        String pref = String.format("+proj=%s +ellps=WGS84 +nadgrids=null "+prefAdd, id);
+        CustomProjection p = new CustomProjection();
+        try {
+            p.update(pref);
+        } catch (ProjectionConfigurationException ex) {
+            throw new RuntimeException(ex);
+        }
+        Bounds b = p.getWorldBoundsLatLon();
+        for (int i=0; i<NUM_IT; i++) {
+            LatLon ll1 = random(b);
+            EastNorth en = p.latlon2eastNorth(ll1);
+            LatLon ll2 = p.eastNorth2latlon(en);
+            Assert.assertTrue(p.toCode() + " at " + ll1 + " is " + ll2, ll2.isValid());
+            double dist = ll1.greatCircleDistance(ll2);
+            if (dist > eps) {
+                error2 = true;
+                text2 += id + ": dist " + dist + " at " + ll1 + "\n";
+                return;
+            }
+        }
+    }
 }
