Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
molpopgen committed Nov 12, 2024
1 parent 6523aae commit 5b4b391
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions demes/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,3 +1772,20 @@ fn test_deme_ancestry_iterator() {
assert_eq!(&ancestors, &ancestors_from_deme);
}
}

#[test]
fn test_load_from_file() {
let filename = "demes-spec/examples/browning_america.yaml";
let file = std::fs::File::open(filename).unwrap();
let graph = crate::load(file).unwrap();
let mut graph_from_file: *mut Graph = std::ptr::null_mut();
let mut error = FFIError::default();

let c_filename = CString::new(filename.to_string()).unwrap();
let code = unsafe {
demes_graph_load_from_file(c_filename.as_ptr(), &mut error, &mut graph_from_file)
};
assert_eq!(code, 0);
assert_eq!(&graph, unsafe{graph_from_file.as_ref()}.unwrap());
unsafe{demes_graph_deallocate(graph_from_file)};
}

0 comments on commit 5b4b391

Please sign in to comment.