Skip to content

Commit 92c6a0d

Browse files
committed
GpxListWriterTest: simulate growing list
1 parent 118e178 commit 92c6a0d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

aat-lib/src/test/kotlin/ch/bailu/aat_lib/file/xml/writer/GpxListWriterTest.kt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package ch.bailu.aat_lib.file.xml.writer
22

33
import ch.bailu.aat_lib.file.xml.parser.gpx.GpxListReaderXml
4+
import ch.bailu.aat_lib.gpx.GpxList
5+
import ch.bailu.aat_lib.gpx.GpxListIterator
46
import ch.bailu.aat_lib.gpx.attributes.AutoPause
7+
import ch.bailu.aat_lib.gpx.attributes.GpxListAttributes
8+
import ch.bailu.aat_lib.gpx.interfaces.GpxType
59
import ch.bailu.aat_lib.mock.MockAppConfig
610
import ch.bailu.aat_lib.mock.MockFoc
711
import ch.bailu.foc_extended.FocResource
@@ -16,12 +20,27 @@ class GpxListWriterTest {
1620
MockAppConfig.init()
1721

1822
val mockFoc = MockFoc("only-in-memory.gpx")
19-
2023
val reader = GpxListReaderXml(FocResource("test.gpx"), AutoPause.NULL)
24+
2125
assertEquals(1855, reader.gpxList.pointList.size())
2226

27+
val gpxList = GpxList(GpxType.TRACK, GpxListAttributes.NULL)
28+
2329
// Write and then close file
24-
GpxListWriter(reader.gpxList, mockFoc).use { }
30+
GpxListWriter(gpxList, mockFoc).use {
31+
val gpxListIterator = GpxListIterator(reader.gpxList)
32+
33+
while (gpxListIterator.nextPoint()) {
34+
val point = gpxListIterator.getPoint()
35+
36+
if (gpxListIterator.isFirstInSegment) {
37+
gpxList.appendToNewSegment(point.point, point.getAttributes())
38+
} else {
39+
gpxList.appendToCurrentSegment(point.point, point.getAttributes())
40+
}
41+
it.writeNewPoints()
42+
}
43+
}
2544

2645
val linesWritten = mockFoc.getLines()
2746

0 commit comments

Comments
 (0)