test/calculations_test.rb in geocoder-1.1.2 vs test/calculations_test.rb in geocoder-1.1.3
- old
+ new
@@ -150,33 +150,39 @@
assert_equal l.bearing_from([50,-86.1]), l.bearing_to([50,-86.1]) - 180
end
def test_extract_coordinates
result = Geocoder::Calculations.extract_coordinates([ nil, nil ])
- assert_equal [ Geocoder::Calculations::NAN ] * 2, result
+ assert is_nan_coordinates?(result)
result = Geocoder::Calculations.extract_coordinates([ 1.0 / 3, 2.0 / 3 ])
assert_in_delta 1.0 / 3, result.first, 1E-5
assert_in_delta 2.0 / 3, result.last, 1E-5
result = Geocoder::Calculations.extract_coordinates(nil)
- assert_equal [ Geocoder::Calculations::NAN ] * 2, result
+ assert is_nan_coordinates?(result)
result = Geocoder::Calculations.extract_coordinates('')
- assert_equal [ Geocoder::Calculations::NAN ] * 2, result
+ assert is_nan_coordinates?(result)
result = Geocoder::Calculations.extract_coordinates([ 'nix' ])
- assert_equal [ Geocoder::Calculations::NAN ] * 2, result
+ assert is_nan_coordinates?(result)
o = Object.new
result = Geocoder::Calculations.extract_coordinates(o)
- assert_equal [ Geocoder::Calculations::NAN ] * 2, result
+ assert is_nan_coordinates?(result)
def o.to_coordinates
[ 1.0 / 3, 2.0 / 3 ]
end
result = Geocoder::Calculations.extract_coordinates(o)
assert_in_delta 1.0 / 3, result.first, 1E-5
assert_in_delta 2.0 / 3, result.last, 1E-5
end
-end
+ def test_coordinates_present
+ assert Geocoder::Calculations.coordinates_present?(3.23)
+ assert !Geocoder::Calculations.coordinates_present?(nil)
+ assert !Geocoder::Calculations.coordinates_present?(Geocoder::Calculations::NAN)
+ assert !Geocoder::Calculations.coordinates_present?(3.23, nil)
+ end
+end