Search in sources :

Example 11 with NumberLiteralAmplifier

use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.

the class NumberLiteralAmplifierTest method testLongMutation.

@Test
public void testLongMutation() {
    final String nameMethod = "methodLong";
    final long originalValue = 23L;
    CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
    RandomHelper.setSeedRandom(42L);
    NumberLiteralAmplifier amplifier = getAmplifier(literalMutationClass);
    CtMethod method = literalMutationClass.getMethod(nameMethod);
    List<Long> expectedValues = Arrays.asList(22L, 24L, 0L, -935319508L);
    List<String> expectedFieldReads = Arrays.asList("java.lang.Long.MAX_VALUE", "java.lang.Long.MIN_VALUE");
    List<CtMethod> mutantMethods = amplifier.amplify(method, 0).collect(Collectors.toList());
    callAssertions(mutantMethods, nameMethod, expectedValues, expectedFieldReads, originalValue, 6);
}
Also used : NumberLiteralAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Example 12 with NumberLiteralAmplifier

use of eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier in project dspot by STAMP-project.

the class NumberLiteralAmplifierTest method testByteMutation.

@Test
public void testByteMutation() {
    final String nameMethod = "methodByte";
    final byte originalValue = 23;
    CtClass<Object> literalMutationClass = launcher.getFactory().Class().get("fr.inria.amp.LiteralMutation");
    RandomHelper.setSeedRandom(42L);
    NumberLiteralAmplifier amplifier = getAmplifier(literalMutationClass);
    CtMethod method = literalMutationClass.getMethod(nameMethod);
    List<Byte> expectedValues = Arrays.asList((byte) 22, (byte) 24, (byte) 0, (byte) 53);
    List<String> expectedFieldReads = Arrays.asList("java.lang.Byte.MAX_VALUE", "java.lang.Byte.MIN_VALUE");
    List<CtMethod> mutantMethods = amplifier.amplify(method, 0).collect(Collectors.toList());
    callAssertions(mutantMethods, nameMethod, expectedValues, expectedFieldReads, originalValue, 6);
}
Also used : NumberLiteralAmplifier(eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Aggregations

NumberLiteralAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.NumberLiteralAmplifier)12 Test (org.junit.Test)10 CtMethod (spoon.reflect.declaration.CtMethod)10 Amplifier (eu.stamp_project.dspot.amplifier.amplifiers.Amplifier)3 AbstractLiteralAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.AbstractLiteralAmplifier)2 IterationDecoratorAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.IterationDecoratorAmplifier)2 StringLiteralAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.StringLiteralAmplifier)2 ArrayList (java.util.ArrayList)2 AbstractTestOnSample (eu.stamp_project.dspot.AbstractTestOnSample)1 SimpleInputAmplDistributor (eu.stamp_project.dspot.amplifier.SimpleInputAmplDistributor)1 MethodAdderOnExistingObjectsAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.MethodAdderOnExistingObjectsAmplifier)1 ReturnValueAmplifier (eu.stamp_project.dspot.amplifier.amplifiers.ReturnValueAmplifier)1 RandomHelper (eu.stamp_project.dspot.amplifier.amplifiers.utils.RandomHelper)1 TestFramework (eu.stamp_project.dspot.common.test_framework.TestFramework)1 Collections (java.util.Collections)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1