iterators

This commit is contained in:
daniel
2020-04-16 15:00:20 +02:00
parent 28a08a1401
commit ceb09f6371
3 changed files with 196 additions and 2 deletions

32
tests/integration.rs Normal file
View File

@@ -0,0 +1,32 @@
#[cfg(test)]
mod integration {
use std::rc::Rc;
use xdrfile::*;
use std::path::Path;
#[test]
fn test_use_library() {
let path = Path::new("tests/1l2y.xtc");
let mut trj = XTCTrajectory::open(path, FileMode::Read).unwrap();
let num_atoms = trj.get_num_atoms().unwrap();
let mut frame = Frame::with_capacity(num_atoms);
trj.read(&mut frame).unwrap();
trj.read(&mut frame).unwrap();
assert_eq!(frame.step, 2);
}
#[test]
fn test_use_library_iterator() {
let path = Path::new("tests/1l2y.xtc");
let trj = XTCTrajectory::open(path, FileMode::Read).unwrap();
let frames: Vec<Rc<Frame>> = trj.into_iter().filter_map(Result::ok).collect();
for (idx, frame) in frames.iter().enumerate() {
assert_eq!(frame.step as usize, idx+1);
}
}
}