Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Ensure that VariantBuilderMultiSampleVector works with 0 samples / 0 …
Browse files Browse the repository at this point in the history
…values per sample

-Make sure we don't crash when creating empty VariantBuilderMultiSampleVectors

-Tests for VariantBuilder already exist confirming that the builder will clear
 the relevant field when given an empty VariantBuilderMultiSampleVector
  • Loading branch information
droazen committed Nov 24, 2014
1 parent 857044d commit 14d37dc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/variant_builder_multi_sample_vector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,22 @@ BOOST_AUTO_TEST_CASE( test_float_multi_sample_vector_multiple_samples ) {
}
}
}

BOOST_AUTO_TEST_CASE( test_multi_sample_vector_zero_samples_and_values ) {
// Ensure that we don't crash when creating empty vectors with num_samples or max_values_per_sample equal to 0

// 0 samples, max of 0 values per sample
auto vec = VariantBuilderMultiSampleVector<int32_t>{0u, 0u, bcf_int32_missing, bcf_int32_vector_end};
BOOST_CHECK_EQUAL(vec.num_samples(), 0u);
BOOST_CHECK_EQUAL(vec.max_values_per_sample(), 0u);

// 4 samples, max of 0 values per sample
vec = VariantBuilderMultiSampleVector<int32_t>{4u, 0u, bcf_int32_missing, bcf_int32_vector_end};
BOOST_CHECK_EQUAL(vec.num_samples(), 4u);
BOOST_CHECK_EQUAL(vec.max_values_per_sample(), 0u);

// 0 samples, max of 4 values per sample
vec = VariantBuilderMultiSampleVector<int32_t>{0u, 4u, bcf_int32_missing, bcf_int32_vector_end};
BOOST_CHECK_EQUAL(vec.num_samples(), 0u);
BOOST_CHECK_EQUAL(vec.max_values_per_sample(), 4u);
}

0 comments on commit 14d37dc

Please sign in to comment.