Skip to content
Browse files

Adding custom assertion for checking reprojection math.

  • Loading branch information...
1 parent 5f1102c commit a6474b6ddf9f9484ee8d4a46c3ded9f30b356edd @miccolis miccolis committed Jun 6, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 test/sphericalmercator.test.js
View
10 test/sphericalmercator.test.js
@@ -3,6 +3,12 @@ var fs = require('fs');
var path = require('path');
var sm = new (require('..'));
+assert.equalBounds = function(expected, actual, message) {
+ actual.forEach(function(v, i) {
+ var diff = Math.abs(actual[i] - expected[i]);
+ assert.ok(diff < 1e-13, message ||'Difference '+ diff+' is larger than threshold.');
+ });
+};
describe('Unit tests', function() {
@@ -73,10 +79,10 @@ describe('Conversion', function() {
// TODO ALL TESTS FAIL - Decide on tolerance!
it('should convert ' + cols[0] + ' to 900913', function(){
- assert.deepEqual(sm.convert(cols[1], '900913'), cols[2]);
+ assert.equalBounds(sm.convert(cols[1], '900913'), cols[2]);
});
it('should convert ' + cols[0] + ' to WGS84', function(){
- assert.deepEqual(sm.convert(cols[2], 'WGS84'), cols[1]);
+ assert.equalBounds(sm.convert(cols[2], 'WGS84'), cols[1]);
});
});
});

0 comments on commit a6474b6

Please sign in to comment.
Something went wrong with that request. Please try again.