From 2d665f2625bdee531bd92531e4feb1600859f766 Mon Sep 17 00:00:00 2001 From: Marc Seeger Date: Sun, 6 Nov 2011 15:38:46 +0100 Subject: [PATCH] Make tests/code compatibile with ruby 1.9.3 --- lib/gpx/magellan_track_log.rb | 4 ++-- tests/segment_test.rb | 18 +++++++++--------- tests/track_test.rb | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/gpx/magellan_track_log.rb b/lib/gpx/magellan_track_log.rb index e2fa052..3d3c28a 100644 --- a/lib/gpx/magellan_track_log.rb +++ b/lib/gpx/magellan_track_log.rb @@ -60,11 +60,11 @@ module GPX # Takes the name of a magellan file, converts the contents to GPX, and # writes the result to gpx_filename. - def convert_to_gpx(magellan_filename, gpx_filename) + def convert_to_gpx(magellan_filename, gpx_filename) segment = Segment.new - CSV.open(magellan_filename, "r") do |row| + CSV.open(magellan_filename, "r").each do |row| next if(row.size < 10 or row[INVALID_FLAG] == 'V') lat_deg = row[LAT][0..1] diff --git a/tests/segment_test.rb b/tests/segment_test.rb index 34a4362..74d838c 100644 --- a/tests/segment_test.rb +++ b/tests/segment_test.rb @@ -12,11 +12,11 @@ class SegmentTest < Test::Unit::TestCase def test_segment_read assert_equal(189, @segment.points.size) - assert_equal("Fri Apr 07 18:12:05 UTC 2006", @segment.earliest_point.time.to_s) - assert_equal("Fri Apr 07 19:26:31 UTC 2006", @segment.latest_point.time.to_s) + assert_equal(1144433525, @segment.earliest_point.time.to_i) + assert_equal(1144437991, @segment.latest_point.time.to_i) assert_equal(1334.447, @segment.lowest_point.elevation) assert_equal(1480.087, @segment.highest_point.elevation) - assert_equal("6.98803359528853", @segment.distance.to_s) + assert_in_delta(6.98803359528853, @segment.distance, 0.001) end def test_segment_crop @@ -27,9 +27,9 @@ class SegmentTest < Test::Unit::TestCase @segment.crop(crop_rectangle) assert_equal(106, @segment.points.size) - assert_equal("4.11422061733046", @segment.distance.to_s) - assert_equal("Fri Apr 07 18:37:21 UTC 2006", @segment.earliest_point.time.to_s) - assert_equal("Fri Apr 07 19:22:32 UTC 2006", @segment.latest_point.time.to_s) + assert_in_delta(4.11422061733046, @segment.distance, 0.001) + assert_equal(1144435041, @segment.earliest_point.time.to_i) + assert_equal(1144437752, @segment.latest_point.time.to_i) assert_equal(1407.027, @segment.lowest_point.elevation) assert_equal(1480.087, @segment.highest_point.elevation) assert_equal(39.173834, @segment.bounds.min_lat) @@ -45,9 +45,9 @@ class SegmentTest < Test::Unit::TestCase :max_lon=> -108.999000) @segment.delete_area(delete_rectangle) assert_equal(83, @segment.points.size) - assert_equal("3.35967118153605", @segment.distance.to_s) - assert_equal("Fri Apr 07 18:12:05 UTC 2006", @segment.earliest_point.time.to_s) - assert_equal("Fri Apr 07 19:26:31 UTC 2006", @segment.latest_point.time.to_s) + assert_in_delta(3.35967118153605, @segment.distance, 0.001) + assert_equal(1144433525, @segment.earliest_point.time.to_i) + assert_equal(1144437991, @segment.latest_point.time.to_i) assert_equal(1334.447, @segment.lowest_point.elevation) assert_equal(1428.176, @segment.highest_point.elevation) assert_equal(39.180572, @segment.bounds.min_lat) diff --git a/tests/track_test.rb b/tests/track_test.rb index 3744976..5afbf87 100644 --- a/tests/track_test.rb +++ b/tests/track_test.rb @@ -13,7 +13,7 @@ class TrackTest < Test::Unit::TestCase assert_equal("ACTIVE LOG", @track.name) assert_equal( 182, @track.points.size) assert_equal(8, @track.segments.size) - assert_equal("3.07249668492626", @track.distance.to_s) + assert_in_delta(3.07249668492626, @track.distance, 0.001) assert_equal(1267.155, @track.lowest_point.elevation) assert_equal(1594.003, @track.highest_point.elevation) assert_equal(38.681488, @track.bounds.min_lat) @@ -32,7 +32,7 @@ class TrackTest < Test::Unit::TestCase assert_equal("ACTIVE LOG", @track.name) assert_equal( 111, @track.points.size) assert_equal(4, @track.segments.size) - assert_equal("1.62136024923607", @track.distance.to_s) + assert_in_delta(1.62136024923607, @track.distance, 0.001) assert_equal(1557.954, @track.lowest_point.elevation) assert_equal(1582.468, @track.highest_point.elevation) assert_equal(38.782511, @track.bounds.min_lat)