Skip to content

Commit 05675ee

Browse files
author
Haiting Pu
committed
apply google java format
1 parent 6dec17b commit 05675ee

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

extension/android/executorch_android/src/test/java/org/pytorch/executorch/EValueTest.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,37 @@ class EValueTest {
7070
// try Tensor
7171
assertFalse(evalue.isTensor)
7272
assertThatThrownBy {
73-
evalue.toTensor() }.isInstanceOf(IllegalStateException::class.java).hasMessage("Expected EValue type Tensor, actual type None")
73+
evalue.toTensor()
74+
}.isInstanceOf(IllegalStateException::class.java)
75+
.hasMessage("Expected EValue type Tensor, actual type None")
7476

7577
// try bool
7678
assertFalse(evalue.isBool)
7779
assertThatThrownBy {
78-
evalue.toBool() }.isInstanceOf(IllegalStateException::class.java).hasMessage("Expected EValue type Bool, actual type None")
80+
evalue.toBool()
81+
}.isInstanceOf(IllegalStateException::class.java)
82+
.hasMessage("Expected EValue type Bool, actual type None")
7983

8084
// try int
8185
assertFalse(evalue.isInt)
8286
assertThatThrownBy {
83-
evalue.toInt() }.isInstanceOf(IllegalStateException::class.java).hasMessage("Expected EValue type Int, actual type None")
87+
evalue.toInt()
88+
}.isInstanceOf(IllegalStateException::class.java)
89+
.hasMessage("Expected EValue type Int, actual type None")
8490

8591
// try double
8692
assertFalse(evalue.isDouble)
8793
assertThatThrownBy {
88-
evalue.toDouble() }.isInstanceOf(IllegalStateException::class.java).hasMessage("Expected EValue type Double, actual type None")
94+
evalue.toDouble()
95+
}.isInstanceOf(IllegalStateException::class.java)
96+
.hasMessage("Expected EValue type Double, actual type None")
8997

9098
// try string
9199
assertFalse(evalue.isString)
92100
assertThatThrownBy {
93-
evalue.toStr() }.isInstanceOf(IllegalStateException::class.java).hasMessage("Expected EValue type String, actual type None")
101+
evalue.toStr()
102+
}.isInstanceOf(IllegalStateException::class.java)
103+
.hasMessage("Expected EValue type String, actual type None")
94104
}
95105

96106
@Test

extension/android/executorch_android/src/test/java/org/pytorch/executorch/TensorTest.kt

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,19 +192,29 @@ class TensorTest {
192192
assertEquals(tensor.dtype(), DType.FLOAT)
193193

194194
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.")
196198

197199
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.")
199203

200204
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.")
202208

203209
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.")
205213

206214
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.")
208218
}
209219

210220
@Test
@@ -214,16 +224,23 @@ class TensorTest {
214224
val mismatchShape = longArrayOf(1, 2)
215225

216226
assertThatThrownBy {
217-
Tensor.fromBlob(null as FloatArray?, mismatchShape) }.isInstanceOf(IllegalArgumentException::class.java).hasMessage("Data array must be not null")
227+
Tensor.fromBlob(null as FloatArray?, mismatchShape)
228+
}.isInstanceOf(IllegalArgumentException::class.java)
229+
.hasMessage("Data array must be not null")
218230

219231
assertThatThrownBy {
220-
Tensor.fromBlob(data, null) }.isInstanceOf(IllegalArgumentException::class.java).hasMessage("Shape must be not null")
232+
Tensor.fromBlob(data, null)
233+
}.isInstanceOf(IllegalArgumentException::class.java).hasMessage("Shape must be not null")
221234

222235
assertThatThrownBy {
223-
Tensor.fromBlob(data, shapeWithNegativeValues) }.isInstanceOf(IllegalArgumentException::class.java).hasMessage("Shape elements must be non negative")
236+
Tensor.fromBlob(data, shapeWithNegativeValues)
237+
}.isInstanceOf(IllegalArgumentException::class.java)
238+
.hasMessage("Shape elements must be non negative")
224239

225240
assertThatThrownBy {
226-
Tensor.fromBlob(data, mismatchShape) }.isInstanceOf(IllegalArgumentException::class.java).hasMessage("Inconsistent data capacity:4 and shape number elements:2 shape:[1, 2]")
241+
Tensor.fromBlob(data, mismatchShape)
242+
}.isInstanceOf(IllegalArgumentException::class.java)
243+
.hasMessage("Inconsistent data capacity:4 and shape number elements:2 shape:[1, 2]")
227244
}
228245

229246
@Test

0 commit comments

Comments
 (0)