Student.java

1
package edu.ucsb.cs156.student;
2
public class Student {
3
    private String name;
4
    private int perm;
5
6
    public Student() {
7
        name = "Sample Student";
8
        perm = 999999;
9
    }
10
11
    public Student(String name, int perm) {
12
13 1 1. <init> : negated conditional → KILLED
        if (!validPerm(perm)) {
14
            throw new IllegalArgumentException("Unacceptable value for perm: " + perm);
15
        }
16
17
        this.name = name;
18
        this.perm = perm;
19
    }
20
21
    public String getName() {
22 1 1. getName : replaced return value with "" for edu/ucsb/cs156/student/Student::getName → KILLED
        return this.name;
23
    }
24
25
    public int getPerm() {
26 1 1. getPerm : replaced int return with 0 for edu/ucsb/cs156/student/Student::getPerm → KILLED
        return this.perm;
27
    }
28
29
    @Override
30
    public String toString() {
31 1 1. toString : replaced return value with "" for edu/ucsb/cs156/student/Student::toString → KILLED
        return "[name: " + this.name + ", perm: " + this.perm + "]";
32
    }
33
34
    public static boolean validPerm(int perm) {
35 4 1. validPerm : changed conditional boundary → SURVIVED
2. validPerm : changed conditional boundary → KILLED
3. validPerm : negated conditional → KILLED
4. validPerm : negated conditional → KILLED
        if (perm < 1 || perm > 9999999) {
36 1 1. validPerm : replaced boolean return with true for edu/ucsb/cs156/student/Student::validPerm → KILLED
            return false;
37
        }
38 2 1. validPerm : changed conditional boundary → SURVIVED
2. validPerm : negated conditional → KILLED
        if (perm <= 999999)
39 1 1. validPerm : replaced boolean return with false for edu/ucsb/cs156/student/Student::validPerm → KILLED
           return true;
40 1 1. validPerm : Replaced integer modulus with multiplication → KILLED
        int lastDigit = perm % 10;
41 1 1. validPerm : Replaced integer division with multiplication → KILLED
        int firstSix = perm / 10;
42 2 1. validPerm : replaced boolean return with true for edu/ucsb/cs156/student/Student::validPerm → SURVIVED
2. validPerm : negated conditional → KILLED
        return lastDigit == Luhn.checkDigit(firstSix);
43
    }
44
45
}

Mutations

13

1.1
Location : <init>
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_constructor_negPerm()]
negated conditional → KILLED

22

1.1
Location : getName
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_getName1()]
replaced return value with "" for edu/ucsb/cs156/student/Student::getName → KILLED

26

1.1
Location : getPerm
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_getPerm1()]
replaced int return with 0 for edu/ucsb/cs156/student/Student::getPerm → KILLED

31

1.1
Location : toString
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_toString1()]
replaced return value with "" for edu/ucsb/cs156/student/Student::toString → KILLED

35

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

2.2
Location : validPerm
Killed by : none
changed conditional boundary → SURVIVED

3.3
Location : validPerm
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_validPerm_neg1_false()]
negated conditional → KILLED

4.4
Location : validPerm
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_constructor_perm_1_ok()]
negated conditional → KILLED

36

1.1
Location : validPerm
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_validPerm_neg1_false()]
replaced boolean return with true for edu/ucsb/cs156/student/Student::validPerm → KILLED

38

1.1
Location : validPerm
Killed by : none
changed conditional boundary → SURVIVED

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

39

1.1
Location : validPerm
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_constructor_perm_1_ok()]
replaced boolean return with false for edu/ucsb/cs156/student/Student::validPerm → KILLED

40

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

41

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

42

1.1
Location : validPerm
Killed by : edu.ucsb.cs156.student.StudentTest.[engine:junit-jupiter]/[class:edu.ucsb.cs156.student.StudentTest]/[method:test_getName2()]
negated conditional → KILLED

2.2
Location : validPerm
Killed by : none
replaced boolean return with true for edu/ucsb/cs156/student/Student::validPerm → SURVIVED

Active mutators

Tests examined


Report generated by PIT 1.7.3