@@ -11666,126 +11666,6 @@ test_table_collection_union_errors(void)
1166611666 tsk_table_collection_free (& tables );
1166711667}
1166811668
11669- static void
11670- test_table_collection_clear_with_options (tsk_flags_t options )
11671- {
11672- int ret ;
11673- tsk_id_t ret_id ;
11674- tsk_table_collection_t tables ;
11675- bool clear_provenance = !!(options & TSK_CLEAR_PROVENANCE );
11676- bool clear_metadata_schemas = !!(options & TSK_CLEAR_METADATA_SCHEMAS );
11677- bool clear_ts_metadata = !!(options & TSK_CLEAR_TS_METADATA_AND_SCHEMA );
11678- tsk_bookmark_t num_rows ;
11679- tsk_bookmark_t expected_rows = { .provenances = clear_provenance ? 0 : 1 };
11680- tsk_size_t expected_len = clear_metadata_schemas ? 0 : 4 ;
11681- tsk_size_t expected_len_ts = clear_ts_metadata ? 0 : 4 ;
11682-
11683- ret = tsk_table_collection_init (& tables , 0 );
11684- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11685- tables .sequence_length = 1 ;
11686-
11687- ret_id
11688- = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , 0 , 0 , NULL , 0 );
11689- CU_ASSERT_FATAL (ret_id >= 0 );
11690- ret_id
11691- = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.5 , 1 , 1 , NULL , 0 );
11692- CU_ASSERT_FATAL (ret_id >= 0 );
11693- ret_id = tsk_individual_table_add_row (
11694- & tables .individuals , 0 , NULL , 0 , NULL , 0 , NULL , 0 );
11695- CU_ASSERT_FATAL (ret_id >= 0 );
11696- ret_id = tsk_individual_table_add_row (
11697- & tables .individuals , 0 , NULL , 0 , NULL , 0 , NULL , 0 );
11698- CU_ASSERT_FATAL (ret_id >= 0 );
11699- ret_id = tsk_population_table_add_row (& tables .populations , NULL , 0 );
11700- CU_ASSERT_FATAL (ret_id >= 0 );
11701- ret_id = tsk_population_table_add_row (& tables .populations , NULL , 0 );
11702- CU_ASSERT_FATAL (ret_id >= 0 );
11703- ret_id = tsk_edge_table_add_row (& tables .edges , 0.0 , 1.0 , 1 , 0 , NULL , 0 );
11704- CU_ASSERT_FATAL (ret_id >= 0 );
11705- ret_id = tsk_site_table_add_row (& tables .sites , 0.2 , "A" , 1 , NULL , 0 );
11706- CU_ASSERT_FATAL (ret_id >= 0 );
11707- ret_id = tsk_mutation_table_add_row (
11708- & tables .mutations , 0 , 0 , TSK_NULL , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
11709- CU_ASSERT_FATAL (ret_id >= 0 );
11710- ret_id = tsk_migration_table_add_row (& tables .migrations , 0 , 1 , 0 , 0 , 0 , 0 , NULL , 0 );
11711- CU_ASSERT_FATAL (ret_id >= 0 );
11712-
11713- ret = tsk_table_collection_build_index (& tables , 0 );
11714- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11715-
11716- ret = tsk_individual_table_set_metadata_schema (& tables .individuals , "test" , 4 );
11717- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11718- ret = tsk_node_table_set_metadata_schema (& tables .nodes , "test" , 4 );
11719- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11720- ret = tsk_edge_table_set_metadata_schema (& tables .edges , "test" , 4 );
11721- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11722- ret = tsk_migration_table_set_metadata_schema (& tables .migrations , "test" , 4 );
11723- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11724- ret = tsk_site_table_set_metadata_schema (& tables .sites , "test" , 4 );
11725- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11726- ret = tsk_mutation_table_set_metadata_schema (& tables .mutations , "test" , 4 );
11727- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11728- ret = tsk_population_table_set_metadata_schema (& tables .populations , "test" , 4 );
11729- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11730-
11731- ret = tsk_table_collection_set_time_units (& tables , "test" , 4 );
11732- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11733- ret = tsk_table_collection_set_metadata (& tables , "test" , 4 );
11734- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11735- ret = tsk_table_collection_set_metadata_schema (& tables , "test" , 4 );
11736- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11737-
11738- ret_id = tsk_provenance_table_add_row (& tables .provenances , "today" , 5 , "test" , 4 );
11739- CU_ASSERT_FATAL (ret_id >= 0 );
11740-
11741- ret = tsk_table_collection_clear (& tables , options );
11742- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11743-
11744- ret = tsk_table_collection_record_num_rows (& tables , & num_rows );
11745- CU_ASSERT_EQUAL_FATAL (ret , 0 );
11746- CU_ASSERT_EQUAL (num_rows .individuals , expected_rows .individuals );
11747- CU_ASSERT_EQUAL (num_rows .nodes , expected_rows .nodes );
11748- CU_ASSERT_EQUAL (num_rows .edges , expected_rows .edges );
11749- CU_ASSERT_EQUAL (num_rows .migrations , expected_rows .migrations );
11750- CU_ASSERT_EQUAL (num_rows .sites , expected_rows .sites );
11751- CU_ASSERT_EQUAL (num_rows .mutations , expected_rows .mutations );
11752- CU_ASSERT_EQUAL (num_rows .populations , expected_rows .populations );
11753- CU_ASSERT_EQUAL (num_rows .provenances , expected_rows .provenances );
11754-
11755- CU_ASSERT_FALSE (tsk_table_collection_has_index (& tables , 0 ));
11756-
11757- CU_ASSERT_EQUAL (tables .individuals .metadata_schema_length , expected_len );
11758- CU_ASSERT_EQUAL (tables .nodes .metadata_schema_length , expected_len );
11759- CU_ASSERT_EQUAL (tables .edges .metadata_schema_length , expected_len );
11760- CU_ASSERT_EQUAL (tables .migrations .metadata_schema_length , expected_len );
11761- CU_ASSERT_EQUAL (tables .sites .metadata_schema_length , expected_len );
11762- CU_ASSERT_EQUAL (tables .mutations .metadata_schema_length , expected_len );
11763- CU_ASSERT_EQUAL (tables .populations .metadata_schema_length , expected_len );
11764- CU_ASSERT_EQUAL (tables .metadata_schema_length , expected_len_ts );
11765- CU_ASSERT_EQUAL (tables .metadata_length , expected_len_ts );
11766- CU_ASSERT_EQUAL (tables .time_units_length , 4 );
11767-
11768- tsk_table_collection_free (& tables );
11769- }
11770-
11771- static void
11772- test_table_collection_clear (void )
11773- {
11774- test_table_collection_clear_with_options (0 );
11775- test_table_collection_clear_with_options (TSK_CLEAR_PROVENANCE );
11776- test_table_collection_clear_with_options (TSK_CLEAR_METADATA_SCHEMAS );
11777- test_table_collection_clear_with_options (TSK_CLEAR_TS_METADATA_AND_SCHEMA );
11778- test_table_collection_clear_with_options (
11779- TSK_CLEAR_PROVENANCE | TSK_CLEAR_METADATA_SCHEMAS );
11780- test_table_collection_clear_with_options (
11781- TSK_CLEAR_PROVENANCE | TSK_CLEAR_TS_METADATA_AND_SCHEMA );
11782- test_table_collection_clear_with_options (
11783- TSK_CLEAR_METADATA_SCHEMAS | TSK_CLEAR_TS_METADATA_AND_SCHEMA );
11784- test_table_collection_clear_with_options (TSK_CLEAR_PROVENANCE
11785- | TSK_CLEAR_METADATA_SCHEMAS
11786- | TSK_CLEAR_TS_METADATA_AND_SCHEMA );
11787- }
11788-
1178911669static void
1179011670test_table_collection_takeset_indexes (void )
1179111671{
@@ -12026,7 +11906,6 @@ main(int argc, char **argv)
1202611906 { "test_table_collection_union_middle_merge" ,
1202711907 test_table_collection_union_middle_merge },
1202811908 { "test_table_collection_union_errors" , test_table_collection_union_errors },
12029- { "test_table_collection_clear" , test_table_collection_clear },
1203011909 { "test_table_collection_takeset_indexes" ,
1203111910 test_table_collection_takeset_indexes },
1203211911 { "test_table_collection_delete_older" , test_table_collection_delete_older },
0 commit comments