Matcher.java

1
package pro.verron.officestamper.core;
2
3
4
/**
5
 * The Matcher class provides methods to match and strip expressions based on a specified prefix and suffix.
6
 * The match()
7
 * method checks if an expression starts with the prefix
8
 * and ends with the suffix.
9
 * The strip()
10
 * method removes the prefix and suffix from an expression
11
 * and returns the inner part.
12
 */
13
public record Matcher(
14
        String prefix,
15
        String suffix
16
) {
17
18
    /**
19
     * Checks if the given expression matches the specified criteria.
20
     *
21
     * @param expression the expression to be matched.
22
     * @return {@code true} if the expression starts with the prefix
23
     * and ends with the suffix,
24
     * {@code false} otherwise.
25
     */
26
27
    public boolean match(String expression) {
28 2 1. match : replaced boolean return with true for pro/verron/officestamper/core/Matcher::match → SURVIVED
2. match : negated conditional → KILLED
        return expression.startsWith(prefix)
29 1 1. match : negated conditional → KILLED
               && expression.endsWith(suffix);
30
    }
31
32
    /**
33
     * Strips the prefix and suffix from the given expression and returns the inner part.
34
     *
35
     * @param expression the expression to be stripped.
36
     * @return the inner part of the expression after stripping the prefix and suffix.
37
     */
38
    public String strip(String expression) {
39
        int start = prefix.length();
40 1 1. strip : Replaced integer subtraction with addition → KILLED
        int end = expression.length() - suffix.length();
41 1 1. strip : replaced return value with "" for pro/verron/officestamper/core/Matcher::strip → KILLED
        return expression.substring(start, end);
42
    }
43
}

Mutations

28

1.1
Location : match
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#28]
negated conditional → KILLED

2.2
Location : match
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/Matcher::match → SURVIVED
Covering tests

29

1.1
Location : match
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#28]
negated conditional → KILLED

40

1.1
Location : strip
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#30]
Replaced integer subtraction with addition → KILLED

41

1.1
Location : strip
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#30]
replaced return value with "" for pro/verron/officestamper/core/Matcher::strip → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.1