Open
Description
Description
Fuzzer tries to put arbitrary Objects
into StringMap
To Reproduce
- Set fuzzing to
100%
- Generate tests for the following class
public class StringMap extends HashMap<String, String> {
public String getAnyString() {
return keySet().iterator().next();
}
}
Expected behavior
There's one passing and one failing test.
Actual behavior
No passing tests are generated, one of the tests fails to compile with the following error: "incompatible types: Object
cannot be converted to String
stringMap.put(object, object1);
".
Visual proofs (screenshots, logs, images)
/**
* @utbot.classUnderTest {@link StringMap}
* @utbot.methodUnderTest {@link StringMap#getAnyString()}
*/
@Test
@DisplayName("getAnyString: -> throw ClassCastException")
public void testGetAnyStringThrowsCCE() {
StringMap stringMap = new StringMap();
Object object = new Object();
Object object1 = new Object();
stringMap.put(object, object1);
/* This test fails because method [org.example.StringMap.getAnyString] produces [java.lang.ClassCastException: class java.lang.Object cannot be cast to class java.lang.String (java.lang.Object and java.lang.String are in module java.base of loader 'bootstrap')]
org.example.StringMap.getAnyString(StringMap.java:7) */
stringMap.getAnyString();
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
In Progress