Sha256: 3db192674500d52f626217336d9e942b1adf5896450f10b506d1fede1f1b8500

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require_relative '../../lib/geo_swap/zone'

module GeoSwap
  describe Zone do


    describe 'finding number from lat long' do


      ZONE_DATA = [
        { long: -180.0, zone_number: 1 },
        { long: -147.0, zone_number: 6 },
        { long: -139.0, zone_number: 7 },
        { long: 0.0, zone_number: 31 },
        { long: 62.0, zone_number: 41 },
        { long: 71.0, zone_number: 42 },
        { long: 110.0, zone_number: 49 },
        { long: 141.0, zone_number: 54 },
        { long: 180.0, zone_number: 60 },
      ]

      it 'applys the zone formula correctly' do
        ZONE_DATA.each do |data|
          Zone.new(0, data[:long]).number.should == data[:zone_number]
        end
      end

    end

    describe 'determining the zone origin' do
      it 'can migrate from too far left' do
        Zone.new(0, -180).origin.should == -177
      end

      it 'can migrate from too far right' do
        Zone.new(0, 180).origin.should == 177
      end

      it 'doesnt change the value when the long is already the origin' do
        Zone.new(0, 3).origin.should == 3
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
geo_swap-0.2.1 spec/geo_swap/zone_spec.rb
geo_swap-0.2.0 spec/geo_swap/zone_spec.rb