Skip to content

Commit

Permalink
Added test for iterator size hint
Browse files Browse the repository at this point in the history
  • Loading branch information
cry-inc committed Sep 3, 2023
1 parent 237a579 commit f97482e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/reader_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use e57::{CartesianCoordinate, E57Reader, RawValues, RecordName, RecordValue};
use e57::{CartesianCoordinate, E57Reader, Point, RawValues, RecordName, RecordValue, Result};
use std::fs::File;

#[test]
Expand Down Expand Up @@ -211,3 +211,25 @@ fn simple_iterator() {
}
assert_eq!(counter, pc.records);
}

#[test]
fn iterator_size_hint() {
let file = "testdata/tinyCartesianFloatRgb.e57";
let mut reader = E57Reader::from_file(file).unwrap();
let pcs = reader.pointclouds();
let pc = pcs.first().unwrap();
let mut iter = reader.pointcloud_simple(pc).unwrap();

// Hint at the beginning returns all points
let hint = iter.size_hint();
assert_eq!(hint, (2090, Some(2090)));

// Hint is correctly updated after we consumed one point
iter.next().unwrap().unwrap();
let hint = iter.size_hint();
assert_eq!(hint, (2089, Some(2089)));

// Reading everything returns the predicted point count
let points: Result<Vec<Point>> = iter.collect();
assert_eq!(points.unwrap().len(), 2089);
}

0 comments on commit f97482e

Please sign in to comment.