use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testWildcardDateSuperBoundaries.
@Test
public void testWildcardDateSuperBoundaries() {
WildcardType objectType = new WildcardTypeImpl(new Type[] { Object.class }, new Type[] { java.util.Date.class });
GenericClass integerClass = new GenericClass(Integer.class);
GenericClass comparableClass = new GenericClass(Comparable.class);
GenericClass dateClass = new GenericClass(java.util.Date.class);
GenericClass sqlDateClass = new GenericClass(java.sql.Date.class);
Assert.assertFalse(integerClass.satisfiesBoundaries(objectType));
Assert.assertFalse(comparableClass.satisfiesBoundaries(objectType));
Assert.assertTrue(dateClass.satisfiesBoundaries(objectType));
Assert.assertFalse(sqlDateClass.satisfiesBoundaries(objectType));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method test01.
@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
@Test
public void test01() throws Throwable {
/*
* This test case come from compilation issue found during SBST'13 competition:
*
* String string0 = vM0.run(vM0.stack);
*
* SUT at: http://www.massapi.com/source/jabref-2.6/src/java/net/sf/jabref/bst/VM.java.html
*
* Snippet of interest:
*
* 1) Stack<Object> stack = new Stack<Object>();
* 2) public String run(Collection<BibtexEntry> bibtex) {
*/
Collection<?> col0 = new Stack<Object>();
Collection<A> col1 = new Stack();
Collection col2 = new Stack();
Collection col3 = new Stack<Object>();
/*
* following does not compile
*
* Collection<A> col = new Stack<Object>();
*
* but it can be generated by EvoSuite
*/
GenericClass stack = new GenericClass(Stack.class).getWithWildcardTypes();
GenericClass collection = new GenericClass(Collection.class).getWithWildcardTypes();
Assert.assertTrue(stack.isAssignableTo(collection));
GenericClass objectStack = new GenericClass(col0.getClass());
Assert.assertTrue(objectStack.isAssignableTo(collection));
Type typeColA = new TypeToken<Collection<A>>() {
}.getType();
Type typeStack = new TypeToken<Stack>() {
}.getType();
Type typeObjectStack = new TypeToken<Stack<Object>>() {
}.getType();
GenericClass classColA = new GenericClass(typeColA);
GenericClass classStack = new GenericClass(typeStack).getWithWildcardTypes();
GenericClass classObjectStack = new GenericClass(typeObjectStack);
Assert.assertFalse(classStack.isAssignableTo(classColA));
Assert.assertFalse(classObjectStack.isAssignableTo(classColA));
Assert.assertFalse(classColA.isAssignableFrom(classObjectStack));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testWildcardComparableBoundaries.
@Test
public void testWildcardComparableBoundaries() {
WildcardType objectType = new WildcardTypeImpl(new Type[] { Comparable.class }, new Type[] {});
GenericClass integerClass = new GenericClass(Integer.class);
GenericClass comparableClass = new GenericClass(Comparable.class);
GenericClass dateClass = new GenericClass(java.util.Date.class);
GenericClass sqlDateClass = new GenericClass(java.sql.Date.class);
Assert.assertTrue(integerClass.satisfiesBoundaries(objectType));
Assert.assertTrue(comparableClass.satisfiesBoundaries(objectType));
Assert.assertTrue(dateClass.satisfiesBoundaries(objectType));
Assert.assertTrue(sqlDateClass.satisfiesBoundaries(objectType));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method test2.
@SuppressWarnings("rawtypes")
@Test
public void test2() {
Type listOfString = new TypeToken<List<String>>() {
}.getType();
Type plainList = new TypeToken<List>() {
}.getType();
Type objectList = new TypeToken<List<Object>>() {
}.getType();
GenericClass listOfStringClass = new GenericClass(listOfString);
GenericClass plainListClass = new GenericClass(plainList).getWithWildcardTypes();
GenericClass objectListClass = new GenericClass(objectList);
/*
* Note:
*
* List<String> l = new LinkedList<Object>();
*
* does not compile
*/
Assert.assertFalse(listOfStringClass.isAssignableTo(objectListClass));
Assert.assertFalse(listOfStringClass.isAssignableFrom(plainListClass));
Assert.assertTrue(listOfStringClass.isAssignableTo(plainListClass));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testAssignableObject.
@Test
public void testAssignableObject() {
GenericClass clazz1 = new GenericClass(Object.class);
GenericClass clazz2 = new GenericClass(Object.class);
Assert.assertTrue(clazz1.isAssignableTo(clazz2));
}
Aggregations