Skip to content

Commit 1f3de41

Browse files
committed
add test
1 parent d7ff095 commit 1f3de41

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Diff for: utbot-framework-test/src/test/kotlin/org/utbot/examples/casts/InstanceOfExampleTest.kt

+10
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,16 @@ internal class InstanceOfExampleTest : UtValueTestCaseChecker(
404404
)
405405
}
406406

407+
@Test
408+
fun testInstanceOfString() {
409+
check(
410+
InstanceOfExample::instanceOfString,
411+
eq(2),
412+
{ cs, r -> cs == null && r == Unit },
413+
{ cs, r -> cs is String && r == null }
414+
)
415+
}
416+
407417

408418
private inline fun <reified T : Any> Any?.isInstanceOfArray() =
409419
(this as? Array<*>)?.run { T::class.java.isAssignableFrom(this::class.java.componentType) } == true

Diff for: utbot-sample/src/main/java/org/utbot/examples/casts/InstanceOfExample.java

+6
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,10 @@ public Object[] instanceOfObjectArray(Object[] array) {
322322

323323
return array;
324324
}
325+
326+
public void instanceOfString(CharSequence cs) {
327+
if (cs instanceof String) {
328+
throw new IllegalStateException("CharSequence must not be a String");
329+
}
330+
}
325331
}

0 commit comments

Comments
 (0)