@@ -3803,7 +3803,7 @@ test_table_collection_check_integrity_with_options(tsk_flags_t tc_options)
3803
3803
ret = tsk_mutation_table_clear (& tables .mutations );
3804
3804
CU_ASSERT_EQUAL_FATAL (ret , 0 );
3805
3805
ret = tsk_mutation_table_add_row (
3806
- & tables .mutations , 0 , 0 , TSK_NULL , NAN , NULL , 0 , NULL , 0 );
3806
+ & tables .mutations , 0 , 0 , TSK_NULL , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
3807
3807
CU_ASSERT_FATAL (ret >= 0 );
3808
3808
ret = tsk_table_collection_check_integrity (& tables , 0 );
3809
3809
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_TIME_NONFINITE );
@@ -3986,10 +3986,10 @@ test_table_collection_subset_with_options(tsk_flags_t options)
3986
3986
// four nodes from two diploids; the first is from pop 0
3987
3987
ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , 0 , 0 , NULL , 0 );
3988
3988
CU_ASSERT_FATAL (ret >= 0 );
3989
- ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0 .0 , 0 , 0 , NULL , 0 );
3989
+ ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 1 .0 , 0 , 0 , NULL , 0 );
3990
3990
CU_ASSERT_FATAL (ret >= 0 );
3991
3991
ret = tsk_node_table_add_row (
3992
- & tables .nodes , TSK_NODE_IS_SAMPLE , 0 .0 , TSK_NULL , 1 , NULL , 0 );
3992
+ & tables .nodes , TSK_NODE_IS_SAMPLE , 2 .0 , TSK_NULL , 1 , NULL , 0 );
3993
3993
CU_ASSERT_FATAL (ret >= 0 );
3994
3994
ret = tsk_node_table_add_row (
3995
3995
& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , TSK_NULL , 1 , NULL , 0 );
@@ -4009,13 +4009,16 @@ test_table_collection_subset_with_options(tsk_flags_t options)
4009
4009
ret = tsk_site_table_add_row (& tables .sites , 0.4 , "A" , 1 , NULL , 0 );
4010
4010
CU_ASSERT_FATAL (ret >= 0 );
4011
4011
ret = tsk_mutation_table_add_row (
4012
- & tables .mutations , 0 , 0 , TSK_NULL , NAN , NULL , 0 , NULL , 0 );
4012
+ & tables .mutations , 0 , 0 , TSK_NULL , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
4013
4013
CU_ASSERT_FATAL (ret >= 0 );
4014
- ret = tsk_mutation_table_add_row (& tables .mutations , 0 , 0 , 0 , NAN , NULL , 0 , NULL , 0 );
4014
+ ret = tsk_mutation_table_add_row (
4015
+ & tables .mutations , 0 , 0 , 0 , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
4015
4016
CU_ASSERT_FATAL (ret >= 0 );
4016
4017
ret = tsk_mutation_table_add_row (
4017
- & tables .mutations , 1 , 1 , TSK_NULL , NAN , NULL , 0 , NULL , 0 );
4018
+ & tables .mutations , 1 , 1 , TSK_NULL , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
4018
4019
CU_ASSERT_FATAL (ret >= 0 );
4020
+ ret = tsk_table_collection_build_index (& tables , 0 );
4021
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4019
4022
4020
4023
// empty nodes should get empty tables
4021
4024
ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT | options );
@@ -4069,16 +4072,17 @@ test_table_collection_subset_errors(void)
4069
4072
4070
4073
ret = tsk_table_collection_init (& tables , 0 );
4071
4074
CU_ASSERT_EQUAL_FATAL (ret , 0 );
4075
+ tables .sequence_length = 1 ;
4072
4076
ret = tsk_table_collection_init (& tables_copy , 0 );
4073
4077
CU_ASSERT_EQUAL_FATAL (ret , 0 );
4074
4078
4075
4079
// four nodes from two diploids; the first is from pop 0
4076
4080
ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , 0 , 0 , NULL , 0 );
4077
4081
CU_ASSERT_FATAL (ret >= 0 );
4078
- ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0 .0 , 0 , 0 , NULL , 0 );
4082
+ ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 1 .0 , 0 , 0 , NULL , 0 );
4079
4083
CU_ASSERT_FATAL (ret >= 0 );
4080
4084
ret = tsk_node_table_add_row (
4081
- & tables .nodes , TSK_NODE_IS_SAMPLE , 0 .0 , TSK_NULL , 1 , NULL , 0 );
4085
+ & tables .nodes , TSK_NODE_IS_SAMPLE , 2 .0 , TSK_NULL , 1 , NULL , 0 );
4082
4086
CU_ASSERT_FATAL (ret >= 0 );
4083
4087
ret = tsk_node_table_add_row (
4084
4088
& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , TSK_NULL , 1 , NULL , 0 );
@@ -4091,6 +4095,8 @@ test_table_collection_subset_errors(void)
4091
4095
CU_ASSERT_FATAL (ret >= 0 );
4092
4096
ret = tsk_edge_table_add_row (& tables .edges , 0.0 , 1.0 , 1 , 0 , NULL , 0 );
4093
4097
CU_ASSERT_FATAL (ret >= 0 );
4098
+ ret = tsk_table_collection_build_index (& tables , 0 );
4099
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4094
4100
4095
4101
/* Migrations are not supported */
4096
4102
ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
@@ -4101,15 +4107,248 @@ test_table_collection_subset_errors(void)
4101
4107
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_MIGRATIONS_NOT_SUPPORTED );
4102
4108
4103
4109
// test out of bounds nodes
4110
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4111
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4104
4112
nodes [0 ] = -1 ;
4105
- ret = tsk_table_collection_subset (& tables , nodes , 4 );
4113
+ ret = tsk_table_collection_subset (& tables_copy , nodes , 4 );
4106
4114
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_NODE_OUT_OF_BOUNDS );
4107
4115
nodes [0 ] = 6 ;
4108
- ret = tsk_table_collection_subset (& tables , nodes , 4 );
4116
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4117
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4118
+ ret = tsk_table_collection_subset (& tables_copy , nodes , 4 );
4109
4119
CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_NODE_OUT_OF_BOUNDS );
4110
4120
4121
+ // check integrity
4122
+ nodes [0 ] = 0 ;
4123
+ nodes [1 ] = 1 ;
4124
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4125
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4126
+ ret = tsk_node_table_truncate (& tables_copy .nodes , 3 );
4127
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4128
+ ret = tsk_node_table_add_row (
4129
+ & tables_copy .nodes , TSK_NODE_IS_SAMPLE , 0.0 , -2 , 0 , NULL , 0 );
4130
+ CU_ASSERT_FATAL (ret >= 0 );
4131
+ ret = tsk_table_collection_subset (& tables_copy , nodes , 4 );
4132
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_POPULATION_OUT_OF_BOUNDS );
4133
+
4134
+ tsk_table_collection_free (& tables );
4135
+ tsk_table_collection_free (& tables_copy );
4136
+ }
4137
+
4138
+ static void
4139
+ test_table_collection_union (void )
4140
+ {
4141
+ int ret ;
4142
+ tsk_table_collection_t tables ;
4143
+ tsk_table_collection_t tables_empty ;
4144
+ tsk_table_collection_t tables_copy ;
4145
+ tsk_id_t node_mapping [3 ];
4146
+
4147
+ memset (node_mapping , 0xff , sizeof (node_mapping ));
4148
+
4149
+ ret = tsk_table_collection_init (& tables , 0 );
4150
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4151
+ tables .sequence_length = 1 ;
4152
+ ret = tsk_table_collection_init (& tables_empty , 0 );
4153
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4154
+ tables_empty .sequence_length = 1 ;
4155
+ ret = tsk_table_collection_init (& tables_copy , 0 );
4156
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4157
+
4158
+ // does not error on empty tables
4159
+ ret = tsk_table_collection_union (
4160
+ & tables , & tables_empty , node_mapping , TSK_UNION_NO_CHECK_SHARED );
4161
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4162
+
4163
+ // three nodes, two pop, three ind, two edge, two site, two mut
4164
+ ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , 0 , 0 , NULL , 0 );
4165
+ CU_ASSERT_FATAL (ret >= 0 );
4166
+ ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , 1 , 1 , NULL , 0 );
4167
+ CU_ASSERT_FATAL (ret >= 0 );
4168
+ ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.5 , 1 , 2 , NULL , 0 );
4169
+ CU_ASSERT_FATAL (ret >= 0 );
4170
+ ret = tsk_individual_table_add_row (& tables .individuals , 0 , NULL , 0 , NULL , 0 );
4171
+ CU_ASSERT_FATAL (ret >= 0 );
4172
+ ret = tsk_individual_table_add_row (& tables .individuals , 0 , NULL , 0 , NULL , 0 );
4173
+ CU_ASSERT_FATAL (ret >= 0 );
4174
+ ret = tsk_individual_table_add_row (& tables .individuals , 0 , NULL , 0 , NULL , 0 );
4175
+ CU_ASSERT_FATAL (ret >= 0 );
4176
+ ret = tsk_population_table_add_row (& tables .populations , NULL , 0 );
4177
+ CU_ASSERT_FATAL (ret >= 0 );
4178
+ ret = tsk_population_table_add_row (& tables .populations , NULL , 0 );
4179
+ CU_ASSERT_FATAL (ret >= 0 );
4180
+ ret = tsk_edge_table_add_row (& tables .edges , 0.0 , 1.0 , 2 , 0 , NULL , 0 );
4181
+ CU_ASSERT_FATAL (ret >= 0 );
4182
+ ret = tsk_edge_table_add_row (& tables .edges , 0.0 , 1.0 , 2 , 1 , NULL , 0 );
4183
+ CU_ASSERT_FATAL (ret >= 0 );
4184
+ ret = tsk_site_table_add_row (& tables .sites , 0.4 , "T" , 1 , NULL , 0 );
4185
+ CU_ASSERT_FATAL (ret >= 0 );
4186
+ ret = tsk_site_table_add_row (& tables .sites , 0.2 , "A" , 1 , NULL , 0 );
4187
+ CU_ASSERT_FATAL (ret >= 0 );
4188
+ ret = tsk_mutation_table_add_row (
4189
+ & tables .mutations , 0 , 0 , TSK_NULL , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
4190
+ ret = tsk_mutation_table_add_row (
4191
+ & tables .mutations , 1 , 1 , TSK_NULL , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
4192
+ CU_ASSERT_FATAL (ret >= 0 );
4193
+ ret = tsk_table_collection_build_index (& tables , 0 );
4194
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4195
+ ret = tsk_table_collection_sort (& tables , NULL , 0 );
4196
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4197
+
4198
+ // union with empty should not change
4199
+ // other is empty
4200
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4201
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4202
+ ret = tsk_table_collection_union (
4203
+ & tables_copy , & tables_empty , node_mapping , TSK_UNION_NO_CHECK_SHARED );
4204
+ CU_ASSERT_FATAL (tsk_table_collection_equals (& tables , & tables_copy ));
4205
+ // self is empty
4206
+ ret = tsk_table_collection_clear (& tables_copy );
4207
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4208
+ ret = tsk_table_collection_union (
4209
+ & tables_copy , & tables , node_mapping , TSK_UNION_NO_CHECK_SHARED );
4210
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4211
+ CU_ASSERT_FATAL (tsk_table_collection_equals (& tables , & tables_copy ));
4212
+
4213
+ // union all shared nodes + subset original nodes = original table
4214
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4215
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4216
+ ret = tsk_table_collection_union (
4217
+ & tables_copy , & tables , node_mapping , TSK_UNION_NO_CHECK_SHARED );
4218
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4219
+ node_mapping [0 ] = 0 ;
4220
+ node_mapping [1 ] = 1 ;
4221
+ node_mapping [2 ] = 2 ;
4222
+ ret = tsk_table_collection_subset (& tables_copy , node_mapping , 3 );
4223
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4224
+ CU_ASSERT_FATAL (tsk_table_collection_equals (& tables , & tables_copy ));
4225
+
4226
+ // union with one shared node
4227
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4228
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4229
+ node_mapping [0 ] = TSK_NULL ;
4230
+ node_mapping [1 ] = TSK_NULL ;
4231
+ node_mapping [2 ] = 2 ;
4232
+ ret = tsk_table_collection_union (& tables_copy , & tables , node_mapping , 0 );
4233
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4234
+ CU_ASSERT_EQUAL_FATAL (
4235
+ tables_copy .populations .num_rows , tables .populations .num_rows + 2 );
4236
+ CU_ASSERT_EQUAL_FATAL (
4237
+ tables_copy .individuals .num_rows , tables .individuals .num_rows + 2 );
4238
+ CU_ASSERT_EQUAL_FATAL (tables_copy .nodes .num_rows , tables .nodes .num_rows + 2 );
4239
+ CU_ASSERT_EQUAL_FATAL (tables_copy .edges .num_rows , tables .edges .num_rows + 2 );
4240
+ CU_ASSERT_EQUAL_FATAL (tables_copy .sites .num_rows , tables .sites .num_rows );
4241
+ CU_ASSERT_EQUAL_FATAL (tables_copy .mutations .num_rows , tables .mutations .num_rows + 2 );
4242
+
4243
+ // union with one shared node, but no add pop
4244
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4245
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4246
+ node_mapping [0 ] = TSK_NULL ;
4247
+ node_mapping [1 ] = TSK_NULL ;
4248
+ node_mapping [2 ] = 2 ;
4249
+ ret = tsk_table_collection_union (
4250
+ & tables_copy , & tables , node_mapping , TSK_UNION_NO_ADD_POP );
4251
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4252
+ CU_ASSERT_EQUAL_FATAL (tables_copy .populations .num_rows , tables .populations .num_rows );
4253
+ CU_ASSERT_EQUAL_FATAL (
4254
+ tables_copy .individuals .num_rows , tables .individuals .num_rows + 2 );
4255
+ CU_ASSERT_EQUAL_FATAL (tables_copy .nodes .num_rows , tables .nodes .num_rows + 2 );
4256
+ CU_ASSERT_EQUAL_FATAL (tables_copy .edges .num_rows , tables .edges .num_rows + 2 );
4257
+ CU_ASSERT_EQUAL_FATAL (tables_copy .sites .num_rows , tables .sites .num_rows );
4258
+ CU_ASSERT_EQUAL_FATAL (tables_copy .mutations .num_rows , tables .mutations .num_rows + 2 );
4259
+
4260
+ tsk_table_collection_free (& tables_copy );
4261
+ tsk_table_collection_free (& tables_empty );
4111
4262
tsk_table_collection_free (& tables );
4263
+ }
4264
+
4265
+ static void
4266
+ test_table_collection_union_errors (void )
4267
+ {
4268
+ int ret ;
4269
+ tsk_table_collection_t tables ;
4270
+ tsk_table_collection_t tables_copy ;
4271
+ tsk_id_t node_mapping [] = { 0 , 1 };
4272
+
4273
+ ret = tsk_table_collection_init (& tables , 0 );
4274
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4275
+ tables .sequence_length = 1 ;
4276
+ ret = tsk_table_collection_init (& tables_copy , 0 );
4277
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4278
+
4279
+ // two nodes, two pop, two ind, one edge, one site, one mut
4280
+ ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , 0 , 0 , NULL , 0 );
4281
+ CU_ASSERT_FATAL (ret >= 0 );
4282
+ ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.5 , 1 , 1 , NULL , 0 );
4283
+ CU_ASSERT_FATAL (ret >= 0 );
4284
+ ret = tsk_individual_table_add_row (& tables .individuals , 0 , NULL , 0 , NULL , 0 );
4285
+ CU_ASSERT_FATAL (ret >= 0 );
4286
+ ret = tsk_individual_table_add_row (& tables .individuals , 0 , NULL , 0 , NULL , 0 );
4287
+ CU_ASSERT_FATAL (ret >= 0 );
4288
+ ret = tsk_population_table_add_row (& tables .populations , NULL , 0 );
4289
+ CU_ASSERT_FATAL (ret >= 0 );
4290
+ ret = tsk_population_table_add_row (& tables .populations , NULL , 0 );
4291
+ CU_ASSERT_FATAL (ret >= 0 );
4292
+ ret = tsk_edge_table_add_row (& tables .edges , 0.0 , 1.0 , 1 , 0 , NULL , 0 );
4293
+ CU_ASSERT_FATAL (ret >= 0 );
4294
+ ret = tsk_site_table_add_row (& tables .sites , 0.2 , "A" , 1 , NULL , 0 );
4295
+ CU_ASSERT_FATAL (ret >= 0 );
4296
+ ret = tsk_mutation_table_add_row (
4297
+ & tables .mutations , 0 , 0 , TSK_NULL , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
4298
+ CU_ASSERT_FATAL (ret >= 0 );
4299
+
4300
+ // trigger diff histories error
4301
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4302
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4303
+ ret = tsk_mutation_table_add_row (
4304
+ & tables_copy .mutations , 0 , 1 , TSK_NULL , TSK_UNKNOWN_TIME , NULL , 0 , NULL , 0 );
4305
+ CU_ASSERT_FATAL (ret >= 0 );
4306
+ ret = tsk_table_collection_union (& tables_copy , & tables , node_mapping , 0 );
4307
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_UNION_DIFF_HISTORIES );
4308
+
4309
+ // Migrations are not supported
4310
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4311
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4312
+ tsk_migration_table_add_row (& tables_copy .migrations , 0 , 1 , 0 , 0 , 0 , 0 , NULL , 0 );
4313
+ CU_ASSERT_EQUAL_FATAL (tables_copy .migrations .num_rows , 1 );
4314
+ ret = tsk_table_collection_union (
4315
+ & tables_copy , & tables , node_mapping , TSK_UNION_NO_CHECK_SHARED );
4316
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_MIGRATIONS_NOT_SUPPORTED );
4317
+
4318
+ // unsuported union - child shared parent not shared
4319
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4320
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4321
+ node_mapping [0 ] = 0 ;
4322
+ node_mapping [1 ] = TSK_NULL ;
4323
+ ret = tsk_table_collection_union (
4324
+ & tables_copy , & tables , node_mapping , TSK_UNION_NO_ADD_POP );
4325
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_UNION_NOT_SUPPORTED );
4326
+
4327
+ // test out of bounds node_mapping
4328
+ node_mapping [0 ] = -4 ;
4329
+ node_mapping [1 ] = 6 ;
4330
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4331
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4332
+ ret = tsk_table_collection_union (& tables_copy , & tables , node_mapping , 0 );
4333
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_UNION_BAD_MAP );
4334
+
4335
+ // check integrity
4336
+ node_mapping [0 ] = 0 ;
4337
+ node_mapping [1 ] = 1 ;
4338
+ ret = tsk_node_table_add_row (
4339
+ & tables_copy .nodes , TSK_NODE_IS_SAMPLE , 0.0 , -2 , 0 , NULL , 0 );
4340
+ CU_ASSERT_FATAL (ret >= 0 );
4341
+ ret = tsk_table_collection_union (& tables_copy , & tables , node_mapping , 0 );
4342
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_POPULATION_OUT_OF_BOUNDS );
4343
+ ret = tsk_table_collection_copy (& tables , & tables_copy , TSK_NO_INIT );
4344
+ CU_ASSERT_EQUAL_FATAL (ret , 0 );
4345
+ ret = tsk_node_table_add_row (& tables .nodes , TSK_NODE_IS_SAMPLE , 0.0 , -2 , 0 , NULL , 0 );
4346
+ CU_ASSERT_FATAL (ret >= 0 );
4347
+ ret = tsk_table_collection_union (& tables , & tables_copy , node_mapping , 0 );
4348
+ CU_ASSERT_EQUAL_FATAL (ret , TSK_ERR_POPULATION_OUT_OF_BOUNDS );
4349
+
4112
4350
tsk_table_collection_free (& tables_copy );
4351
+ tsk_table_collection_free (& tables );
4113
4352
}
4114
4353
4115
4354
int
@@ -4168,6 +4407,8 @@ main(int argc, char **argv)
4168
4407
test_table_collection_check_integrity_no_populations },
4169
4408
{ "test_table_collection_subset" , test_table_collection_subset },
4170
4409
{ "test_table_collection_subset_errors" , test_table_collection_subset_errors },
4410
+ { "test_table_collection_union" , test_table_collection_union },
4411
+ { "test_table_collection_union_errors" , test_table_collection_union_errors },
4171
4412
{ NULL , NULL },
4172
4413
};
4173
4414
0 commit comments