Skip to content

Commit 87593d4

Browse files
authored
Merge pull request #59 from molpopgen/add_test_metadata_some_columns_only
Add test of metadata decoding when not all rows have metadata.
2 parents adcc321 + 5ab8e8c commit 87593d4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/table_collection.rs

+36
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,42 @@ mod test {
805805
}
806806
}
807807

808+
#[test]
809+
fn test_add_mutation_with_metadata_for_some_columns() {
810+
let mut tables = TableCollection::new(1000.).unwrap();
811+
tables
812+
.add_mutation_with_metadata(
813+
0,
814+
0,
815+
crate::TSK_NULL,
816+
1.123,
817+
None,
818+
Some(&F { x: -3, y: 666 }),
819+
)
820+
.unwrap();
821+
822+
tables
823+
.add_mutation_with_metadata(1, 2, crate::TSK_NULL, 2.0, None, None)
824+
.unwrap();
825+
826+
let mut num_with_metadata = 0;
827+
let mut num_without_metadata = 0;
828+
for i in 0..tables.mutations().num_rows() {
829+
match tables.mutations().metadata::<F>(i as tsk_id_t).unwrap() {
830+
Some(x) => {
831+
num_with_metadata += 1;
832+
assert_eq!(x.x, -3);
833+
assert_eq!(x.y, 666);
834+
}
835+
None => {
836+
num_without_metadata += 1;
837+
}
838+
}
839+
}
840+
assert_eq!(num_with_metadata, 1);
841+
assert_eq!(num_without_metadata, 1);
842+
}
843+
808844
#[test]
809845
fn test_add_population() {
810846
let mut tables = TableCollection::new(1000.).unwrap();

0 commit comments

Comments
 (0)