@@ -8776,6 +8776,48 @@ test_init_compute_mutation_parents(void)
8776
8776
tsk_treeseq_free (& ts );
8777
8777
}
8778
8778
8779
+ static void
8780
+ test_init_compute_mutation_parents_errors (void )
8781
+ {
8782
+ int ret ;
8783
+ tsk_table_collection_t tables ;
8784
+ tsk_treeseq_t ts ;
8785
+ const char * sites = "0.5 0\n"
8786
+ "0 0\n" ;
8787
+
8788
+ ret = tsk_table_collection_init (& tables , 0 );
8789
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
8790
+
8791
+ tables .sequence_length = 1 ;
8792
+ parse_nodes (single_tree_ex_nodes , & tables .nodes );
8793
+ CU_ASSERT_EQUAL_FATAL (tables .nodes .num_rows , 7 );
8794
+ parse_edges (single_tree_ex_edges , & tables .edges );
8795
+ CU_ASSERT_EQUAL_FATAL (tables .edges .num_rows , 6 );
8796
+ parse_sites (sites , & tables .sites );
8797
+ CU_ASSERT_EQUAL_FATAL (tables .sites .num_rows , 2 );
8798
+ tables .sequence_length = 1.0 ;
8799
+
8800
+ ret = tsk_treeseq_init (
8801
+ & ts , & tables , TSK_TS_INIT_BUILD_INDEXES | TSK_TS_INIT_COMPUTE_MUTATION_PARENTS );
8802
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_UNSORTED_SITES );
8803
+
8804
+ tsk_site_table_clear (& tables .sites );
8805
+ ret = tsk_site_table_add_row (& tables .sites , 0.5 , "A" , 1 , NULL , 0 );
8806
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
8807
+ ret = tsk_mutation_table_add_row (
8808
+ & tables .mutations , 0 , 0 , TSK_NULL , TSK_UNKNOWN_TIME , "A" , 1 , NULL , 0 );
8809
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
8810
+ ret = tsk_mutation_table_add_row (
8811
+ & tables .mutations , 0 , 4 , TSK_NULL , TSK_UNKNOWN_TIME , "A" , 1 , NULL , 0 );
8812
+ CU_ASSERT_EQUAL_FATAL (ret , 1 );
8813
+
8814
+ ret = tsk_treeseq_init (
8815
+ & ts , & tables , TSK_TS_INIT_BUILD_INDEXES | TSK_TS_INIT_COMPUTE_MUTATION_PARENTS );
8816
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_MUTATION_PARENT_AFTER_CHILD );
8817
+
8818
+ tsk_table_collection_free (& tables );
8819
+ }
8820
+
8779
8821
int
8780
8822
main (int argc , char * * argv )
8781
8823
{
@@ -8985,6 +9027,8 @@ main(int argc, char **argv)
8985
9027
{ "test_init_take_ownership_no_edge_metadata" ,
8986
9028
test_init_take_ownership_no_edge_metadata },
8987
9029
{ "test_init_compute_mutation_parents" , test_init_compute_mutation_parents },
9030
+ { "test_init_compute_mutation_parents_errors" ,
9031
+ test_init_compute_mutation_parents_errors },
8988
9032
{ NULL , NULL },
8989
9033
};
8990
9034
0 commit comments