You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: extension/android/executorch_android/src/test/java/org/pytorch/executorch/TensorTest.kt
+26-9Lines changed: 26 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -192,19 +192,29 @@ class TensorTest {
192
192
assertEquals(tensor.dtype(), DType.FLOAT)
193
193
194
194
assertThatThrownBy {
195
-
tensor.dataAsByteArray }.isInstanceOf(IllegalStateException::class.java).hasMessage("Tensor of type Tensor_float32 cannot return data as byte array.")
195
+
tensor.dataAsByteArray
196
+
}.isInstanceOf(IllegalStateException::class.java)
197
+
.hasMessage("Tensor of type Tensor_float32 cannot return data as byte array.")
196
198
197
199
assertThatThrownBy {
198
-
tensor.dataAsUnsignedByteArray }.isInstanceOf(IllegalStateException::class.java).hasMessage("Tensor of type Tensor_float32 cannot return data as unsigned byte array.")
200
+
tensor.dataAsUnsignedByteArray
201
+
}.isInstanceOf(IllegalStateException::class.java)
202
+
.hasMessage("Tensor of type Tensor_float32 cannot return data as unsigned byte array.")
199
203
200
204
assertThatThrownBy {
201
-
tensor.dataAsIntArray }.isInstanceOf(IllegalStateException::class.java).hasMessage("Tensor of type Tensor_float32 cannot return data as int array.")
205
+
tensor.dataAsIntArray
206
+
}.isInstanceOf(IllegalStateException::class.java)
207
+
.hasMessage("Tensor of type Tensor_float32 cannot return data as int array.")
202
208
203
209
assertThatThrownBy {
204
-
tensor.dataAsDoubleArray }.isInstanceOf(IllegalStateException::class.java).hasMessage("Tensor of type Tensor_float32 cannot return data as double array.")
210
+
tensor.dataAsDoubleArray
211
+
}.isInstanceOf(IllegalStateException::class.java)
212
+
.hasMessage("Tensor of type Tensor_float32 cannot return data as double array.")
205
213
206
214
assertThatThrownBy {
207
-
tensor.dataAsLongArray }.isInstanceOf(IllegalStateException::class.java).hasMessage("Tensor of type Tensor_float32 cannot return data as long array.")
215
+
tensor.dataAsLongArray
216
+
}.isInstanceOf(IllegalStateException::class.java)
217
+
.hasMessage("Tensor of type Tensor_float32 cannot return data as long array.")
208
218
}
209
219
210
220
@Test
@@ -214,16 +224,23 @@ class TensorTest {
214
224
val mismatchShape = longArrayOf(1, 2)
215
225
216
226
assertThatThrownBy {
217
-
Tensor.fromBlob(nullasFloatArray?, mismatchShape) }.isInstanceOf(IllegalArgumentException::class.java).hasMessage("Data array must be not null")
.hasMessage("Shape elements must be non negative")
224
239
225
240
assertThatThrownBy {
226
-
Tensor.fromBlob(data, mismatchShape) }.isInstanceOf(IllegalArgumentException::class.java).hasMessage("Inconsistent data capacity:4 and shape number elements:2 shape:[1, 2]")
0 commit comments