Updating unit tests in light of recent fixes to routes and waypoints code.
parent
8df3cb1ea3
commit
75d24706f4
|
@ -1,7 +1,7 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require File.dirname(__FILE__) + '/../lib/gpx'
|
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")
|
GPX_FILE = File.join(File.dirname(__FILE__), "gpx_files/gpx10.gpx")
|
||||||
|
|
||||||
def test_read
|
def test_read
|
||||||
|
|
|
@ -1 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Link2GPS - 2.0.2 - http://www.hiketech.com" xsi:schemaLocation="ttp://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"><metadata><name><![CDATA[routes.gpx]]></name><time>2006-01-02T08:55:34Z</time><bounds min_lat="39.989739" min_lon="-105.295285" max_lat="39.999840" max_lon="-105.214696"/></metadata><extensions/><rte><name><![CDATA[GRG-CA-TO]]></name><rtept lat="39.997298" lon="-105.292674"><name><![CDATA[GRG-CA]]></name><sym>Waypoint</sym><ele>1766.535</ele></rtept><rtept lat="39.995700" lon="-105.292805"><name><![CDATA[AMPTHT]]></name><sym>Waypoint</sym><ele>1854.735</ele></rtept><rtept lat="39.989739" lon="-105.295285"><name><![CDATA[TO]]></name><sym>Waypoint</sym><ele>2163.556</ele></rtept></rte><rte><name><![CDATA[SBDR-SBDR]]></name><rtept lat="39.999840" lon="-105.214696"><name><![CDATA[SBDR]]></name><sym>Waypoint</sym><ele>1612.965</ele></rtept></rte></gpx>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Link2GPS - 2.0.2 - http://www.hiketech.com" xsi:schemaLocation="ttp://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"><metadata><name><![CDATA[routes.gpx]]></name><time>2006-01-02T08:55:34Z</time><bounds min_lat="39.989739" min_lon="-105.295285" max_lat="39.999840" max_lon="-105.214696"/></metadata><extensions/>
|
||||||
|
<rte><name><![CDATA[GRG-CA-TO]]></name>
|
||||||
|
<rtept lat="39.997298" lon="-105.292674"><name><![CDATA[GRG-CA]]></name><sym>Waypoint</sym><ele>1766.535</ele></rtept>
|
||||||
|
<rtept lat="39.995700" lon="-105.292805"><name><![CDATA[AMPTHT]]></name><sym>Waypoint</sym><ele>1854.735</ele></rtept>
|
||||||
|
<rtept lat="39.989739" lon="-105.295285"><name><![CDATA[TO]]></name><sym>Waypoint</sym><ele>2163.556</ele></rtept></rte>
|
||||||
|
<rte><name><![CDATA[SBDR-SBDR]]></name>
|
||||||
|
<rtept lat="39.999840" lon="-105.214696"><name><![CDATA[SBDR]]></name><sym>Waypoint</sym><ele>1612.965</ele></rtept></rte>
|
||||||
|
</gpx>
|
|
@ -1 +1,20 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Link2GPS - 2.0.2 - http://www.hiketech.com" xsi:schemaLocation="ttp://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"><metadata><name><![CDATA[waypoints.gpx]]></name><time>2006-01-02T08:55:21Z</time><bounds min_lat="25.061783" min_lon="-111.946110" max_lat="50.982883" max_lon="121.640267"/></metadata><extensions/><wpt lat="40.035557" lon="-105.248268"><name><![CDATA[001]]></name><sym>Waypoint</sym><ele>1639.161</ele></wpt><wpt lat="39.993070" lon="-105.296588"><name><![CDATA[002]]></name><sym>Waypoint</sym><ele>1955.192</ele></wpt><wpt lat="39.990151" lon="-105.295680"><name><![CDATA[003]]></name><sym>Waypoint</sym><ele>2129.91</ele></wpt><wpt lat="39.990157" lon="-105.295686"><name><![CDATA[004]]></name><sym>Waypoint</sym><ele>2136.399</ele></wpt><wpt lat="39.990134" lon="-105.295251"><name><![CDATA[005]]></name><sym>Waypoint</sym><ele>2174.612</ele></wpt><wpt lat="39.990116" lon="-105.295147"><name><![CDATA[006]]></name><sym>Waypoint</sym><ele>2156.106</ele></wpt><wpt lat="39.990099" lon="-105.295207"><name><![CDATA[007]]></name><sym>Waypoint</sym><ele>2155.145</ele></wpt><wpt lat="39.990067" lon="-105.295185"><name><![CDATA[008]]></name><sym>Waypoint</sym><ele>2152.021</ele></wpt><wpt lat="39.995700" lon="-105.292805"><name><![CDATA[AMPTHT]]></name><sym>Waypoint</sym><ele>1854.735</ele></wpt><wpt lat="38.855550" lon="-94.799017"><name><![CDATA[GARMIN]]></name><sym>Waypoint</sym><ele>325.0491</ele></wpt><wpt lat="39.997298" lon="-105.292674"><name><![CDATA[GRG-CA]]></name><sym>Waypoint</sym><ele>1766.535</ele></wpt><wpt lat="50.982883" lon="-1.463900"><name><![CDATA[GRMEUR]]></name><sym>Waypoint</sym><ele>35.93469</ele></wpt><wpt lat="33.330190" lon="-111.946110"><name><![CDATA[GRMPHX]]></name><sym>Waypoint</sym><ele>361.0981</ele></wpt><wpt lat="25.061783" lon="121.640267"><name><![CDATA[GRMTWN]]></name><sym>Waypoint</sym><ele>38.09766</ele></wpt><wpt lat="39.999840" lon="-105.214696"><name><![CDATA[SBDR]]></name><sym>Waypoint</sym><ele>1612.965</ele></wpt><wpt lat="39.989739" lon="-105.295285"><name><![CDATA[TO]]></name><sym>Waypoint</sym><ele>2163.556</ele></wpt><wpt lat="40.035301" lon="-105.254443"><name><![CDATA[VICS]]></name><sym>Waypoint</sym><ele>1535.34</ele></wpt></gpx>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="Link2GPS - 2.0.2 - http://www.hiketech.com" xsi:schemaLocation="ttp://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"><metadata><name><![CDATA[waypoints.gpx]]></name><time>2006-01-02T08:55:21Z</time><bounds min_lat="25.061783" min_lon="-111.946110" max_lat="50.982883" max_lon="121.640267"/></metadata><extensions/>
|
||||||
|
<wpt lat="40.035557" lon="-105.248268"><name><![CDATA[001]]></name><sym>Waypoint</sym><ele>1639.161</ele><cmt><![CDATA[001]]></cmt><desc><![CDATA[Just some waypoint...]]></desc></wpt>
|
||||||
|
<wpt lat="39.993070" lon="-105.296588"><name><![CDATA[002]]></name><sym>Waypoint</sym><ele>1955.192</ele></wpt>
|
||||||
|
<wpt lat="39.990151" lon="-105.295680"><name><![CDATA[003]]></name><sym>Waypoint</sym><ele>2129.91</ele></wpt>
|
||||||
|
<wpt lat="39.990157" lon="-105.295686"><name><![CDATA[004]]></name><sym>Waypoint</sym><ele>2136.399</ele></wpt>
|
||||||
|
<wpt lat="39.990134" lon="-105.295251"><name><![CDATA[005]]></name><sym>Waypoint</sym><ele>2174.612</ele></wpt>
|
||||||
|
<wpt lat="39.990116" lon="-105.295147"><name><![CDATA[006]]></name><sym>Waypoint</sym><ele>2156.106</ele></wpt>
|
||||||
|
<wpt lat="39.990099" lon="-105.295207"><name><![CDATA[007]]></name><sym>Waypoint</sym><ele>2155.145</ele></wpt>
|
||||||
|
<wpt lat="39.990067" lon="-105.295185"><name><![CDATA[008]]></name><sym>Waypoint</sym><ele>2152.021</ele></wpt>
|
||||||
|
<wpt lat="39.995700" lon="-105.292805"><name><![CDATA[AMPTHT]]></name><sym>Waypoint</sym><ele>1854.735</ele></wpt>
|
||||||
|
<wpt lat="38.855550" lon="-94.799017"><name><![CDATA[GARMIN]]></name><sym>Waypoint</sym><ele>325.0491</ele></wpt>
|
||||||
|
<wpt lat="39.997298" lon="-105.292674"><name><![CDATA[GRG-CA]]></name><sym>Waypoint</sym><ele>1766.535</ele></wpt>
|
||||||
|
<wpt lat="50.982883" lon="-1.463900"><name><![CDATA[GRMEUR]]></name><sym>Waypoint</sym><ele>35.93469</ele></wpt>
|
||||||
|
<wpt lat="33.330190" lon="-111.946110"><name><![CDATA[GRMPHX]]></name><sym>Waypoint</sym><ele>361.0981</ele></wpt>
|
||||||
|
<wpt lat="25.061783" lon="121.640267"><name><![CDATA[GRMTWN]]></name><sym>Waypoint</sym><ele>38.09766</ele></wpt>
|
||||||
|
<wpt lat="39.999840" lon="-105.214696"><name><![CDATA[SBDR]]></name><sym>Waypoint</sym><ele>1612.965</ele></wpt>
|
||||||
|
<wpt lat="39.989739" lon="-105.295285"><name><![CDATA[TO]]></name><sym>Waypoint</sym><ele>2163.556</ele></wpt>
|
||||||
|
<wpt lat="40.035301" lon="-105.254443"><name><![CDATA[VICS]]></name><sym>Waypoint</sym><ele>1535.34</ele></wpt>
|
||||||
|
</gpx>
|
|
@ -1,7 +1,7 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require File.dirname(__FILE__) + '/../lib/gpx'
|
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")
|
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")
|
GPX_FILE = File.join(File.dirname(__FILE__), "gpx_files/one_segment.gpx")
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
# <rtept lat="39.997298" lon="-105.292674">
|
||||||
|
# <name><![CDATA[GRG-CA]]></name>
|
||||||
|
# <sym>Waypoint</sym>
|
||||||
|
# <ele>1766.535</ele>
|
||||||
|
# </rtept>
|
||||||
|
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
|
||||||
|
# <rtept lat="39.995700" lon="-105.292805">
|
||||||
|
# <name><![CDATA[AMPTHT]]></name>
|
||||||
|
# <sym>Waypoint</sym>
|
||||||
|
# <ele>1854.735</ele>
|
||||||
|
# </rtept>
|
||||||
|
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
|
||||||
|
# <rtept lat="39.989739" lon="-105.295285">
|
||||||
|
# <name><![CDATA[TO]]></name>
|
||||||
|
# <sym>Waypoint</sym>
|
||||||
|
# <ele>2163.556</ele>
|
||||||
|
# </rtept>
|
||||||
|
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
|
||||||
|
# <rtept lat="39.999840" lon="-105.214696">
|
||||||
|
# <name><![CDATA[SBDR]]></name>
|
||||||
|
# <sym>Waypoint</sym>
|
||||||
|
# <ele>1612.965</ele>
|
||||||
|
# </rtept>
|
||||||
|
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
|
|
@ -2,7 +2,7 @@ require 'test/unit'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require File.dirname(__FILE__) + '/../lib/gpx'
|
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")
|
ONE_SEGMENT = File.join(File.dirname(__FILE__), "gpx_files/one_segment.gpx")
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require File.dirname(__FILE__) + '/../lib/gpx'
|
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")
|
TRACK_FILE = File.join(File.dirname(__FILE__), "gpx_files/tracks.gpx")
|
||||||
OTHER_TRACK_FILE = File.join(File.dirname(__FILE__), "gpx_files/arches.gpx")
|
OTHER_TRACK_FILE = File.join(File.dirname(__FILE__), "gpx_files/arches.gpx")
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require File.dirname(__FILE__) + '/../lib/gpx'
|
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")
|
ONE_TRACK = File.join(File.dirname(__FILE__), "gpx_files/one_track.gpx")
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
|
|
@ -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
|
||||||
|
# <wpt lat="40.035557" lon="-105.248268">
|
||||||
|
# <name><![CDATA[001]]></name>
|
||||||
|
# <sym>Waypoint</sym>
|
||||||
|
# <ele>1639.161</ele>
|
||||||
|
# <cmt><![CDATA[001]]></cmt>
|
||||||
|
# <desc><![CDATA[Just some waypoint...]]></desc>
|
||||||
|
# </wpt>
|
||||||
|
|
||||||
|
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
|
||||||
|
# <wpt lat="39.993070" lon="-105.296588">
|
||||||
|
# <name><![CDATA[002]]></name>
|
||||||
|
# <sym>Waypoint</sym>
|
||||||
|
# <ele>1955.192</ele>
|
||||||
|
# </wpt>
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue