ByteUtils.java

1
package com.renomad.minum.utils;
2
3
import java.util.List;
4
5
/**
6
 * Handy helpers when working with bytes
7
 */
8
public final class ByteUtils {
9
10
    private ByteUtils() {}
11
12
    /**
13
     * A helper method to reduce some of the boilerplate
14
     * code when converting a list of bytes to an array.
15
     * <p>
16
     *     Often, we are gradually building up a list - the list takes
17
     *     care of accommodating more elements as necessary. An
18
     *     array, in contrast, is just a single size and doesn't
19
     *     resize itself.  It's much less convenient to use, so we
20
     *     more often use lists.
21
     * </p>
22
     */
23
    public static byte[] byteListToArray(List<Byte> result) {
24
        final var resultArray = new byte[result.size()];
25 2 1. byteListToArray : changed conditional boundary → KILLED
2. byteListToArray : negated conditional → KILLED
        for(int i = 0; i < result.size(); i++) {
26
            resultArray[i] = result.get(i);
27
        }
28 1 1. byteListToArray : replaced return value with null for com/renomad/minum/utils/ByteUtils::byteListToArray → KILLED
        return resultArray;
29
    }
30
31
}

Mutations

25

1.1
Location : byteListToArray
Killed by : com.renomad.minum.utils.ByteUtilsTests.testConversionToArray(com.renomad.minum.utils.ByteUtilsTests)
changed conditional boundary → KILLED

2.2
Location : byteListToArray
Killed by : com.renomad.minum.utils.ByteUtilsTests.testConversionToArray(com.renomad.minum.utils.ByteUtilsTests)
negated conditional → KILLED

28

1.1
Location : byteListToArray
Killed by : com.renomad.minum.utils.ByteUtilsTests.testConversionToArray(com.renomad.minum.utils.ByteUtilsTests)
replaced return value with null for com/renomad/minum/utils/ByteUtils::byteListToArray → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0