Password.kt

1
package com.adventofcode.day02
2
3
4
class Password(private val password: String, private val policy: Policy) {
5
6
    companion object {
7
        fun fromInput(policy : (String) -> Policy, passwordAndPolicy: String) : Password {
8
            val split = passwordAndPolicy.split(":")
9 1 1. fromInput : negated conditional → KILLED
           return Password(split[1].trim(), policy.invoke(split[0]))
10
        }
11
    }
12
13
    fun isValid(): Boolean {
14 2 1. isValid : replaced boolean return with false for com/adventofcode/day02/Password::isValid → KILLED
2. isValid : replaced boolean return with true for com/adventofcode/day02/Password::isValid → KILLED
        return policy.checkValidity(password)
15
    }
16
17
    override fun toString(): String {
18 1 1. toString : replaced return value with "" for com/adventofcode/day02/Password::toString → NO_COVERAGE
        return "Password '$password' with: $policy"
19
    }
20
}

Mutations

9

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

14

1.1
Location : isValid
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/Password::isValid → KILLED

2.2
Location : isValid
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/Password::isValid → KILLED

18

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

Active mutators

Tests examined


Report generated by PIT 1.6.1