Skip to content

Commit a45be79

Browse files
committed
Add missing C test
1 parent 026fff3 commit a45be79

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

c/tests/test_trees.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8776,6 +8776,48 @@ test_init_compute_mutation_parents(void)
87768776
tsk_treeseq_free(&ts);
87778777
}
87788778

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+
87798821
int
87808822
main(int argc, char **argv)
87818823
{
@@ -8985,6 +9027,8 @@ main(int argc, char **argv)
89859027
{ "test_init_take_ownership_no_edge_metadata",
89869028
test_init_take_ownership_no_edge_metadata },
89879029
{ "test_init_compute_mutation_parents", test_init_compute_mutation_parents },
9030+
{ "test_init_compute_mutation_parents_errors",
9031+
test_init_compute_mutation_parents_errors },
89889032
{ NULL, NULL },
89899033
};
89909034

0 commit comments

Comments
 (0)