Dices.java

1
package io.github.mathieusoysal;
2
3
import java.util.stream.IntStream;
4
5
import io.github.mathieusoysal.exception.IncorrectDiceValueException;
6
7
/**
8
 * The {@code Dices} class represents a set of five dice used in the Yatzy game.
9
 * It allows you to store and manipulate the values of these dice.
10
 *
11
 * @see IntStream
12
 * @see IncorrectDiceValueException
13
 */
14
public class Dices {
15
    private int[] dicesArray;
16
17
    /**
18
     * Constructs a new {@code Dices} object with the values of five dice.
19
     * 
20
     * @param dice1 The value of the first die.
21
     * @param dice2 The value of the second die.
22
     * @param dice3 The value of the third die.
23
     * @param dice4 The value of the fourth die.
24
     * @param dice5 The value of the fifth die.
25
     * @throws IncorrectDiceValueException If any of the dice values are not in the
26
     *                                     valid range [1, 6].
27
     */
28
    public Dices(int dice1, int dice2, int dice3, int dice4, int dice5) {
29
        dicesArray = new int[] { dice1, dice2, dice3, dice4, dice5 };
30
        for (int diceValue : dicesArray)
31 1 1. <init> : removed call to io/github/mathieusoysal/Dices::checkDiceValue → KILLED
            checkDiceValue(diceValue);
32
    }
33
34
    /**
35
     * Checks if a given dice value is within the valid range [1, 6].
36
     * 
37
     * @param diceValue The value of the dice to check.
38
     * @throws IncorrectDiceValueException If the dice value is not in the valid
39
     *                                     range [1, 6].
40
     */
41
    private void checkDiceValue(int diceValue) {
42 4 1. checkDiceValue : negated conditional → KILLED
2. checkDiceValue : negated conditional → KILLED
3. checkDiceValue : changed conditional boundary → KILLED
4. checkDiceValue : changed conditional boundary → KILLED
        if (diceValue < 1 || diceValue > 6)
43
            throw new IncorrectDiceValueException();
44
    }
45
46
    /**
47
     * Returns an {@link IntStream} of the dice values.
48
     * 
49
     * @return An {@link IntStream} containing the values of the five dice.
50
     */
51
    public IntStream getDicesIntStream() {
52 1 1. getDicesIntStream : replaced return value with null for io/github/mathieusoysal/Dices::getDicesIntStream → KILLED
        return IntStream.of(dicesArray);
53
    }
54
}

Mutations

31

1.1
Location : <init>
Killed by : io.github.mathieusoysal.DicesTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.DicesTest]/[test-template:test_throwsIncorrectDiceValue_with7(int, int, int, int, int)]/[test-template-invocation:#5]
removed call to io/github/mathieusoysal/Dices::checkDiceValue → KILLED

42

1.1
Location : checkDiceValue
Killed by : io.github.mathieusoysal.yatzy_mod.YatzyModTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.yatzy_mod.YatzyModTest]/[test-template:test_calculateScore_withNotNullDices(io.github.mathieusoysal.yatzy_mod.YatzyMod)]/[test-template-invocation:#2]
negated conditional → KILLED

2.2
Location : checkDiceValue
Killed by : io.github.mathieusoysal.yatzy_mod.YatzyModTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.yatzy_mod.YatzyModTest]/[test-template:test_calculateScore_withNotNullDices(io.github.mathieusoysal.yatzy_mod.YatzyMod)]/[test-template-invocation:#2]
negated conditional → KILLED

3.3
Location : checkDiceValue
Killed by : io.github.mathieusoysal.YatzyTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.YatzyTest]/[test-template:test_chance(int, int, int, int, int, int)]/[test-template-invocation:#4]
changed conditional boundary → KILLED

4.4
Location : checkDiceValue
Killed by : io.github.mathieusoysal.yatzy_mod.YatzyModTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.yatzy_mod.YatzyModTest]/[test-template:test_calculateScore_withNotNullDices(io.github.mathieusoysal.yatzy_mod.YatzyMod)]/[test-template-invocation:#2]
changed conditional boundary → KILLED

52

1.1
Location : getDicesIntStream
Killed by : io.github.mathieusoysal.yatzy_mod.YatzyModTest.[engine:junit-jupiter]/[class:io.github.mathieusoysal.yatzy_mod.YatzyModTest]/[test-template:test_calculateScore_withNotNullDices(io.github.mathieusoysal.yatzy_mod.YatzyMod)]/[test-template-invocation:#2]
replaced return value with null for io/github/mathieusoysal/Dices::getDicesIntStream → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0