[OpenLayers-Commits] r2342 - sandbox/vector-2.4/tests/BaseTypes

commits at openlayers.org commits at openlayers.org
Mon Mar 5 15:23:19 EST 2007


Author: euzuro
Date: 2007-03-05 15:23:11 -0500 (Mon, 05 Mar 2007)
New Revision: 2342

Modified:
   sandbox/vector-2.4/tests/BaseTypes/test_Bounds.html
Log:
tests for extend() on Bounds class

Modified: sandbox/vector-2.4/tests/BaseTypes/test_Bounds.html
===================================================================
--- sandbox/vector-2.4/tests/BaseTypes/test_Bounds.html	2007-03-05 20:04:38 UTC (rev 2341)
+++ sandbox/vector-2.4/tests/BaseTypes/test_Bounds.html	2007-03-05 20:23:11 UTC (rev 2342)
@@ -277,7 +277,7 @@
         t.eq( bounds.top, 4, "bounds.top is set correctly" );
      }
 
-     function test_14_Bounds_fromSize(t) {
+     function test_15_Bounds_fromSize(t) {
         t.plan( 5 );
         
         var height = 15;
@@ -291,6 +291,95 @@
         t.eq( bounds.top, 0, "bounds.top is set correctly" );
      }
 
+
+     function test_16_Bounds_extend(t) {
+        t.plan( 8 );
+
+        var originalBounds = new OpenLayers.Bounds(10,20,50,80);
+
+        var bounds = originalBounds.clone();
+        
+      //null obj
+        bounds.extend(null);        
+        t.ok(bounds.equals(originalBounds), "null to extend does not crash or change original bounds");
+
+      //obj with no classname        
+        var object = new Object();
+        bounds.extend(object);        
+        t.ok(bounds.equals(originalBounds), "extend() passing object with no classname does not crash or change original bounds")
+
+    //obj is bounds
+
+      //pushing all limits with bounds obj
+        var testBounds = new OpenLayers.Bounds(5, 10, 60, 90);
+        object = testBounds.clone();
+        
+        bounds.extend(object);
+        t.ok(bounds.equals(testBounds), "extend by valid bounds, pushing all limits, correctly extends bounds");
+
+      //pushing no limits with bounds obj
+        bounds = originalBounds.clone();
+
+        testBounds = new OpenLayers.Bounds(15, 30, 40, 70);
+        object = testBounds.clone();
+        
+        bounds.extend(object);
+        t.ok(bounds.equals(originalBounds), "extend by valid bounds, pushing no limits, correctly does not extend bounds");
+
+    // obj is lonlat
+    
+      //left, bottom
+        bounds = originalBounds.clone();
+        
+        object = new OpenLayers.LonLat(5, 10);
+        
+        bounds.extend(object);
+               
+        t.ok( ((bounds.left == object.lon) &&
+               (bounds.bottom == object.lat) &&
+               (bounds.right == originalBounds.right) &&
+               (bounds.top == originalBounds.top)), "obj lonlat to extends correclty modifies left and bottom");
+              
+      //right, top
+        bounds = originalBounds.clone();
+        
+        object = new OpenLayers.LonLat(60,90);
+        
+        bounds.extend(object);
+
+        t.ok( ((bounds.left == originalBounds.left) &&
+               (bounds.bottom == originalBounds.bottom) &&
+               (bounds.right == object.lon) &&
+               (bounds.top == object.lat)), "obj lonlat to extends correclty modifies right and top");
+              
+    // obj is point
+    
+      //left, bottom
+        bounds = originalBounds.clone();
+        
+        object = new OpenLayers.Geometry.Point(5, 10);
+        
+        bounds.extend(object);
+               
+        t.ok( ((bounds.left == object.lon) &&
+               (bounds.bottom == object.lat) &&
+               (bounds.right == originalBounds.right) &&
+               (bounds.top == originalBounds.top)), "obj Point to extends correclty modifies left and bottom");
+              
+      //right, top
+        bounds = originalBounds.clone();
+        
+        object = new OpenLayers.Geometry.Point(60,90);
+        
+        bounds.extend(object);
+
+        t.ok( ((bounds.left == originalBounds.left) &&
+               (bounds.bottom == originalBounds.bottom) &&
+               (bounds.right == object.lon) &&
+               (bounds.top == object.lat)), "obj Point to extends correclty modifies right and top");
+
+     }
+
   // -->
   </script>
 </head>



More information about the Commits mailing list