Sha256: 1920dadc956f9864d232a51bd2b2eb7b34c78ccb5cae61a70275d05806217dc1

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 Bytes

Contents

require 'helper'

class TestGeolocation < Test::Unit::TestCase
  def test_lat
    assert_match /[0-9]+/, Faker::Geolocation.lat.to_s
  end

  def test_lng
    assert_match /[0-9]+/, Faker::Geolocation.lng.to_s
  end

  def test_boxed_coords
    coords_list = [
      [[1,1], [3,3]],
      [[12.3455,23.3434], [34.3434,36.34343]],
      [[12.3455,23.3434], [10.3434,6.34343]]
    ]

    coords_list.each do |coords|
      lat_min = [coords[0][0], coords[1][0]].min
      lat_max = [coords[0][0], coords[1][0]].max
      lon_min = [coords[0][1], coords[1][1]].min
      lon_max = [coords[0][1], coords[1][1]].max

      new_coords = Faker::Geolocation.boxed_coords(coords[0], coords[1])

      assert (lat_min..lat_max).include?new_coords[0]
      assert (lon_min..lon_max).include?new_coords[1]
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ffaker-1.21.0 test/test_geolocation.rb
ffaker-1.20.0 test/test_geolocation.rb
ffaker-1.19.0 test/test_geolocation.rb
ffaker-1.18.0 test/test_geolocation.rb
ffaker-1.17.0 test/test_geolocation.rb