|
1
|
|
package com.ancientprogramming.fixedformat4j.format.impl; |
|
2
|
|
|
|
3
|
|
import com.ancientprogramming.fixedformat4j.format.FormatInstructions; |
|
4
|
|
|
|
5
|
|
import static com.ancientprogramming.fixedformat4j.annotation.Field.UNSET_NULL_CHAR; |
|
6
|
|
|
|
7
|
|
/** |
|
8
|
|
* Shared null-char helpers used by both {@link FixedFormatManagerImpl} and |
|
9
|
|
* {@link RepeatingFieldSupport}. |
|
10
|
|
* |
|
11
|
|
* @author Jacob von Eyben - <a href="https://eybenconsult.com">https://eybenconsult.com</a> |
|
12
|
|
* @since 1.7.1 |
|
13
|
|
*/ |
|
14
|
|
final class NullCharSupport { |
|
15
|
|
|
|
16
|
|
private NullCharSupport() {} |
|
17
|
|
|
|
18
|
|
/** |
|
19
|
|
* Returns {@code true} when {@code @Field.nullChar()} is explicitly configured (non-sentinel). |
|
20
|
|
* The sentinel {@link com.ancientprogramming.fixedformat4j.annotation.Field#UNSET_NULL_CHAR} |
|
21
|
|
* marks "not configured" and is never treated as a real null character. Setting |
|
22
|
|
* {@code nullChar} equal to {@code paddingChar} activates the "blank-is-null" convention |
|
23
|
|
* (Issue 84). |
|
24
|
|
*/ |
|
25
|
|
static boolean isNullCharActive(FormatInstructions instructions) { |
|
26
|
7
1. isNullCharActive : removed conditional - replaced equality check with false → KILLED
2. isNullCharActive : Substituted 0 with 1 → KILLED
3. isNullCharActive : removed conditional - replaced equality check with true → KILLED
4. isNullCharActive : Substituted 1 with 0 → KILLED
5. isNullCharActive : removed call to com/ancientprogramming/fixedformat4j/format/FormatInstructions::getNullChar → KILLED
6. isNullCharActive : replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullCharActive → KILLED
7. isNullCharActive : negated conditional → KILLED
|
return instructions.getNullChar() != UNSET_NULL_CHAR; |
|
27
|
|
} |
|
28
|
|
|
|
29
|
|
/** |
|
30
|
|
* Returns {@code true} when the raw slice consists entirely of the configured |
|
31
|
|
* {@code nullChar}. An empty slice is never treated as null. |
|
32
|
|
*/ |
|
33
|
|
static boolean isNullSlice(String slice, FormatInstructions instructions) { |
|
34
|
11
1. isNullSlice : removed call to java/lang/String::isEmpty → SURVIVED
2. isNullSlice : removed conditional - replaced equality check with true → SURVIVED
3. isNullSlice : removed conditional - replaced equality check with true → SURVIVED
4. isNullSlice : removed conditional - replaced equality check with false → SURVIVED
5. isNullSlice : negated conditional → KILLED
6. isNullSlice : removed call to com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullCharActive → KILLED
7. isNullSlice : removed conditional - replaced equality check with false → KILLED
8. isNullSlice : removed conditional - replaced equality check with false → KILLED
9. isNullSlice : negated conditional → KILLED
10. isNullSlice : negated conditional → KILLED
11. isNullSlice : removed conditional - replaced equality check with true → KILLED
|
if (!isNullCharActive(instructions) || slice == null || slice.isEmpty()) { |
|
35
|
2
1. isNullSlice : Substituted 0 with 1 → KILLED
2. isNullSlice : replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullSlice → KILLED
|
return false; |
|
36
|
|
} |
|
37
|
1
1. isNullSlice : removed call to com/ancientprogramming/fixedformat4j/format/FormatInstructions::getNullChar → KILLED
|
char nullChar = instructions.getNullChar(); |
|
38
|
6
1. isNullSlice : Substituted 0 with 1 → SURVIVED
2. isNullSlice : removed call to java/lang/String::length → KILLED
3. isNullSlice : negated conditional → KILLED
4. isNullSlice : removed conditional - replaced comparison check with true → KILLED
5. isNullSlice : changed conditional boundary → KILLED
6. isNullSlice : removed conditional - replaced comparison check with false → KILLED
|
for (int i = 0; i < slice.length(); i++) { |
|
39
|
4
1. isNullSlice : removed call to java/lang/String::charAt → KILLED
2. isNullSlice : removed conditional - replaced equality check with true → KILLED
3. isNullSlice : removed conditional - replaced equality check with false → KILLED
4. isNullSlice : negated conditional → KILLED
|
if (slice.charAt(i) != nullChar) { |
|
40
|
2
1. isNullSlice : Substituted 0 with 1 → KILLED
2. isNullSlice : replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullSlice → KILLED
|
return false; |
|
41
|
|
} |
|
42
|
|
} |
|
43
|
2
1. isNullSlice : Substituted 1 with 0 → KILLED
2. isNullSlice : replaced boolean return with false for com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullSlice → KILLED
|
return true; |
|
44
|
|
} |
|
45
|
|
} |
| | Mutations |
| 26 |
|
1.1 Location : isNullCharActive Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed conditional - replaced equality check with false → KILLED
2.2 Location : isNullCharActive Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue33.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue33]/[method:nullDateFieldExportsAsAllPadding()] Substituted 0 with 1 → KILLED
3.3 Location : isNullCharActive Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue33.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue33]/[method:nullDateFieldExportsAsAllPadding()] removed conditional - replaced equality check with true → KILLED
4.4 Location : isNullCharActive Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] Substituted 1 with 0 → KILLED
5.5 Location : isNullCharActive Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed call to com/ancientprogramming/fixedformat4j/format/FormatInstructions::getNullChar → KILLED
6.6 Location : isNullCharActive Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue33.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue33]/[method:nullDateFieldExportsAsAllPadding()] replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullCharActive → KILLED
7.7 Location : isNullCharActive Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] negated conditional → KILLED
|
| 34 |
|
1.1 Location : isNullSlice Killed by : none removed call to java/lang/String::isEmpty → SURVIVED
Covering tests
2.2 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] negated conditional → KILLED
3.3 Location : isNullSlice Killed by : none removed conditional - replaced equality check with true → SURVIVED
Covering tests
4.4 Location : isNullSlice Killed by : none removed conditional - replaced equality check with true → SURVIVED
Covering tests
5.5 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed call to com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullCharActive → KILLED
6.6 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed conditional - replaced equality check with false → KILLED
7.7 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed conditional - replaced equality check with false → KILLED
8.8 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] negated conditional → KILLED
9.9 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] negated conditional → KILLED
10.10 Location : isNullSlice Killed by : none removed conditional - replaced equality check with false → SURVIVED
Covering tests
11.11 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed conditional - replaced equality check with true → KILLED
|
| 35 |
|
1.1 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue97RestOfLine.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue97RestOfLine]/[method:load_restOfLineFromOffset1_emptyLineYieldsEmptyString()] Substituted 0 with 1 → KILLED
2.2 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue97RestOfLine.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue97RestOfLine]/[method:load_restOfLineFromOffset1_emptyLineYieldsEmptyString()] replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullSlice → KILLED
|
| 37 |
|
1.1 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed call to com/ancientprogramming/fixedformat4j/format/FormatInstructions::getNullChar → KILLED
|
| 38 |
|
1.1 Location : isNullSlice Killed by : none Substituted 0 with 1 → SURVIVED
Covering tests
2.2 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl]/[method:testLoad_nullCharPartialMatch_fieldIsParsed()] removed call to java/lang/String::length → KILLED
3.3 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl]/[method:testLoad_nullCharPartialMatch_fieldIsParsed()] negated conditional → KILLED
4.4 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed conditional - replaced comparison check with true → KILLED
5.5 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] changed conditional boundary → KILLED
6.6 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl]/[method:testLoad_nullCharPartialMatch_fieldIsParsed()] removed conditional - replaced comparison check with false → KILLED
|
| 39 |
|
1.1 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed call to java/lang/String::charAt → KILLED
2.2 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] removed conditional - replaced equality check with true → KILLED
3.3 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl]/[method:testLoad_nullCharPartialMatch_fieldIsParsed()] removed conditional - replaced equality check with false → KILLED
4.4 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] negated conditional → KILLED
|
| 40 |
|
1.1 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl]/[method:testLoad_nullCharPartialMatch_fieldIsParsed()] Substituted 0 with 1 → KILLED
2.2 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.format.impl.TestFixedFormatManagerImpl]/[method:testLoad_nullCharPartialMatch_fieldIsParsed()] replaced boolean return with true for com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullSlice → KILLED
|
| 43 |
|
1.1 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] Substituted 1 with 0 → KILLED
2.2 Location : isNullSlice Killed by : com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull.[engine:junit-jupiter]/[class:com.ancientprogramming.fixedformat4j.issues.TestIssue84BlankIsNull]/[method:loadAllSpacesOnStringField_returnsNull()] replaced boolean return with false for com/ancientprogramming/fixedformat4j/format/impl/NullCharSupport::isNullSlice → KILLED
|