Add tests for regular and irregular transformations
This commit is contained in:
@@ -34,6 +34,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function assertFloatEqual
|
||||
* Test two objects for floating point equivalence. Throw an exception
|
||||
* if not equivalent.
|
||||
*
|
||||
* Parameters:
|
||||
* got - {Object}
|
||||
* expected - {Object}
|
||||
* msg - {String} The message to be thrown. This message will be appended
|
||||
* with ": got {got} but expected {expected}" where got and expected are
|
||||
* replaced with string representations of the above arguments.
|
||||
*/
|
||||
function assertFloatEqual(got, expected, msg) {
|
||||
if(got === undefined) {
|
||||
got = "undefined";
|
||||
} else if (got === null) {
|
||||
got = "null";
|
||||
}
|
||||
if(expected === undefined) {
|
||||
expected = "undefined";
|
||||
} else if (expected === null) {
|
||||
expected = "null";
|
||||
}
|
||||
if(Math.abs(got - expected) > 0.000000001) {
|
||||
throw msg + ": got '" + got + "' but expected '" + expected + "'";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function assertGeometryEqual
|
||||
* Test two geometries for equivalence. Geometries are considered
|
||||
@@ -58,9 +86,9 @@
|
||||
|
||||
if(got instanceof OpenLayers.Geometry.Point) {
|
||||
// compare points
|
||||
assertEqual(got.x, expected.x, "x mismatch");
|
||||
assertEqual(got.y, expected.y, "y mismatch");
|
||||
assertEqual(got.z, expected.z, "z mismatch");
|
||||
assertFloatEqual(got.x, expected.x, "x mismatch");
|
||||
assertFloatEqual(got.y, expected.y, "y mismatch");
|
||||
assertFloatEqual(got.z, expected.z, "z mismatch");
|
||||
} else {
|
||||
// compare components
|
||||
assertEqual(
|
||||
@@ -107,4 +135,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user