use of eu.stamp_project.dspot.amplifier.amplifiers.FastLiteralAmplifier in project dspot by STAMP-project.
the class TestDataMutatorTest method testCharacterMutation.
@Test
public void testCharacterMutation() throws Exception {
/*
Test the amplification on character literal
*/
final String nameMethod = "methodCharacter";
final char originalValue = 'z';
CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
RandomHelper.setSeedRandom(42L);
FastLiteralAmplifier mutator = getTestDataMutator(literalMutationClass);
CtMethod method = literalMutationClass.getMethod(nameMethod);
List<CtMethod> mutantMethods = mutator.amplify(method, 0).collect(Collectors.toList());
List<Character> expectedValues = Arrays.asList('\0', ' ', 'h', '{', 'y', System.getProperty("line.separator").charAt(0));
assertEquals(6, mutantMethods.size());
for (int i = 0; i < mutantMethods.size(); i++) {
CtMethod mutantMethod = mutantMethods.get(i);
assertEquals(nameMethod + SUFFIX_MUTATION + "Char" + (i + 1), mutantMethod.getSimpleName());
CtLiteral mutantLiteral = mutantMethod.getBody().getElements(new TypeFilter<>(CtLiteral.class)).get(0);
assertNotEquals(originalValue, mutantLiteral.getValue());
assertTrue(expectedValues.contains(mutantLiteral.getValue()));
}
}
use of eu.stamp_project.dspot.amplifier.amplifiers.FastLiteralAmplifier in project dspot by STAMP-project.
the class TestDataMutatorTest method testDoubleMutation.
@Test
public void testDoubleMutation() throws Exception {
/*
Test the amplification on numbers (double) literal
4 operations: i+1, i−1, i×2, i÷2
and 1 literals present that is different that the muted
*/
final String nameMethod = "methodDouble";
final double originalValue = 23.0D;
CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
RandomHelper.setSeedRandom(42L);
FastLiteralAmplifier amplifier = getTestDataMutator(literalMutationClass);
CtMethod method = literalMutationClass.getMethod(nameMethod);
List<Double> expectedValues = Arrays.asList(22.0D, 24.0D, 46.0D, (23.0D / 2.0D), 32.0D, 0.0D);
List<CtMethod> mutantMethods = amplifier.amplify(method, 0).collect(Collectors.toList());
assertEquals(6, mutantMethods.size());
for (int i = 0; i < mutantMethods.size(); i++) {
CtMethod mutantMethod = mutantMethods.get(i);
assertEquals(nameMethod + SUFFIX_MUTATION + "Number" + (i + 1), mutantMethod.getSimpleName());
CtLiteral mutantLiteral = mutantMethod.getBody().getElements(new TypeFilter<>(CtLiteral.class)).get(0);
assertNotEquals(originalValue, mutantLiteral.getValue());
assertTrue(expectedValues.contains(mutantLiteral.getValue()));
}
}
Aggregations