mrkn commented on a change in pull request #9395:
URL: https://github.com/apache/arrow/pull/9395#discussion_r577377611



##########
File path: cpp/src/arrow/tensor_test.cc
##########
@@ -152,6 +243,22 @@ TEST(TestTensor, MakeFailureCases) {
   // negative items in shape
   ASSERT_RAISES(Invalid, Tensor::Make(float64(), data, {-3, 6}));
 
+  // overflow in stride computation
+  constexpr uint64_t total_length =
+      1 + static_cast<uint64_t>(std::numeric_limits<int64_t>::max());
+  EXPECT_RAISES_WITH_MESSAGE_THAT(
+      Invalid,
+      testing::HasSubstr(
+          "Row-major strides computed from shape would not fit in 64-bit 
integer"),
+      Tensor::Make(float64(), data, {2, 2, static_cast<int64_t>(total_length / 
4)}));
+
+  // overflow by negative multiplication in strides validity check
+  EXPECT_RAISES_WITH_MESSAGE_THAT(
+      Invalid, testing::HasSubstr("would not fit in 64-bit integer"),
+      Tensor::Make(
+          float64(), data, {0, 4, 0},
+          {sizeof(double), -static_cast<int64_t>(total_length / 2), 
sizeof(double)}));

Review comment:
       I replaced this assertion with the new one to check that negative 
strides are prohibited.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to