3 <script src="../../lib/OpenLayers.js"></script>
4 <script type="text/javascript">
6 function test_Rectangle_constructor (t) {
10 var rect = new OpenLayers.Geometry.Rectangle();
11 t.ok( rect instanceof OpenLayers.Geometry.Rectangle, "new OpenLayers.Geometry.Rectangle returns Rectangle object" );
12 t.eq( rect.CLASS_NAME, "OpenLayers.Geometry.Rectangle", "Rectangle.CLASS_NAME is set correctly");
13 t.ok( rect.id != null, "rect.id is set");
14 t.ok( ! (rect.x || rect.y || rect.width || rect.height), "empty construct leaves properties empty");
21 var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
22 t.eq( rect.x, x, "good init correctly sets x property");
23 t.eq( rect.y, y, "good init correctly sets y property");
24 t.eq( rect.width, w, "good init correctly sets width property");
25 t.eq( rect.height, h, "good init correctly sets height property");
28 function test_Rectangle_calculateBounds(t) {
35 var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
36 rect.calculateBounds();
38 var testBounds = new OpenLayers.Bounds(x, y, x + w, y + h)
40 t.ok( rect.bounds.equals(testBounds), "calculateBounds works correctly");
43 function test_Rectangle_getLength(t) {
50 var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
52 var testLength = (2 * w) + (2 * h);
54 t.eq(rect.getLength(), testLength, "getLength() works");
57 function test_Rectangle_getArea(t) {
64 var rect = new OpenLayers.Geometry.Rectangle(x, y, w, h);
67 t.eq(rect.getArea(), testArea, "testArea() works");