@@ -784,16 +784,30 @@ TEST_F(TensorPtrTest, TensorUint8BufferTooSmallExpectDeath) {
784
784
{ auto tensor = make_tensor_ptr ({2 , 2 }, std::move (data)); }, " " );
785
785
}
786
786
787
- TEST_F (TensorPtrTest, TensorUint8BufferTooLarge ) {
787
+ TEST_F (TensorPtrTest, TensorUint8BufferTooLargeExpectDeath ) {
788
788
std::vector<uint8_t > data (
789
- 4 * executorch::aten::elementSize (executorch::aten::ScalarType::Float));
790
- auto tensor = make_tensor_ptr ({2 , 2 }, std::move (data));
789
+ 5 * executorch::aten::elementSize (executorch::aten::ScalarType::Float));
790
+ ET_EXPECT_DEATH ({ auto _ = make_tensor_ptr ({2 , 2 }, std::move (data)); }, " " );
791
+ }
791
792
792
- EXPECT_EQ (tensor->dim (), 2 );
793
- EXPECT_EQ (tensor->size (0 ), 2 );
794
- EXPECT_EQ (tensor->size (1 ), 2 );
795
- EXPECT_EQ (tensor->strides ()[0 ], 2 );
796
- EXPECT_EQ (tensor->strides ()[1 ], 1 );
793
+ TEST_F (TensorPtrTest, VectorFloatTooSmallExpectDeath) {
794
+ std::vector<float > data (9 , 1 .f );
795
+ ET_EXPECT_DEATH ({ auto _ = make_tensor_ptr ({2 , 5 }, std::move (data)); }, " " );
796
+ }
797
+
798
+ TEST_F (TensorPtrTest, VectorFloatTooLargeExpectDeath) {
799
+ std::vector<float > data (11 , 1 .f );
800
+ ET_EXPECT_DEATH ({ auto _ = make_tensor_ptr ({2 , 5 }, std::move (data)); }, " " );
801
+ }
802
+
803
+ TEST_F (TensorPtrTest, VectorIntToFloatCastTooSmallExpectDeath) {
804
+ std::vector<int32_t > data (9 , 1 );
805
+ ET_EXPECT_DEATH ({ auto _ = make_tensor_ptr ({2 , 5 }, std::move (data)); }, " " );
806
+ }
807
+
808
+ TEST_F (TensorPtrTest, VectorIntToFloatCastTooLargeExpectDeath) {
809
+ std::vector<int32_t > data (11 , 1 );
810
+ ET_EXPECT_DEATH ({ auto _ = make_tensor_ptr ({2 , 5 }, std::move (data)); }, " " );
797
811
}
798
812
799
813
TEST_F (TensorPtrTest, StridesAndDimOrderMustMatchSizes) {
0 commit comments