| 565 | } // namespace |
| 566 | |
| 567 | TEST(TestSparseCSFIndex, RejectInconsistentBufferCounts) { |
| 568 | // ndim == 1 is not a valid CSF index (it has no indptr buffers), and used to |
| 569 | // reach SparseCSFIndex's constructor with an empty indptr vector. |
| 570 | ASSERT_OK_AND_ASSIGN(auto message, |
| 571 | MakeCSFSparseTensorMessage(/*shape=*/{4}, /*num_indptr_buffers=*/0, |
| 572 | /*num_indices_buffers=*/1, |
| 573 | /*axis_order_size=*/1)); |
| 574 | ASSERT_RAISES(Invalid, ReadSparseTensor(*message)); |
| 575 | |
| 576 | // Too many indices buffers for the declared number of dimensions, which used |
| 577 | // to write past the end of the fixed-size index vectors. |
| 578 | ASSERT_OK_AND_ASSIGN( |
| 579 | message, MakeCSFSparseTensorMessage(/*shape=*/{4, 4}, /*num_indptr_buffers=*/1, |
| 580 | /*num_indices_buffers=*/3, |
| 581 | /*axis_order_size=*/2)); |
| 582 | ASSERT_RAISES(Invalid, ReadSparseTensor(*message)); |
| 583 | |
| 584 | // axisOrder and indicesBuffers lengths disagree (out-of-bounds read). |
| 585 | ASSERT_OK_AND_ASSIGN( |
| 586 | message, MakeCSFSparseTensorMessage(/*shape=*/{4, 4}, /*num_indptr_buffers=*/1, |
| 587 | /*num_indices_buffers=*/2, |
| 588 | /*axis_order_size=*/3)); |
| 589 | ASSERT_RAISES(Invalid, ReadSparseTensor(*message)); |
| 590 | } |
| 591 | |
| 592 | TEST(TestSparseCSFIndex, RejectInconsistentPayloadBufferCounts) { |
| 593 | ASSERT_OK_AND_ASSIGN(auto message, |
nothing calls this directly
no test coverage detected