test/unit/graticule/location_test.rb in graticule-0.1.1 vs test/unit/graticule/location_test.rb in graticule-0.1.2
- old
+ new
@@ -32,7 +32,20 @@
assert_not_equal Location.new, Location.new(k => v)
assert_not_equal Location.new(attrs), Location.new(attrs.update(k => nil))
end
end
+ def test_antipode
+ washington_dc = Location.new(:latitude => 38.898748, :longitude => -77.037684)
+ chicago = Location.new(:latitude => 41.85, :longitude => -87.65)
+
+ assert_equal [-38.898748, 102.962316], washington_dc.antipode.coordinates
+ assert_equal [-41.85, 92.35], chicago.antipode.coordinates
+ assert_equal [-41, -180], Graticule::Location.new(:latitude => 41, :longitude => 0).antipode.coordinates
+ assert_equal [-41, 179], Graticule::Location.new(:latitude => 41, :longitude => -1).antipode.coordinates
+ assert_equal [-41, -179], Graticule::Location.new(:latitude => 41, :longitude => 1).antipode.coordinates
+
+ assert_equal washington_dc.coordinates, washington_dc.antipode.antipode.coordinates
+ assert_equal chicago.coordinates, chicago.antipode.antipode.coordinates
+ end
end
end
\ No newline at end of file