Added some tests around ByteUtils

This commit is contained in:
Alexandros Schillings
2015-07-03 15:38:57 +01:00
parent 53138d5462
commit 9c04515a34
6 changed files with 112 additions and 45 deletions
@@ -65,8 +65,10 @@ public final class IBeaconManufacturerData {
public IBeaconManufacturerData(final byte[] data) {
mData = data;
mCompanyIdentidier = ByteUtils.getIntFrom2ByteArray(
ByteUtils.invertArray(Arrays.copyOfRange(mData, 0, 2)));
final byte[] intArray = Arrays.copyOfRange(mData, 0, 2);
ByteUtils.invertArray(intArray);
mCompanyIdentidier = ByteUtils.getIntFrom2ByteArray(intArray);
mIBeaconAdvertisment = ByteUtils.getIntFrom2ByteArray(Arrays.copyOfRange(mData, 2, 4));
mUUID = calculateUUIDString(Arrays.copyOfRange(mData, 4, 20));
@@ -36,7 +36,7 @@ public class ByteUtils {
}
/**
* Checks to see if a byte arry starts with another byte array.
* Checks to see if a byte array starts with another byte array.
*
* @param array the array
* @param prefix the prefix
@@ -78,7 +78,7 @@ public class ByteUtils {
* <p/>
* For example, FF will be converted to 255 and not -1.
*
* @param bite the bite
* @param bite the byte
* @return the int from byte
*/
public static int getIntFromByte(final byte bite) {
@@ -107,12 +107,11 @@ public class ByteUtils {
/**
* Inverts an array
* Inverts an byte array in place.
*
* @param array the array
* @return the byte[]
*/
public static byte[] invertArray(final byte[] array) {
public static void invertArray(final byte[] array) {
final int size = array.length;
byte temp;
@@ -121,7 +120,5 @@ public class ByteUtils {
array[i] = array[size - 1 - i];
array[size - 1 - i] = temp;
}
return array;
}
}