Skip to content

Commit e055574

Browse files
committed
Update
[ghstack-poisoned]
1 parent 6f8a73d commit e055574

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static org.junit.Assert.assertTrue;
1313
import static org.junit.Assert.assertFalse;
1414
import static org.junit.Assert.assertNotEquals;
15+
import static org.junit.Assert.fail;
1516

1617
import com.facebook.jni.annotations.DoNotStrip;
1718

@@ -148,60 +149,70 @@ public void testAllIllegalCast() {
148149
assertFalse(evalue.isTensor());
149150
try {
150151
evalue.toTensor();
152+
fail("Should have thrown an exception");
151153
} catch (IllegalStateException e) {}
152154

153155
// try bool
154156
assertFalse(evalue.isBool());
155157
try {
156158
evalue.toBool();
159+
fail("Should have thrown an exception");
157160
} catch (IllegalStateException e) {}
158161

159162
// try int
160163
assertFalse(evalue.isInt());
161164
try {
162165
evalue.toInt();
166+
fail("Should have thrown an exception");
163167
} catch (IllegalStateException e) {}
164168

165169
// try double
166170
assertFalse(evalue.isDouble());
167171
try {
168172
evalue.toDouble();
173+
fail("Should have thrown an exception");
169174
} catch (IllegalStateException e) {}
170175

171176
// try string
172177
assertFalse(evalue.isString());
173178
try {
174179
evalue.toStr();
180+
fail("Should have thrown an exception");
175181
} catch (IllegalStateException e) {}
176182

177183
// try bool list
178184
assertFalse(evalue.isBoolList());
179185
try {
180186
evalue.toBoolList();
187+
fail("Should have thrown an exception");
181188
} catch (IllegalStateException e) {}
182189

183190
// try int list
184191
assertFalse(evalue.isIntList());
185192
try {
186193
evalue.toIntList();
194+
fail("Should have thrown an exception");
187195
} catch (IllegalStateException e) {}
188196

189197
// try double list
190198
assertFalse(evalue.isDoubleList());
191199
try {
192200
evalue.toBool();
201+
fail("Should have thrown an exception");
193202
} catch (IllegalStateException e) {}
194203

195204
// try Tensor list
196205
assertFalse(evalue.isTensorList());
197206
try {
198207
evalue.toTensorList();
208+
fail("Should have thrown an exception");
199209
} catch (IllegalStateException e) {}
200210

201211
// try optional Tensor list
202212
assertFalse(evalue.isOptionalTensorList());
203213
try {
204214
evalue.toOptionalTensorList();
215+
fail("Should have thrown an exception");
205216
} catch (IllegalStateException e) {}
206217
}
207218
}

0 commit comments

Comments
 (0)