// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/util/ByteArrays.java
// public class ByteArrays {
// 
//     /**
//      * Joins all of the byte arrays in the list, in order.
//      *
//      * @param arrays the list of byte arrays
//      * @return a joined list of byte arrays
//      */
//     public static byte[] join(final List<byte[]> arrays) {
//         byte[] current = new byte[0];
// 
//         for (final byte[] array : arrays) {
//             current = join(current, array);
//         }
// 
//         return current;
//     }
// 
//     /**
//      * Joins the two byte arrays into a single byte array, as first, then second.
//      *
//      * @param first the first byte array
//      * @param second the second byte array
//      * @return a merged byte array of the two in order
//      */
//     public static byte[] join(final byte[] first, final byte[] second) {
//         byte[] combined = new byte[first.length + second.length];
//         arraycopy(first, 0, combined, 0, first.length);
//         arraycopy(second, 0, combined, first.length, second.length);
//         return combined;
//     }
// 
//     /**
//      * Used to join the array of <code>ByteBuffer</code>s into a single array of bytes.
//      *
//      * @param buffers the ByteBuffers to be joined
//      * @return a byte array container the merged bytes from the buffers
//      */
//     public static byte[] join(final ByteBuffer[] buffers) {
//         byte[] incoming = new byte[0];
// 
//         for (final ByteBuffer b : buffers) {
//             final byte[] data = new byte[b.remaining()];
//             b.get(data);
//             incoming = join(incoming, data);
//         }
// 
//         return incoming;
//     }
// }


import io.github.cjstehno.ersatz.util.ByteArrays;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * Copyright (C) 2022 Christopher J. Stehno
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.github.cjstehno.ersatz.util;




class ByteArraysTest {

    private static final byte[] A_0 = "first byte array".getBytes();
    private static final byte[] A_1 = "second byte array".getBytes();
    private static final byte[] A_2 = "third byte array".getBytes();

    @Test @DisplayName("joining two byte arrays")
    void joining_two() {
        final var result = ByteArrays.join(A_0, A_1);
        assertEquals("first byte arraysecond byte array", new String(result));
    }

    @Test @DisplayName("joining a collection of arrays")

// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/util/ByteArrays.java
// public class ByteArrays {
// 
//     /**
//      * Joins all of the byte arrays in the list, in order.
//      *
//      * @param arrays the list of byte arrays
//      * @return a joined list of byte arrays
//      */
//     public static byte[] join(final List<byte[]> arrays) {
//         byte[] current = new byte[0];
// 
//         for (final byte[] array : arrays) {
//             current = join(current, array);
//         }
// 
//         return current;
//     }
// 
//     /**
//      * Joins the two byte arrays into a single byte array, as first, then second.
//      *
//      * @param first the first byte array
//      * @param second the second byte array
//      * @return a merged byte array of the two in order
//      */
//     public static byte[] join(final byte[] first, final byte[] second) {
//         byte[] combined = new byte[first.length + second.length];
//         arraycopy(first, 0, combined, 0, first.length);
//         arraycopy(second, 0, combined, first.length, second.length);
//         return combined;
//     }
// 
//     /**
//      * Used to join the array of <code>ByteBuffer</code>s into a single array of bytes.
//      *
//      * @param buffers the ByteBuffers to be joined
//      * @return a byte array container the merged bytes from the buffers
//      */
//     public static byte[] join(final ByteBuffer[] buffers) {
//         byte[] incoming = new byte[0];
// 
//         for (final ByteBuffer b : buffers) {
//             final byte[] data = new byte[b.remaining()];
//             b.get(data);
//             incoming = join(incoming, data);
//         }
// 
//         return incoming;
//     }
// }


// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/util/ByteArraysTest.java
import io.github.cjstehno.ersatz.util.ByteArrays;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * Copyright (C) 2022 Christopher J. Stehno
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.github.cjstehno.ersatz.util;




class ByteArraysTest {

    private static final byte[] A_0 = "first byte array".getBytes();
    private static final byte[] A_1 = "second byte array".getBytes();
    private static final byte[] A_2 = "third byte array".getBytes();

    @Test @DisplayName("joining two byte arrays")
    void joining_two() {
        final var result = ByteArrays.join(A_0, A_1);
        assertEquals("first byte arraysecond byte array", new String(result));
    }

    @Test @DisplayName("joining a collection of arrays")

    void joining_collection() {
