From 4b3d20e409c6f7f9d40baa74148a6b3034f56ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Fri, 16 May 2014 16:20:34 +0200 Subject: [PATCH] test/geo-point: relax too precise assertions Relax the assertions to verify only the integer part of the distances. The decimal part is subject to small variances depending on the exact implementation of floating-point arithmetic. For example, the distance calculated on Node v0.11.13 is different than the distance calculated on Node v0.10.x. --- test/geo-point.test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/geo-point.test.js b/test/geo-point.test.js index 2f3da597..bc84f717 100644 --- a/test/geo-point.test.js +++ b/test/geo-point.test.js @@ -3,8 +3,9 @@ describe('GeoPoint', function() { it("Get the distance to another `GeoPoint`", function() { var here = new GeoPoint({lat: 10, lng: 10}); var there = new GeoPoint({lat: 5, lng: 5}); - - assert.equal(here.distanceTo(there, {type: 'meters'}), 782777.923052584); + var distance = here.distanceTo(there, {type: 'meters'}); + + assert.equal(Math.floor(distance), 782777); }); }); @@ -12,8 +13,9 @@ describe('GeoPoint', function() { it("Get the distance between two points", function() { var here = new GeoPoint({lat: 10, lng: 10}); var there = new GeoPoint({lat: 5, lng: 5}); + var distance = GeoPoint.distanceBetween(here, there, {type: 'feet'}); - assert.equal(GeoPoint.distanceBetween(here, there, {type: 'feet'}), 2568169.038886431); + assert.equal(Math.floor(distance), 2568169); }); });