// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte DATA = (byte) (VERSION | longToUbyte(0));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte FIN = (byte) (VERSION | longToUbyte(16));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte RESET = (byte) (VERSION | longToUbyte(48));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte STATE = (byte) (VERSION | longToUbyte(32));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte SYN = (byte) (VERSION | longToUbyte(64));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static byte[] joinByteArray(byte[] array1, byte[] array2) {
// 		
// 	int length1 = array1 == null ? 0 : array1.length;
// 	int length2 = array2 == null ? 0 : array2.length;
// 
// 		
// 	int totalLength = length1 + length2;
// 	byte[] returnArray = new byte[totalLength];
// 		
// 	int i = 0;
// 	for (; i < length1; i++) {
// 		returnArray[i] = array1[i];
// 	}
// 		
// 	for (int j = 0; j < length2; j++) {
// 		returnArray[i] = array2[j];
// 		i++;
// 	}
// 		
// 	return returnArray;
// 		
// }


import static net.utp4j.data.UtpPacketUtils.DATA;
import static net.utp4j.data.UtpPacketUtils.FIN;
import static net.utp4j.data.UtpPacketUtils.RESET;
import static net.utp4j.data.UtpPacketUtils.STATE;
import static net.utp4j.data.UtpPacketUtils.SYN;
import static net.utp4j.data.UtpPacketUtils.joinByteArray;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

/* Copyright 2013 Ivan Iljkic
*
* 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 net.utp4j.data.bytes;



public class UtpPacketUtilsTest {
	
	/**
	 * Testing with type 0,1,2,3,4 which correspondents to: ST_DATA, ST_FIN, ST_STATE, ST_RESET, ST_SYN 
	 * and provoking exceptions for arguments out of range. 
	 * see http://bittorrent.org/beps/bep_0029.html
	 */
	@Test
	public void testTypeAndVersionByte() {
		String type0excpected = "1";
		String type1excpected = "10001";
		String type2excpected = "100001";
		String type3excpected = "110001";
		String type4excpected = "1000001";
		
		String actual0 = toBinaryString(DATA, type0excpected.length());

// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte DATA = (byte) (VERSION | longToUbyte(0));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte FIN = (byte) (VERSION | longToUbyte(16));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte RESET = (byte) (VERSION | longToUbyte(48));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte STATE = (byte) (VERSION | longToUbyte(32));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static final byte SYN = (byte) (VERSION | longToUbyte(64));
// 
// Path: src/main/java/net/utp4j/data/UtpPacketUtils.java
// public static byte[] joinByteArray(byte[] array1, byte[] array2) {
// 		
// 	int length1 = array1 == null ? 0 : array1.length;
// 	int length2 = array2 == null ? 0 : array2.length;
// 
// 		
// 	int totalLength = length1 + length2;
// 	byte[] returnArray = new byte[totalLength];
// 		
// 	int i = 0;
// 	for (; i < length1; i++) {
// 		returnArray[i] = array1[i];
// 	}
// 		
// 	for (int j = 0; j < length2; j++) {
// 		returnArray[i] = array2[j];
// 		i++;
// 	}
// 		
// 	return returnArray;
// 		
// }


// Path: src/test/java/net/utp4j/data/bytes/UtpPacketUtilsTest.java
import static net.utp4j.data.UtpPacketUtils.DATA;
import static net.utp4j.data.UtpPacketUtils.FIN;
import static net.utp4j.data.UtpPacketUtils.RESET;
import static net.utp4j.data.UtpPacketUtils.STATE;
import static net.utp4j.data.UtpPacketUtils.SYN;
import static net.utp4j.data.UtpPacketUtils.joinByteArray;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

/* Copyright 2013 Ivan Iljkic
*
* 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 net.utp4j.data.bytes;



public class UtpPacketUtilsTest {
	
	/**
	 * Testing with type 0,1,2,3,4 which correspondents to: ST_DATA, ST_FIN, ST_STATE, ST_RESET, ST_SYN 
	 * and provoking exceptions for arguments out of range. 
	 * see http://bittorrent.org/beps/bep_0029.html
	 */
	@Test
	public void testTypeAndVersionByte() {
		String type0excpected = "1";
		String type1excpected = "10001";
		String type2excpected = "100001";
		String type3excpected = "110001";
		String type4excpected = "1000001";
		
		String actual0 = toBinaryString(DATA, type0excpected.length());

		String actual1 = toBinaryString(FIN, type1excpected.length());
