Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/BBoxTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/BBoxTest.java	(revision 12028)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/BBoxTest.java	(revision 12029)
@@ -2,4 +2,5 @@
 package org.openstreetmap.josm.data.osm;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -68,3 +69,86 @@
     }
 
+    /**
+     * Test double constructor which might result in invalid bbox
+     */
+    @Test
+    public void testDoubleConstructor() {
+        assertTrue(new BBox(1, 2, 3, 4).isValid());
+        assertFalse(new BBox(Double.NaN, 2, 3, 4).isValid());
+        assertFalse(new BBox(1, Double.NaN, 3, 4).isValid());
+        assertFalse(new BBox(1, 2, Double.NaN, 4).isValid());
+        assertFalse(new BBox(1, 2, 3, Double.NaN).isValid());
+    }
+
+    /**
+     * Test Node constructor which might result in invalid bbox
+     */
+    @Test
+    public void testNodeConstructor() {
+        assertTrue(new BBox(new Node(LatLon.NORTH_POLE)).isValid());
+        assertFalse(new BBox(new Node()).isValid());
+    }
+
+    /**
+     * Unit test of {@link BBox#add(LatLon)} method.
+     */
+    @Test
+    public void testAddLatLon() {
+        BBox b = new BBox();
+        b.add((LatLon) null);
+        b.add(new LatLon(Double.NaN, Double.NaN));
+        assertFalse(b.isValid());
+        b.add(LatLon.NORTH_POLE);
+        assertTrue(b.isValid());
+        assertEquals(LatLon.NORTH_POLE, b.getCenter());
+    }
+
+    /**
+     * Unit test of {@link BBox#add(double, double)} method.
+     */
+    @Test
+    public void testAddDouble() {
+        BBox b = new BBox();
+        b.add(1, Double.NaN);
+        assertFalse(b.isValid());
+        b.add(Double.NaN, 2);
+        assertFalse(b.isValid());
+        b.add(1, 2);
+        assertTrue(b.isValid());
+        assertEquals(new LatLon(2, 1), b.getCenter());
+    }
+
+    /**
+     * Unit test of {@link BBox#addPrimitive} method.
+     */
+    @Test
+    public void testAddPrimitive() {
+        BBox b = new BBox();
+        b.addPrimitive(new Node(LatLon.NORTH_POLE), 0.5);
+        assertEquals(LatLon.NORTH_POLE, b.getCenter());
+        assertEquals(new LatLon(90.5, -0.5), b.getTopLeft());
+        assertEquals(new LatLon(89.5, +0.5), b.getBottomRight());
+    }
+
+    /**
+     * Unit test of {@link BBox#height} and {@link BBox#width} methods.
+     */
+    @Test
+    public void testHeightWidth() {
+        BBox b1 = new BBox(1, 2, 3, 5);
+        assertEquals(2, b1.width(), 1e-7);
+        assertEquals(3, b1.height(), 1e-7);
+        BBox b2 = new BBox();
+        assertEquals(0, b2.width(), 1e-7);
+        assertEquals(0, b2.height(), 1e-7);
+    }
+
+    /**
+     * Unit test of {@link BBox#toString} method.
+     */
+    @Test
+    public void testToString() {
+        assertEquals("[ x: Infinity -> -Infinity, y: Infinity -> -Infinity ]", new BBox().toString());
+        assertEquals("[ x: 1.0 -> 3.0, y: 2.0 -> 4.0 ]", new BBox(1, 2, 3, 4).toString());
+    }
 }
