public VariableReference appendBooleanPrimitive(boolean b) { BooleanPrimitiveStatement primitiveStmt = new BooleanPrimitiveStatement( tc, b); tc.addStatement(primitiveStmt); return primitiveStmt.getReturnValue(); }
/** {@inheritDoc} */ @Override public void decrement() { delta(); }
BooleanPrimitiveStatement stmt1 = new BooleanPrimitiveStatement(test, true); VariableReference boolean0 = test.addStatement(stmt1);
private void after(BooleanPrimitiveStatement statement, Scope scope) { boolean valueOf = statement.getValue(); VariableReference varRef = statement.getReturnValue(); String varRefName = varRef.getName(); IntegerVariable integerVariable = buildIntegerVariable(varRefName, valueOf ? 1 : 0, 0, 1); Boolean boolean_instance; try { boolean_instance = (Boolean) varRef.getObject(scope); } catch (CodeUnderTestException e) { throw new EvosuiteError(e); } symb_expressions.put(varRefName, integerVariable); ReferenceConstant booleanRef = newBooleanReference(boolean_instance, integerVariable); symb_references.put(varRefName, booleanRef); }
if (p instanceof BooleanPrimitiveStatement) { BooleanPrimitiveStatement bp = (BooleanPrimitiveStatement) p; bp.setValue(value.intValue() > 0); } else if (p instanceof CharPrimitiveStatement) { CharPrimitiveStatement cp = (CharPrimitiveStatement) p;
statement = new BooleanPrimitiveStatement(tc); } else if (clazz == int.class) { statement = new IntPrimitiveStatement(tc);
@Test public void testInputCoverageClassWithField() throws NoSuchFieldException, NoSuchMethodException { Class<?> sut = ClassWithField.class; DefaultTestCase tc = new DefaultTestCase(); // ClassWithField classWithField0 = new ClassWithField(); GenericConstructor constructor = new GenericConstructor(sut.getConstructors()[0], sut); ConstructorStatement constructorStatement = new ConstructorStatement(tc, constructor, Arrays.asList(new VariableReference[] {})); VariableReference obj = tc.addStatement(constructorStatement); // classWithField0.testFoo(classWithField0.BOOLEAN_FIELD); FieldReference field = new FieldReference(tc, new GenericField(sut.getDeclaredField("BOOLEAN_FIELD"), sut),obj); Method m = sut.getMethod("testFoo", new Class<?>[] { Boolean.TYPE}); GenericMethod gm = new GenericMethod(m, sut); tc.addStatement(new MethodStatement(tc, gm, obj, Arrays.asList(new VariableReference[] {field}))); // classWithField0.BOOLEAN_FIELD = false; VariableReference boolRef = tc.addStatement(new BooleanPrimitiveStatement(tc,false)); tc.addStatement(new AssignmentStatement(tc, field, boolRef)); tc.addStatement(new MethodStatement(tc, gm, obj, Arrays.asList(new VariableReference[] {field}))); Properties.TARGET_CLASS = sut.getCanonicalName(); Properties.JUNIT_TESTS = true; TestSuiteChromosome testSuite = new TestSuiteChromosome(); testSuite.addTest(tc); FitnessFunction ffunction = FitnessFunctions.getFitnessFunction(Properties.Criterion.INPUT); assertEquals("Should be 0.0", 0.0, ffunction.getFitness(testSuite), 0.0); assertEquals("Should be 1.0", 1.0, testSuite.getCoverage(ffunction), 0.0); }
/** {@inheritDoc} */ @Override public void increment(long delta) { delta(); }
tch1.getTestCase().addStatement(new BooleanPrimitiveStatement(tch1.getTestCase(),true)); tch1.setFitness(f1, 1); tch1.setFitness(f2, 0.5); TestChromosome tch4 = new TestChromosome(); tch4.setTestCase(new DefaultTestCase()); tch4.getTestCase().addStatement(new BooleanPrimitiveStatement(tch4.getTestCase(),false)); tch4.setFitness(f1, 0.5); tch4.setFitness(f2, 2);
/** {@inheritDoc} */ @Override public void increment() { delta(); }
VariableReference boolRef = tc.addStatement(new BooleanPrimitiveStatement(tc,true)); VariableReference ref = new VariableReferenceImpl(tc, Foo.class); FunctionalMockStatement mockStmt = new FunctionalMockStatement(tc, ref, new GenericClass(Foo.class));