SledRentalPolicy.kt

1
package com.adventofcode.day02
2
3
class SledRentalPolicy(private val expectedCount: String, private val letter: String) : Policy {
4
5
    companion object {
6
        fun fromInput(policyAsString: String): SledRentalPolicy {
7
            val split = policyAsString.split(" ")
8
            return SledRentalPolicy(split.first(), split.last())
9
        }
10
    }
11
12
    override fun toString(): String {
13 1 1. toString : replaced return value with "" for com/adventofcode/day02/SledRentalPolicy::toString → NO_COVERAGE
        return "Sled Rental policy: -letter '$letter' repeated '$expectedCount' times-"
14
    }
15
16
    override fun checkValidity(password: String): Boolean {
17 2 1. checkValidity : replaced boolean return with false for com/adventofcode/day02/SledRentalPolicy::checkValidity → KILLED
2. checkValidity : replaced boolean return with true for com/adventofcode/day02/SledRentalPolicy::checkValidity → KILLED
        return isLetterCountValid(countValidLetterOf(password))
18
    }
19
20
    private fun countValidLetterOf(password: String): Int {
21
        return password.count{it == letter.toCharArray()[0]}
22
    }
23
24
    private  fun isLetterCountValid(count: Int): Boolean {
25
        val expectedCountSplit = expectedCount.split("-")
26 5 1. isLetterCountValid : replaced boolean return with true for com/adventofcode/day02/SledRentalPolicy::isLetterCountValid → KILLED
2. isLetterCountValid : changed conditional boundary → KILLED
3. isLetterCountValid : changed conditional boundary → KILLED
4. isLetterCountValid : negated conditional → KILLED
5. isLetterCountValid : negated conditional → KILLED
        return count in expectedCountSplit.first().toInt()..expectedCountSplit.last().toInt()
27
    }
28
29
30
}

Mutations

13

1.1
Location : toString
Killed by : none
replaced return value with "" for com/adventofcode/day02/SledRentalPolicy::toString → NO_COVERAGE

17

1.1
Location : checkValidity
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichRespectItsPolicyIsValid()]
replaced boolean return with false for com/adventofcode/day02/SledRentalPolicy::checkValidity → KILLED

2.2
Location : checkValidity
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichDoesNotRespectItsPolicyIsInvalid()]
replaced boolean return with true for com/adventofcode/day02/SledRentalPolicy::checkValidity → KILLED

26

1.1
Location : isLetterCountValid
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichDoesNotRespectItsPolicyIsInvalid()]
replaced boolean return with true for com/adventofcode/day02/SledRentalPolicy::isLetterCountValid → KILLED

2.2
Location : isLetterCountValid
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichRespectItsPolicyIsValid()]
changed conditional boundary → KILLED

3.3
Location : isLetterCountValid
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichRespectItsPolicyIsValid()]
changed conditional boundary → KILLED

4.4
Location : isLetterCountValid
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichDoesNotRespectItsPolicyIsInvalid()]
negated conditional → KILLED

5.5
Location : isLetterCountValid
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichRespectItsPolicyIsValid()]
negated conditional → KILLED

33

1.1
Location : countValidLetterOf
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichDoesNotRespectItsPolicyIsInvalid()]
changed conditional boundary → KILLED

2.2
Location : countValidLetterOf
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichRespectItsPolicyIsValid()]
negated conditional → KILLED

34

1.1
Location : countValidLetterOf
Killed by : com.adventofcode.day02.PasswordsWithSledRentalPolicyTest.[engine:junit-jupiter]/[class:com.adventofcode.day02.PasswordsWithSledRentalPolicyTest]/[method:passwordWhichRespectItsPolicyIsValid()]
replaced int return with 0 for com/adventofcode/day02/SledRentalPolicy::countValidLetterOf → KILLED

Active mutators

Tests examined


Report generated by PIT 1.6.1