7
7
*/
8
8
9
9
#include < executorch/runtime/core/portable_type/tensor.h>
10
- # include < executorch/test/utils/DeathTest.h >
10
+
11
11
#include < gtest/gtest.h>
12
12
13
+ #include < executorch/runtime/platform/runtime.h>
14
+ #include < executorch/test/utils/DeathTest.h>
15
+
13
16
namespace torch {
14
17
namespace executor {
15
18
16
- TEST (TensorTest, InvalidScalarType) {
19
+ class TensorTest : public ::testing::Test {
20
+ protected:
21
+ void SetUp () override {
22
+ // Since these tests cause ET_LOG to be called, the PAL must be initialized
23
+ // first.
24
+ runtime_init ();
25
+ }
26
+ };
27
+
28
+ TEST_F (TensorTest, InvalidScalarType) {
17
29
TensorImpl::SizesType sizes[1 ] = {1 };
18
30
19
31
// Undefined, which is sort of a special case since it's not part of the
@@ -28,7 +40,7 @@ TEST(TensorTest, InvalidScalarType) {
28
40
ET_EXPECT_DEATH ({ TensorImpl y (static_cast <ScalarType>(-1 ), 1 , sizes); }, " " );
29
41
}
30
42
31
- TEST (TensorTest, SetData) {
43
+ TEST_F (TensorTest, SetData) {
32
44
TensorImpl::SizesType sizes[1 ] = {5 };
33
45
TensorImpl::DimOrderType dim_order[1 ] = {0 };
34
46
int32_t data[5 ] = {0 , 0 , 1 , 0 , 0 };
@@ -39,7 +51,7 @@ TEST(TensorTest, SetData) {
39
51
EXPECT_EQ (a.const_data_ptr (), nullptr );
40
52
}
41
53
42
- TEST (TensorTest, Strides) {
54
+ TEST_F (TensorTest, Strides) {
43
55
TensorImpl::SizesType sizes[2 ] = {2 , 2 };
44
56
TensorImpl::DimOrderType dim_order[2 ] = {0 , 1 };
45
57
int32_t data[4 ] = {0 , 0 , 1 , 1 };
@@ -53,7 +65,7 @@ TEST(TensorTest, Strides) {
53
65
EXPECT_EQ (a.const_data_ptr <int32_t >()[0 + a.strides ()[0 ]], 1 );
54
66
}
55
67
56
- TEST (TensorTest, ModifyDataOfConstTensor) {
68
+ TEST_F (TensorTest, ModifyDataOfConstTensor) {
57
69
TensorImpl::SizesType sizes[1 ] = {1 };
58
70
TensorImpl::DimOrderType dim_order[2 ] = {0 };
59
71
int32_t data[1 ] = {1 };
0 commit comments