Search in sources :

Example 11 with ConstantValue

use of org.evosuite.testcase.variable.ConstantValue in project evosuite by EvoSuite.

the class TestOverloading method testOverloadedConstructorBigFraction.

@Test
public void testOverloadedConstructorBigFraction() {
    Class<?> clazz = BigFraction.class;
    Constructor<?> constructor1 = clazz.getConstructors()[0];
    Constructor<?> constructor2 = clazz.getConstructors()[1];
    GenericConstructor genericConstructor1 = new GenericConstructor(constructor1, clazz);
    GenericConstructor genericConstructor2 = new GenericConstructor(constructor2, clazz);
    TestCase test = new DefaultTestCase();
    ConstantValue longValue = new ConstantValue(test, long.class);
    ConstantValue intValue = new ConstantValue(test, int.class);
    List<VariableReference> parameters = Arrays.asList(longValue, intValue);
    assertTrue(genericConstructor1.isOverloaded(parameters));
    assertTrue(genericConstructor2.isOverloaded(parameters));
}
Also used : BigFraction(com.examples.with.different.packagename.utils.generic.BigFraction) VariableReference(org.evosuite.testcase.variable.VariableReference) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) TestCase(org.evosuite.testcase.TestCase) DefaultTestCase(org.evosuite.testcase.DefaultTestCase) ConstantValue(org.evosuite.testcase.variable.ConstantValue) Test(org.junit.Test)

Example 12 with ConstantValue

use of org.evosuite.testcase.variable.ConstantValue in project evosuite by EvoSuite.

the class ValueMinimizer method visitStatement.

@Override
public void visitStatement(Statement statement) {
    for (VariableReference var : statement.getVariableReferences()) {
        if (var instanceof ConstantValue) {
            ConstantValue constantValue = (ConstantValue) var;
            Object value = constantValue.getValue();
            if (value instanceof String) {
                logger.info("Statement before minimization: " + statement.getCode());
                cleanString(constantValue);
                removeCharacters(constantValue);
                if (Properties.LM_STRINGS) {
                    replaceWithLanguageModel(constantValue);
                }
                logger.info("Statement after minimization: " + statement.getCode());
            // TODO: Try to delete characters, or at least replace non-ascii characters with ascii characters
            } else if (value instanceof Number) {
                logger.info("Statement before minimization: " + statement.getCode());
                binarySearch(constantValue, (Number) constantValue.getValue());
                logger.info("Statement after minimization: " + statement.getCode());
            }
        }
    }
}
Also used : VariableReference(org.evosuite.testcase.variable.VariableReference) ConstantValue(org.evosuite.testcase.variable.ConstantValue)

Aggregations

ConstantValue (org.evosuite.testcase.variable.ConstantValue)12 VariableReference (org.evosuite.testcase.variable.VariableReference)12 DefaultTestCase (org.evosuite.testcase.DefaultTestCase)5 TestCase (org.evosuite.testcase.TestCase)5 Test (org.junit.Test)5 VariableReferenceImpl (org.evosuite.testcase.variable.VariableReferenceImpl)4 CodeUnderTestException (org.evosuite.testcase.execution.CodeUnderTestException)3 GenericClass (org.evosuite.utils.generic.GenericClass)3 ClassWithOverloadedMethods (com.examples.with.different.packagename.utils.generic.ClassWithOverloadedMethods)2 ClassWithoutOverloadedMethods (com.examples.with.different.packagename.utils.generic.ClassWithoutOverloadedMethods)2 Method (java.lang.reflect.Method)2 MethodStatement (org.evosuite.testcase.statements.MethodStatement)2 BigFraction (com.examples.with.different.packagename.utils.generic.BigFraction)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 EqualsAssertion (org.evosuite.assertion.EqualsAssertion)1 AssignmentStatement (org.evosuite.testcase.statements.AssignmentStatement)1 EntityWithParametersStatement (org.evosuite.testcase.statements.EntityWithParametersStatement)1 FieldStatement (org.evosuite.testcase.statements.FieldStatement)1