This commit is contained in:
vcoppe committed 2026-10-03 20:54:05 +02:00
1 parent 9afba53e5d
commit f1904bc12f
17 files changed
+222 -310

No files matched your search

+6 -5
View File
@@ -2,7 +2,7 @@ use uuid::Uuid;
use crate::{Trackpoint, Waypoint};
static MAX_TRKPT_CHUNK_SIZE: usize = 4096;
const MAX_TRKPT_CHUNK_SIZE: usize = 4096;
#[derive(Debug, PartialEq, Eq)]
pub struct TrackpointChunkId(Uuid);
@@ -40,7 +40,7 @@ impl Default for WaypointChunkId {
}
}
static MAX_WPT_CHUNK_SIZE: usize = 128;
const MAX_WPT_CHUNK_SIZE: usize = 128;
#[derive(Debug, Default)]
pub struct WaypointChunk {
@@ -91,9 +91,10 @@ mod tests {
let a = TrackpointChunk::default();
let b = TrackpointChunk::default();
assert_ne!(a, b);
let mut c = TrackpointChunk::default();
c.id = TrackpointChunkId(a.id.0);
c.trkpt.push(Trackpoint::default());
let c = TrackpointChunk {
id: TrackpointChunkId(a.id.0),
trkpt: vec![Trackpoint::default()],
};
assert_eq!(a, c);
}
}
+11 -7
View File
@@ -109,6 +109,10 @@ impl TrackSegment {
self.cumul_length.last().copied().unwrap_or_default()
}
pub fn is_empty(&self) -> bool {
self.chunks.is_empty()
}
pub fn iter(&self) -> TrackSegmentIterator<'_> {
TrackSegmentIterator::new(self)
}
@@ -248,9 +252,10 @@ mod tests {
for n in 1..=nb_chunks {
let mut chunk = TrackpointChunk::default();
for _ in 0..n {
let mut trkpt = Trackpoint::default();
trkpt.ele = count as f64;
chunk.trkpt.push(trkpt);
chunk.trkpt.push(Trackpoint {
ele: count as f64,
..Default::default()
});
count += 1;
}
trkseg.push(chunk);
@@ -367,7 +372,7 @@ mod tests {
fn test_index_out_of_bounds_1() {
let nb_chunks = 10;
let trkseg = create_track_segment(nb_chunks);
trkseg[trkseg.len()].ele;
let _ = trkseg[trkseg.len()];
}
#[test]
@@ -375,12 +380,11 @@ mod tests {
fn test_index_out_of_bounds_2() {
let nb_chunks = 10;
let trkseg = create_track_segment(nb_chunks);
trkseg[TrackSegmentIndex {
let _ = trkseg[TrackSegmentIndex {
chunk: trkseg.chunks.len(),
pos: 0,
flat: 0,
}]
.ele;
}];
}
#[test]