Sha256: e9dcc2d29dbfe0c20a1cee0040f88a61dc0c7490082c8b22a1aac23bb52a7dd7
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 KB
Contents
require "minitest/autorun" require "national_grid" module NationalGrid class EastingNorthingTest < Minitest::Test def test_initialize_with_defaults point = EastingNorthing.new assert_equal 0, point.easting assert_equal 0, point.northing assert_equal 0, point.elevation end def test_initialize_with_easting_and_northing point = EastingNorthing.new(12345.6, 78901.2) assert_equal 12345.6, point.easting assert_equal 78901.2, point.northing assert_equal 0, point.elevation end def test_initialize_with_easting_northing_and_elevation point = EastingNorthing.new(12345.6, 78901.2, 345.6) assert_equal 12345.6, point.easting assert_equal 78901.2, point.northing assert_equal 345.6, point.elevation end def test_inspect assert_match /^#<NationalGrid::EastingNorthing:0x\h+ easting=12345.678 northing=90123.456 elevation=789.012>$/, EastingNorthing.new(12345.6779, 90123.4559, 789.0119).inspect end def test_to_a assert_equal [12345.6, 78901.2, 345.6], EastingNorthing.new(12345.6, 78901.2, 345.6).to_a end def test_to_latitude_longitude assert_close LatitudeLongitude.new(51.427547, -2.544076, 104.018), EastingNorthing.new(362269.979, 169978.688, 54.467).to_latitude_longitude end def test_to_latitude_longitude_when_outside_the_grid assert_nil EastingNorthing.new(999999.999, 999999.999, 99.999).to_latitude_longitude end def test_round point = EastingNorthing.new(12.3456, 78.9012, 34.5678).round(3) assert_equal 12.346, point.easting assert_equal 78.901, point.northing assert_equal 34.568, point.elevation end private def assert_close(expected, actual) assert_in_delta expected.latitude, actual.latitude, 0.5e-6 assert_in_delta expected.longitude, actual.longitude, 0.5e-6 assert_in_delta expected.elevation, actual.elevation, 0.5e-3 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
national_grid-0.2.0 | test/national_grid/easting_northing_test.rb |