1+ package uk .co .alt236 .bluetoothlelib .util ;
2+
3+ import junit .framework .TestCase ;
4+
5+ /**
6+ *
7+ */
8+ public class IBeaconUtilsTest extends TestCase {
9+
10+ public void testIsThisAnIBeacon () throws Exception {
11+ assertFalse (IBeaconUtils .isThisAnIBeacon ((byte []) null ));
12+ assertFalse (IBeaconUtils .isThisAnIBeacon (new byte [0 ]));
13+ assertFalse (IBeaconUtils .isThisAnIBeacon (new byte [25 ]));
14+
15+ assertTrue (IBeaconUtils .isThisAnIBeacon (new byte []{
16+ 0x4C , 0x00 , 0x02 , 0x15 , 0x00 , // <- Magic iBeacon header
17+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
18+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
19+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
20+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00
21+ }));
22+ }
23+
24+ public void testGetDistanceDescriptor () throws Exception {
25+ assertEquals (IBeaconDistanceDescriptor .UNKNOWN , IBeaconUtils .getDistanceDescriptor (-1 ));
26+
27+ assertEquals (IBeaconDistanceDescriptor .IMMEDIATE , IBeaconUtils .getDistanceDescriptor (0 ));
28+ assertEquals (IBeaconDistanceDescriptor .IMMEDIATE , IBeaconUtils .getDistanceDescriptor (0.4 ));
29+
30+ assertEquals (IBeaconDistanceDescriptor .NEAR , IBeaconUtils .getDistanceDescriptor (0.5 ));
31+ assertEquals (IBeaconDistanceDescriptor .NEAR , IBeaconUtils .getDistanceDescriptor (2.9 ));
32+
33+ assertEquals (IBeaconDistanceDescriptor .FAR , IBeaconUtils .getDistanceDescriptor (3 ));
34+ }
35+
36+ public void testCalculateUuidString () throws Exception {
37+
38+ }
39+ }
0 commit comments