Fix for #5 (IBeaconManufacturerData.calculateUUIDString(byte[]) bug)
This commit is contained in:
@@ -50,6 +50,9 @@ public class IBeaconUtils {
|
||||
}
|
||||
|
||||
final int intFromByte = ByteUtils.getIntFromByte(uuid[i]);
|
||||
if(intFromByte <= 0xF){
|
||||
sb.append('0');
|
||||
}
|
||||
sb.append(Integer.toHexString(intFromByte));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,13 @@ public class IBeaconUtilsTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testCalculateUuidString() throws Exception {
|
||||
|
||||
assertEquals("00", IBeaconUtils.calculateUuidString(new byte[]{0}));
|
||||
assertEquals("0a", IBeaconUtils.calculateUuidString(new byte[]{10}));
|
||||
assertEquals("0f", IBeaconUtils.calculateUuidString(new byte[]{15}));
|
||||
assertEquals("10", IBeaconUtils.calculateUuidString(new byte[]{16}));
|
||||
assertEquals("7f", IBeaconUtils.calculateUuidString(new byte[]{127}));
|
||||
assertEquals(
|
||||
"00000000-0000-0000-0000-00",
|
||||
IBeaconUtils.calculateUuidString(new byte[]{0,0,0,0,0,0,0,0,0,0,0}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user