Skip to content

Commit d55ebc4

Browse files
committed
Tests for XTC/TRR group writing
1 parent c1e7433 commit d55ebc4

File tree

5 files changed

+566
-0
lines changed

5 files changed

+566
-0
lines changed

src/io/trr_io.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,6 +1798,32 @@ mod tests {
17981798
assert!(file_diff::diff_files(&mut result, &mut expected));
17991799
}
18001800

1801+
#[test]
1802+
fn write_group_trr_not_starting() {
1803+
let mut system = System::from_file("test_files/example.gro").unwrap();
1804+
system.group_create("Phosphates", "name PO4").unwrap();
1805+
1806+
let xtc_output = NamedTempFile::new().unwrap();
1807+
let path_to_output = xtc_output.path();
1808+
1809+
system
1810+
.trr_group_writer_init(path_to_output, "Phosphates")
1811+
.unwrap();
1812+
1813+
for frame in system.xtc_iter("test_files/short_trajectory.xtc").unwrap() {
1814+
let frame = frame.unwrap();
1815+
1816+
frame.traj_write_frame().unwrap();
1817+
}
1818+
1819+
system.traj_close();
1820+
1821+
let mut result = File::open(path_to_output).unwrap();
1822+
let mut expected = File::open("test_files/short_trajectory_phosphates.trr").unwrap();
1823+
1824+
assert!(file_diff::diff_files(&mut result, &mut expected));
1825+
}
1826+
18011827
#[test]
18021828
fn write_group_trr_all() {
18031829
let mut system = System::from_file("test_files/example.gro").unwrap();

src/io/xtc_io/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,31 @@ mod tests_write {
10801080
assert!(file_diff::diff_files(&mut result, &mut expected));
10811081
}
10821082

1083+
#[test]
1084+
fn write_group_xtc_not_starting() {
1085+
let mut system = System::from_file("test_files/example.gro").unwrap();
1086+
system.group_create("Phosphates", "name PO4").unwrap();
1087+
1088+
let xtc_output = NamedTempFile::new().unwrap();
1089+
let path_to_output = xtc_output.path();
1090+
1091+
system
1092+
.xtc_group_writer_init(path_to_output, "Phosphates")
1093+
.unwrap();
1094+
1095+
for frame in system.xtc_iter("test_files/short_trajectory.xtc").unwrap() {
1096+
let frame = frame.unwrap();
1097+
frame.traj_write_frame().unwrap();
1098+
}
1099+
1100+
system.traj_close();
1101+
1102+
let mut result = File::open(path_to_output).unwrap();
1103+
let mut expected = File::open("test_files/short_trajectory_phosphates.xtc").unwrap();
1104+
1105+
assert!(file_diff::diff_files(&mut result, &mut expected));
1106+
}
1107+
10831108
#[test]
10841109
fn write_group_xtc_all() {
10851110
let mut system = System::from_file("test_files/example.gro").unwrap();

0 commit comments

Comments
 (0)