Luhn.java

1
package edu.ucsb.cs156.student;
2
3
public class Luhn {
4
5
    public static int checkDigit(int num) {
6
        
7
        int currentPlace = 0;
8
        int sumOfDigits = 0;
9
10 2 1. checkDigit : changed conditional boundary → TIMED_OUT
2. checkDigit : negated conditional → KILLED
        while (num > 0) {
11 1 1. checkDigit : Changed increment from 1 to -1 → KILLED
            currentPlace += 1;
12 1 1. checkDigit : Replaced integer modulus with multiplication → KILLED
            int leastSigDigit = num % 10;
13
            int thisValue = leastSigDigit;
14
15 2 1. checkDigit : Replaced integer modulus with multiplication → KILLED
2. checkDigit : negated conditional → KILLED
            if (currentPlace % 2 == 1) {
16 1 1. checkDigit : Replaced integer multiplication with division → KILLED
                thisValue = leastSigDigit * 2;
17
            }
18
19 2 1. checkDigit : changed conditional boundary → KILLED
2. checkDigit : negated conditional → KILLED
            if (thisValue <= 9)
20 1 1. checkDigit : Replaced integer addition with subtraction → KILLED
                sumOfDigits += thisValue;
21
            else
22 3 1. checkDigit : Replaced integer modulus with multiplication → KILLED
2. checkDigit : Replaced integer addition with subtraction → KILLED
3. checkDigit : Replaced integer addition with subtraction → KILLED
                sumOfDigits += 1 + (thisValue % 10);
23 1 1. checkDigit : Replaced integer division with multiplication → KILLED
            num = num / 10;
24
        }
25
26 3 1. checkDigit : Replaced integer multiplication with division → KILLED
2. checkDigit : Replaced integer modulus with multiplication → KILLED
3. checkDigit : replaced int return with 0 for edu/ucsb/cs156/student/Luhn::checkDigit → KILLED
        return ( sumOfDigits * 9 ) % 10;
27
    }
28
29
    public static void main(String [] args) {
30 1 1. main : removed call to java/io/PrintStream::println → NO_COVERAGE
        System.out.println(checkDigit(Integer.parseInt(args[0])));
31
    }
32
33
}

Mutations

10

1.1
Location : checkDigit
Killed by : none
changed conditional boundary → TIMED_OUT

2.2
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
negated conditional → KILLED

11

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Changed increment from 1 to -1 → KILLED

12

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer modulus with multiplication → KILLED

15

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer modulus with multiplication → KILLED

2.2
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
negated conditional → KILLED

16

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer multiplication with division → KILLED

19

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_constructor_perm_9999996_ok()]
changed conditional boundary → KILLED

2.2
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
negated conditional → KILLED

20

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer addition with subtraction → KILLED

22

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer modulus with multiplication → KILLED

2.2
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer addition with subtraction → KILLED

3.3
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer addition with subtraction → KILLED

23

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer division with multiplication → KILLED

26

1.1
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer multiplication with division → KILLED

2.2
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
Replaced integer modulus with multiplication → KILLED

3.3
Location : checkDigit
Killed by : edu.ucsb.cs156.student.LuhnTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.LuhnTest]/[method:test_luhn_123456()]
replaced int return with 0 for edu/ucsb/cs156/student/Luhn::checkDigit → KILLED

30

1.1
Location : main
Killed by : none
removed call to java/io/PrintStream::println → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.7.3