From 75d24706f441bac6bf2b95898ba5773f46a5422e Mon Sep 17 00:00:00 2001 From: Doug Fales Date: Mon, 11 Feb 2008 21:13:48 +0000 Subject: [PATCH] Updating unit tests in light of recent fixes to routes and waypoints code. --- tests/gpx10_test.rb | 2 +- tests/gpx_files/routes.gpx | 10 +++++- tests/gpx_files/waypoints.gpx | 21 +++++++++++- tests/magellan_test.rb | 2 +- tests/route_test.rb | 63 +++++++++++++++++++++++++++++++++++ tests/segment_test.rb | 2 +- tests/track_file_test.rb | 2 +- tests/track_test.rb | 2 +- tests/waypoint_test.rb | 44 ++++++++++++++++++++++++ 9 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 tests/route_test.rb create mode 100755 tests/waypoint_test.rb diff --git a/tests/gpx10_test.rb b/tests/gpx10_test.rb index 8a98095..bc8ade8 100644 --- a/tests/gpx10_test.rb +++ b/tests/gpx10_test.rb @@ -1,7 +1,7 @@ require 'test/unit' require File.dirname(__FILE__) + '/../lib/gpx' -class TestGPX10 < Test::Unit::TestCase +class GPX10Test < Test::Unit::TestCase GPX_FILE = File.join(File.dirname(__FILE__), "gpx_files/gpx10.gpx") def test_read diff --git a/tests/gpx_files/routes.gpx b/tests/gpx_files/routes.gpx index d2dd500..235ac28 100644 --- a/tests/gpx_files/routes.gpx +++ b/tests/gpx_files/routes.gpx @@ -1 +1,9 @@ -Waypoint1766.535Waypoint1854.735Waypoint2163.556Waypoint1612.965 \ No newline at end of file + + + +Waypoint1766.535 +Waypoint1854.735 +Waypoint2163.556 + +Waypoint1612.965 + \ No newline at end of file diff --git a/tests/gpx_files/waypoints.gpx b/tests/gpx_files/waypoints.gpx index 60486c9..a021ca4 100644 --- a/tests/gpx_files/waypoints.gpx +++ b/tests/gpx_files/waypoints.gpx @@ -1 +1,20 @@ -Waypoint1639.161Waypoint1955.192Waypoint2129.91Waypoint2136.399Waypoint2174.612Waypoint2156.106Waypoint2155.145Waypoint2152.021Waypoint1854.735Waypoint325.0491Waypoint1766.535Waypoint35.93469Waypoint361.0981Waypoint38.09766Waypoint1612.965Waypoint2163.556Waypoint1535.34 \ No newline at end of file + + +Waypoint1639.161 +Waypoint1955.192 +Waypoint2129.91 +Waypoint2136.399 +Waypoint2174.612 +Waypoint2156.106 +Waypoint2155.145 +Waypoint2152.021 +Waypoint1854.735 +Waypoint325.0491 +Waypoint1766.535 +Waypoint35.93469 +Waypoint361.0981 +Waypoint38.09766 +Waypoint1612.965 +Waypoint2163.556 +Waypoint1535.34 + \ No newline at end of file diff --git a/tests/magellan_test.rb b/tests/magellan_test.rb index ecac714..636f012 100644 --- a/tests/magellan_test.rb +++ b/tests/magellan_test.rb @@ -1,7 +1,7 @@ require 'test/unit' require File.dirname(__FILE__) + '/../lib/gpx' -class TestMagellanTrackLog < Test::Unit::TestCase +class MagellanTest < Test::Unit::TestCase MAGELLAN_TRACK_LOG = File.join(File.dirname(__FILE__), "gpx_files/magellan_track.log") GPX_FILE = File.join(File.dirname(__FILE__), "gpx_files/one_segment.gpx") diff --git a/tests/route_test.rb b/tests/route_test.rb new file mode 100644 index 0000000..e01616b --- /dev/null +++ b/tests/route_test.rb @@ -0,0 +1,63 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../lib/gpx' + +class RouteTest < Test::Unit::TestCase + + def test_read_routes + gpx = GPX::GPXFile.new(:gpx_file => File.join(File.dirname(__FILE__), "gpx_files/routes.gpx")) + assert_equal(2, gpx.routes.size) + first_route = gpx.routes.first + assert_equal(3, first_route.points.size) + assert_equal('GRG-CA-TO', first_route.name) + + +# Route 1, First Point +# +# +# Waypoint +# 1766.535 +# + assert_equal(39.997298, first_route.points[0].lat) + assert_equal(-105.292674, first_route.points[0].lon) + assert_equal(1766.535, first_route.points[0].elevation) + + +# Route 1, Second Point +# +# +# Waypoint +# 1854.735 +# + assert_equal(39.995700, first_route.points[1].lat) + assert_equal(-105.292805, first_route.points[1].lon) + assert_equal(1854.735, first_route.points[1].elevation) + +# Route 1, Third Point +# +# +# Waypoint +# 2163.556 +# + assert_equal(39.989739, first_route.points[2].lat) + assert_equal(-105.295285, first_route.points[2].lon) + assert_equal(2163.556, first_route.points[2].elevation) + + + second_route = gpx.routes[1] + assert_equal(1, second_route.points.size) + assert_equal('SBDR-SBDR', second_route.name) + +# Route 2, Only Point +# +# +# Waypoint +# 1612.965 +# + assert_equal(39.999840, second_route.points[0].lat) + assert_equal(-105.214696, second_route.points[0].lon) + assert_equal(1612.965, second_route.points[0].elevation) + + end + + +end diff --git a/tests/segment_test.rb b/tests/segment_test.rb index a5aaf01..34a4362 100644 --- a/tests/segment_test.rb +++ b/tests/segment_test.rb @@ -2,7 +2,7 @@ require 'test/unit' require 'yaml' require File.dirname(__FILE__) + '/../lib/gpx' -class TestSegment < Test::Unit::TestCase +class SegmentTest < Test::Unit::TestCase ONE_SEGMENT = File.join(File.dirname(__FILE__), "gpx_files/one_segment.gpx") def setup diff --git a/tests/track_file_test.rb b/tests/track_file_test.rb index f5650ab..aa6f72f 100644 --- a/tests/track_file_test.rb +++ b/tests/track_file_test.rb @@ -1,7 +1,7 @@ require 'test/unit' require File.dirname(__FILE__) + '/../lib/gpx' -class TestTrackFile < Test::Unit::TestCase +class TrackFileTest < Test::Unit::TestCase TRACK_FILE = File.join(File.dirname(__FILE__), "gpx_files/tracks.gpx") OTHER_TRACK_FILE = File.join(File.dirname(__FILE__), "gpx_files/arches.gpx") diff --git a/tests/track_test.rb b/tests/track_test.rb index 0c9941f..d9d4229 100644 --- a/tests/track_test.rb +++ b/tests/track_test.rb @@ -1,7 +1,7 @@ require 'test/unit' require File.dirname(__FILE__) + '/../lib/gpx' -class TestTrack < Test::Unit::TestCase +class TrackTest < Test::Unit::TestCase ONE_TRACK = File.join(File.dirname(__FILE__), "gpx_files/one_track.gpx") def setup diff --git a/tests/waypoint_test.rb b/tests/waypoint_test.rb new file mode 100755 index 0000000..13f20da --- /dev/null +++ b/tests/waypoint_test.rb @@ -0,0 +1,44 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../lib/gpx' + +class WaypointTest < Test::Unit::TestCase + + def test_read_waypoints + + gpx = GPX::GPXFile.new(:gpx_file => File.join(File.dirname(__FILE__), "gpx_files/waypoints.gpx")) + assert_equal(17, gpx.waypoints.size) + + # First Waypoint + # + # + # Waypoint + # 1639.161 + # + # + # + + first_wpt = gpx.waypoints[0] + assert_equal(40.035557, first_wpt.lat) + assert_equal(-105.248268, first_wpt.lon) + assert_equal('001', first_wpt.name) + assert_equal('001', first_wpt.cmt) + assert_equal('Just some waypoint...', first_wpt.desc) + assert_equal('Waypoint', first_wpt.sym) + assert_equal(1639.161, first_wpt.elevation) + + # Second Waypoint + # + # + # Waypoint + # 1955.192 + # + second_wpt = gpx.waypoints[1] + assert_equal(39.993070, second_wpt.lat) + assert_equal(-105.296588, second_wpt.lon) + assert_equal('002', second_wpt.name) + assert_equal('Waypoint', second_wpt.sym) + assert_equal(1955.192, second_wpt.elevation) + + end +end +