2013-03-14 10:21:23 +04:00
|
|
|
var assert = require("../env-assert"),
|
|
|
|
d3 = require("../../"),
|
|
|
|
format = d3.format("13.8f");
|
2013-03-12 02:33:40 +04:00
|
|
|
|
|
|
|
module.exports = function(suite, mapping) {
|
|
|
|
|
|
|
|
for (var place in mapping) {
|
|
|
|
suite[place] = test(mapping[place][0], mapping[place][1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function test(location, point) {
|
|
|
|
return function(projection) {
|
|
|
|
var actualLocation = projection.invert(point),
|
|
|
|
actualPoint = projection(location);
|
|
|
|
try {
|
|
|
|
assert.inDelta([actualPoint, actualLocation], [point, location], 1e-5);
|
|
|
|
} catch (e) {
|
|
|
|
e.message = "project [["
|
|
|
|
+ location.map(format).join(", ") + "], [" + actualPoint.map(format).join(", ")
|
|
|
|
+ "]]\n invert [["
|
|
|
|
+ actualLocation.map(format).join(", ") + "], [" + point.map(format).join(", ")
|
|
|
|
+ "]]";
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return suite;
|
|
|
|
};
|