PassportsValidator.kt

1
package com.adventofcode.day04
2
3
interface PassportsValidator {
4
5
6
    var invalidityCause: String
7
    val validationData: Collection<Pair<Passport, Boolean>>
8
9
    fun areAllPassportsValidOnes(): Boolean {
10
        // return validationData.all { it.second }  produces a false positive in mutatinon testing by pitest. ok when replaced by a for loop and returns as below :
11
        validationData.forEach {
12
            when {
13 2 1. areAllPassportsValidOnes : replaced boolean return with true for com/adventofcode/day04/PassportsValidator$DefaultImpls::areAllPassportsValidOnes → KILLED
2. areAllPassportsValidOnes : negated conditional → KILLED
                !it.second -> return false
14
            }
15
        }
16 1 1. areAllPassportsValidOnes : replaced boolean return with false for com/adventofcode/day04/PassportsValidator$DefaultImpls::areAllPassportsValidOnes → KILLED
        return true
17
    }
18
19
    fun validateAll(passports: Collection<Passport>): Collection<Pair<Passport, Boolean>> {
20
        return passports.map { it to validatePassport(it) }
21
    }
22
23
    fun validatePassport(passport: Passport): Boolean {
24 3 1. validatePassport : Changed increment from 1 to -1 → KILLED
2. validatePassport : negated conditional → KILLED
3. validatePassport : negated conditional → KILLED
        val invalidData = DataField.values().filter { it != DataField.CID }.subtract(passport.data.keys).toList()
25 1 1. validatePassport : removed call to com/adventofcode/day04/PassportsValidator::setInvalidityCause → KILLED
        invalidityCause = "Missing some data = $invalidData"
26 2 1. validatePassport : replaced boolean return with false for com/adventofcode/day04/PassportsValidator$DefaultImpls::validatePassport → KILLED
2. validatePassport : replaced boolean return with true for com/adventofcode/day04/PassportsValidator$DefaultImpls::validatePassport → KILLED
        return invalidData.isEmpty()
27
    }
28
29
    fun asString(): String {
30 1 1. asString : replaced return value with "" for com/adventofcode/day04/PassportsValidator$DefaultImpls::asString → KILLED
        return "${this.javaClass.simpleName}: ${validationData.size} data(s) validated among:\n${validationData.joinToString("\n")}"
31
    }
32
33
}

Mutations

13

1.1
Location : areAllPassportsValidOnes
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldInvalidatePassportWhenSomeDataIsMissing()]
replaced boolean return with true for com/adventofcode/day04/PassportsValidator$DefaultImpls::areAllPassportsValidOnes → KILLED

2.2
Location : areAllPassportsValidOnes
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldValidatePassportWhenDataHasAllFieldsCompleted()]
negated conditional → KILLED

16

1.1
Location : areAllPassportsValidOnes
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldValidatePassportWhenDataHasAllFieldsCompleted()]
replaced boolean return with false for com/adventofcode/day04/PassportsValidator$DefaultImpls::areAllPassportsValidOnes → KILLED

24

1.1
Location : validatePassport
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldValidatePassportWhenDataHasAllFieldsCompleted()]
Changed increment from 1 to -1 → KILLED

2.2
Location : validatePassport
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldValidatePassportWhenDataHasAllFieldsCompletedButCID()]
negated conditional → KILLED

3.3
Location : validatePassport
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldValidatePassportWhenDataHasAllFieldsCompletedButCID()]
negated conditional → KILLED

25

1.1
Location : validatePassport
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldGiveInvalidityCauseWhenPassportIsInvalid()]
removed call to com/adventofcode/day04/PassportsValidator::setInvalidityCause → KILLED

26

1.1
Location : validatePassport
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldValidatePassportWhenDataHasAllFieldsCompleted()]
replaced boolean return with false for com/adventofcode/day04/PassportsValidator$DefaultImpls::validatePassport → KILLED

2.2
Location : validatePassport
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldInvalidatePassportWhenSomeDataIsMissing()]
replaced boolean return with true for com/adventofcode/day04/PassportsValidator$DefaultImpls::validatePassport → KILLED

30

1.1
Location : asString
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldDisplayNumberOfValidData()]
replaced return value with "" for com/adventofcode/day04/PassportsValidator$DefaultImpls::asString → KILLED

40

1.1
Location : validateAll
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldInvalidatePassportWhenSomeDataIsMissing()]
replaced return value with Collections.emptyList for com/adventofcode/day04/PassportsValidator$DefaultImpls::validateAll → KILLED

42

1.1
Location : validatePassport
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldValidatePassportWhenDataHasAllFieldsCompleted()]
changed conditional boundary → KILLED

2.2
Location : validatePassport
Killed by : com.adventofcode.day04.PassportScannerWithSimpleValidationTest.[engine:junit-jupiter]/[class:com.adventofcode.day04.PassportScannerWithSimpleValidationTest]/[method:shouldInvalidatePassportWhenSomeDataIsMissing()]
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT 1.6.1