]> git.openstreetmap.org Git - rails.git/blobdiff - test/lib/short_link_test.rb
Merge remote-tracking branch 'upstream/pull/4705'
[rails.git] / test / lib / short_link_test.rb
index 9b198ffc7535449ba95d8a5f63ecffc4a4a7ded5..a32e1ac205b14a29e67f2e3d47d9bb203385bb2a 100644 (file)
@@ -1,4 +1,4 @@
-require 'test_helper'
+require "test_helper"
 
 class ShortLinkTest < ActiveSupport::TestCase
   ##
@@ -7,7 +7,7 @@ class ShortLinkTest < ActiveSupport::TestCase
   def test_encode_decode
     cases = []
     1000.times do
-      cases << [180.0 * rand - 90.0, 360.0 * rand - 180.0, (18 * rand).to_i]
+      cases << [(180.0 * rand) - 90.0, (360.0 * rand) - 180.0, (18 * rand).to_i]
     end
 
     cases.each do |lat, lon, zoom|
@@ -18,9 +18,9 @@ class ShortLinkTest < ActiveSupport::TestCase
       # one pixel (i.e: zoom + 8). the sqrt(5) is because each position
       # has an extra bit of accuracy in the lat coordinate, due to the
       # smaller range.
-      distance = Math.sqrt((lat - lat2)**2 + (lon - lon2)**2)
+      distance = Math.sqrt(((lat - lat2)**2) + ((lon - lon2)**2))
       max_distance = 360.0 / (1 << (zoom + 8)) * 0.5 * Math.sqrt(5)
-      assert max_distance > distance, "Maximum expected error exceeded: #{max_distance} <= #{distance} for (#{lat}, #{lon}, #{zoom})."
+      assert_operator max_distance, :>, distance, "Maximum expected error exceeded: #{max_distance} <= #{distance} for (#{lat}, #{lon}, #{zoom})."
     end
   end