@@ -533,6 +533,16 @@ TYPED_TEST(Matrix, construct_with_size_and_ptr_empty) {
533533 EXPECT_EQ (matr.shape_padded (), (plssvm::shape{ 0 , 0 }));
534534}
535535
536+ TYPED_TEST (Matrix, construct_with_size_and_nullptr_ptr) {
537+ using real_type = typename TestFixture::fixture_real_type;
538+ constexpr plssvm::layout_type layout = TestFixture::fixture_layout;
539+
540+ // construct a matrix with a specific size and a nullptr
541+ EXPECT_THROW_WHAT ((plssvm::matrix<real_type, layout>{ plssvm::shape{ 2 , 3 }, nullptr }),
542+ plssvm::matrix_exception,
543+ " The provided data pointer may not be a nullptr if the matrix size is greater than 0!" );
544+ }
545+
536546TYPED_TEST (Matrix, construct_with_size_and_ptr_value_zero_num_rows) {
537547 using real_type = typename TestFixture::fixture_real_type;
538548 constexpr plssvm::layout_type layout = TestFixture::fixture_layout;
@@ -603,6 +613,16 @@ TYPED_TEST(Matrix, construct_with_size_and_ptr_empty_and_padding) {
603613 EXPECT_TRUE (std::all_of (matr.data (), matr.data () + matr.size_padded (), [](const real_type val) { return val == real_type{ 0.0 }; }));
604614}
605615
616+ TYPED_TEST (Matrix, construct_with_size_and_nullptr_empty_and_padding) {
617+ using real_type = typename TestFixture::fixture_real_type;
618+ constexpr plssvm::layout_type layout = TestFixture::fixture_layout;
619+
620+ // construct a matrix with a specific size, padding and a nullptr
621+ EXPECT_THROW_WHAT ((plssvm::matrix<real_type, layout>{ plssvm::shape{ 2 , 3 }, nullptr , plssvm::shape{ 4 , 5 } }),
622+ plssvm::matrix_exception,
623+ " The provided data pointer may not be a nullptr if the matrix size is greater than 0!" );
624+ }
625+
606626TYPED_TEST (Matrix, construct_with_size_and_ptr_empty_and_zero_padding) {
607627 using real_type = typename TestFixture::fixture_real_type;
608628 constexpr plssvm::layout_type layout = TestFixture::fixture_layout;
0 commit comments