-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpx_test.go
134 lines (125 loc) · 4.17 KB
/
gpx_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//
// gpx_test.go
// GPXutils
//
// Created by Mario Martelli on 13.10.2019
// Copyright © 2019 Mario Martelli. All rights reserved.
//
// This file is part of GPXutils
//
// EverOrg is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// EverOrg is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with EverOrg. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"encoding/xml"
"testing"
)
const xmlTrack string = `
<trk>
<name>Bonn ---- Radfahren</name>
<desc>tescht</desc>
<trkseg>
<trkpt lat="50.83326700" lon="7.13071600">
<ele>85.7</ele>
<time>2011-04-09T06:03:40Z</time>
<extensions>
<gpxdata:hr>0</gpxdata:hr>
<gpxdata:cadence>1</gpxdata:cadence>
</extensions>
</trkpt>
<trkpt lat="50.83318700" lon="7.13064500">
<ele>86.2</ele>
<time>2011-04-09T06:03:46Z</time>
<extensions>
<gpxdata:hr>0</gpxdata:hr>
<gpxdata:cadence>9</gpxdata:cadence>
</extensions>
</trkpt>
<trkpt lat="50.83307600" lon="7.13060100">
<ele>80.9</ele>
<time>2011-04-09T06:03:51Z</time>
<extensions>
<gpxdata:hr>0</gpxdata:hr>
<gpxdata:cadence>0</gpxdata:cadence>
</extensions>
</trkpt>
<trkpt lat="50.83304600" lon="7.13059300">
<ele>85.7</ele>
<time>2011-04-09T06:03:52Z</time>
<extensions>
<gpxdata:hr>0</gpxdata:hr>
<gpxdata:cadence>0</gpxdata:cadence>
</extensions>
</trkpt>
</trkseg>
</trk>
`
func TestGetTimstamp(t *testing.T) {
var track Track
_ = xml.Unmarshal([]byte(xmlTrack), &track)
if track.getTimestamp() != "2011-04-09T06-03-40Z" {
t.Error("Expected 2011-04-09T06-03-40Z and got ", track.getTimestamp())
}
}
func TestGpx(t *testing.T) {
var track Track
_ = xml.Unmarshal([]byte(xmlTrack), &track)
if track.gpx() != `<?xml version="1.0" encoding="UTF-8" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1"
version="1.1"
creator="rubiTrack - https://www.rubitrack.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.cluetrust.com/XML/GPXDATA/1/0 http://www.cluetrust.com/Schemas/gpxdata10.xsd"> <trk>
<name>Bonn ---- Radfahren</name>
<desc>tescht</desc>
<trkseg>
<trkpt lat="50.83326700" lon="7.13071600">
<ele>85.7</ele>
<time>2011-04-09T06:03:40Z</time>
<extensions>
<gpxdata:hr>0</gpxdata:hr>
<gpxdata:cadence>1</gpxdata:cadence>
</extensions>
</trkpt>
<trkpt lat="50.83318700" lon="7.13064500">
<ele>86.2</ele>
<time>2011-04-09T06:03:46Z</time>
<extensions>
<gpxdata:hr>0</gpxdata:hr>
<gpxdata:cadence>9</gpxdata:cadence>
</extensions>
</trkpt>
<trkpt lat="50.83307600" lon="7.13060100">
<ele>80.9</ele>
<time>2011-04-09T06:03:51Z</time>
<extensions>
<gpxdata:hr>0</gpxdata:hr>
<gpxdata:cadence>0</gpxdata:cadence>
</extensions>
</trkpt>
<trkpt lat="50.83304600" lon="7.13059300">
<ele>85.7</ele>
<time>2011-04-09T06:03:52Z</time>
<extensions>
<gpxdata:hr>0</gpxdata:hr>
<gpxdata:cadence>0</gpxdata:cadence>
</extensions>
</trkpt>
</trkseg>
</trk>
</gpx>
` {
t.Error("track.gpx gave faulty return")
}
}