PowerpointRun.java

1
package pro.verron.officestamper.experimental;
2
3
import org.docx4j.dml.CTRegularTextRun;
4
5
/**
6
 * Represents a run within a PowerPoint slide.
7
 */
8
public record PowerpointRun(
9
        int startIndex,
10
        int endIndex,
11
        int indexInParent,
12
        CTRegularTextRun run
13
) {
14
    /**
15
     * Checks if the given range of indices touches the start or end index of the run.
16
     *
17
     * @param globalStartIndex the start index of the global range.
18
     * @param globalEndIndex   the end index of the global range.
19
     *
20
     * @return {@code true} if the range touches the start or end index of the run, {@code false} otherwise.
21
     */
22
    public boolean isTouchedByRange(int globalStartIndex, int globalEndIndex) {
23 13 1. isTouchedByRange : changed conditional boundary → SURVIVED
2. isTouchedByRange : negated conditional → NO_COVERAGE
3. isTouchedByRange : changed conditional boundary → SURVIVED
4. isTouchedByRange : changed conditional boundary → NO_COVERAGE
5. isTouchedByRange : negated conditional → NO_COVERAGE
6. isTouchedByRange : negated conditional → NO_COVERAGE
7. isTouchedByRange : negated conditional → SURVIVED
8. isTouchedByRange : negated conditional → SURVIVED
9. isTouchedByRange : replaced boolean return with true for pro/verron/officestamper/experimental/PowerpointRun::isTouchedByRange → SURVIVED
10. isTouchedByRange : changed conditional boundary → NO_COVERAGE
11. isTouchedByRange : negated conditional → NO_COVERAGE
12. isTouchedByRange : changed conditional boundary → NO_COVERAGE
13. isTouchedByRange : changed conditional boundary → NO_COVERAGE
        return ((startIndex >= globalStartIndex) && (startIndex <= globalEndIndex))
24
                || ((endIndex >= globalStartIndex) && (endIndex <= globalEndIndex))
25
                || ((startIndex <= globalStartIndex) && (endIndex >= globalEndIndex));
26
    }
27
28
    /**
29
     * Replaces a substring within the run's text.
30
     *
31
     * @param globalStartIndex the start index of the substring to be replaced.
32
     * @param globalEndIndex   the end index of the substring to be replaced.
33
     * @param replacement      the replacement string.
34
     */
35
    public void replace(
36
            int globalStartIndex,
37
            int globalEndIndex,
38
            String replacement
39
    ) {
40
        int localStartIndex = globalIndexToLocalIndex(globalStartIndex);
41
        int localEndIndex = globalIndexToLocalIndex(globalEndIndex);
42
        var source = run.getT();
43 1 1. replace : Replaced integer addition with subtraction → KILLED
        var target = source.substring(0, localStartIndex)
44
                + replacement
45
                + source.substring(localEndIndex + 1);
46 1 1. replace : removed call to org/docx4j/dml/CTRegularTextRun::setT → KILLED
        run.setT(target);
47
    }
48
49
    private int globalIndexToLocalIndex(int globalIndex) {
50 2 1. globalIndexToLocalIndex : changed conditional boundary → SURVIVED
2. globalIndexToLocalIndex : negated conditional → KILLED
        if (globalIndex < startIndex) return 0;
51 3 1. globalIndexToLocalIndex : changed conditional boundary → SURVIVED
2. globalIndexToLocalIndex : replaced int return with 0 for pro/verron/officestamper/experimental/PowerpointRun::globalIndexToLocalIndex → KILLED
3. globalIndexToLocalIndex : negated conditional → KILLED
        else if (globalIndex > endIndex) return lastIndex();
52 2 1. globalIndexToLocalIndex : replaced int return with 0 for pro/verron/officestamper/experimental/PowerpointRun::globalIndexToLocalIndex → SURVIVED
2. globalIndexToLocalIndex : Replaced integer subtraction with addition → KILLED
        else return globalIndex - startIndex;
53
    }
54
55
    private int lastIndex() {
56 1 1. lastIndex : replaced int return with 0 for pro/verron/officestamper/experimental/PowerpointRun::lastIndex → KILLED
        return lastIndex(run.getT());
57
    }
58
59
    private int lastIndex(String string) {
60 2 1. lastIndex : Replaced integer subtraction with addition → KILLED
2. lastIndex : replaced int return with 0 for pro/verron/officestamper/experimental/PowerpointRun::lastIndex → KILLED
        return string.length() - 1;
61
    }
62
}

Mutations

23

1.1
Location : isTouchedByRange
Killed by : none
changed conditional boundary → SURVIVED
Covering tests

2.2
Location : isTouchedByRange
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : isTouchedByRange
Killed by : none
changed conditional boundary → SURVIVED Covering tests

4.4
Location : isTouchedByRange
Killed by : none
changed conditional boundary → NO_COVERAGE

5.5
Location : isTouchedByRange
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : isTouchedByRange
Killed by : none
negated conditional → NO_COVERAGE

7.7
Location : isTouchedByRange
Killed by : none
negated conditional → SURVIVED Covering tests

8.8
Location : isTouchedByRange
Killed by : none
negated conditional → SURVIVED Covering tests

9.9
Location : isTouchedByRange
Killed by : none
replaced boolean return with true for pro/verron/officestamper/experimental/PowerpointRun::isTouchedByRange → SURVIVED Covering tests

10.10
Location : isTouchedByRange
Killed by : none
changed conditional boundary → NO_COVERAGE

11.11
Location : isTouchedByRange
Killed by : none
negated conditional → NO_COVERAGE

12.12
Location : isTouchedByRange
Killed by : none
changed conditional boundary → NO_COVERAGE

13.13
Location : isTouchedByRange
Killed by : none
changed conditional boundary → NO_COVERAGE

43

1.1
Location : replace
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
Replaced integer addition with subtraction → KILLED

46

1.1
Location : replace
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
removed call to org/docx4j/dml/CTRegularTextRun::setT → KILLED

50

1.1
Location : globalIndexToLocalIndex
Killed by : none
changed conditional boundary → SURVIVED
Covering tests

2.2
Location : globalIndexToLocalIndex
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
negated conditional → KILLED

51

1.1
Location : globalIndexToLocalIndex
Killed by : none
changed conditional boundary → SURVIVED
Covering tests

2.2
Location : globalIndexToLocalIndex
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
replaced int return with 0 for pro/verron/officestamper/experimental/PowerpointRun::globalIndexToLocalIndex → KILLED

3.3
Location : globalIndexToLocalIndex
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
negated conditional → KILLED

52

1.1
Location : globalIndexToLocalIndex
Killed by : none
replaced int return with 0 for pro/verron/officestamper/experimental/PowerpointRun::globalIndexToLocalIndex → SURVIVED
Covering tests

2.2
Location : globalIndexToLocalIndex
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
Replaced integer subtraction with addition → KILLED

56

1.1
Location : lastIndex
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
replaced int return with 0 for pro/verron/officestamper/experimental/PowerpointRun::lastIndex → KILLED

60

1.1
Location : lastIndex
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
Replaced integer subtraction with addition → KILLED

2.2
Location : lastIndex
Killed by : pro.verron.officestamper.test.BasicPowerpointTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.BasicPowerpointTest]/[method:testStamper()]
replaced int return with 0 for pro/verron/officestamper/experimental/PowerpointRun::lastIndex → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0