|
12 | 12 | import static org.junit.Assert.assertTrue; |
13 | 13 | import static org.junit.Assert.assertFalse; |
14 | 14 | import static org.junit.Assert.assertNotEquals; |
| 15 | +import static org.junit.Assert.fail; |
15 | 16 |
|
16 | 17 | import com.facebook.jni.annotations.DoNotStrip; |
17 | 18 |
|
@@ -148,60 +149,70 @@ public void testAllIllegalCast() { |
148 | 149 | assertFalse(evalue.isTensor()); |
149 | 150 | try { |
150 | 151 | evalue.toTensor(); |
| 152 | + fail("Should have thrown an exception"); |
151 | 153 | } catch (IllegalStateException e) {} |
152 | 154 |
|
153 | 155 | // try bool |
154 | 156 | assertFalse(evalue.isBool()); |
155 | 157 | try { |
156 | 158 | evalue.toBool(); |
| 159 | + fail("Should have thrown an exception"); |
157 | 160 | } catch (IllegalStateException e) {} |
158 | 161 |
|
159 | 162 | // try int |
160 | 163 | assertFalse(evalue.isInt()); |
161 | 164 | try { |
162 | 165 | evalue.toInt(); |
| 166 | + fail("Should have thrown an exception"); |
163 | 167 | } catch (IllegalStateException e) {} |
164 | 168 |
|
165 | 169 | // try double |
166 | 170 | assertFalse(evalue.isDouble()); |
167 | 171 | try { |
168 | 172 | evalue.toDouble(); |
| 173 | + fail("Should have thrown an exception"); |
169 | 174 | } catch (IllegalStateException e) {} |
170 | 175 |
|
171 | 176 | // try string |
172 | 177 | assertFalse(evalue.isString()); |
173 | 178 | try { |
174 | 179 | evalue.toStr(); |
| 180 | + fail("Should have thrown an exception"); |
175 | 181 | } catch (IllegalStateException e) {} |
176 | 182 |
|
177 | 183 | // try bool list |
178 | 184 | assertFalse(evalue.isBoolList()); |
179 | 185 | try { |
180 | 186 | evalue.toBoolList(); |
| 187 | + fail("Should have thrown an exception"); |
181 | 188 | } catch (IllegalStateException e) {} |
182 | 189 |
|
183 | 190 | // try int list |
184 | 191 | assertFalse(evalue.isIntList()); |
185 | 192 | try { |
186 | 193 | evalue.toIntList(); |
| 194 | + fail("Should have thrown an exception"); |
187 | 195 | } catch (IllegalStateException e) {} |
188 | 196 |
|
189 | 197 | // try double list |
190 | 198 | assertFalse(evalue.isDoubleList()); |
191 | 199 | try { |
192 | 200 | evalue.toBool(); |
| 201 | + fail("Should have thrown an exception"); |
193 | 202 | } catch (IllegalStateException e) {} |
194 | 203 |
|
195 | 204 | // try Tensor list |
196 | 205 | assertFalse(evalue.isTensorList()); |
197 | 206 | try { |
198 | 207 | evalue.toTensorList(); |
| 208 | + fail("Should have thrown an exception"); |
199 | 209 | } catch (IllegalStateException e) {} |
200 | 210 |
|
201 | 211 | // try optional Tensor list |
202 | 212 | assertFalse(evalue.isOptionalTensorList()); |
203 | 213 | try { |
204 | 214 | evalue.toOptionalTensorList(); |
| 215 | + fail("Should have thrown an exception"); |
205 | 216 | } catch (IllegalStateException e) {} |
206 | 217 | } |
207 | 218 | } |
0 commit comments