77
88import static org .junit .Assert .assertEquals ;
99import static org .junit .Assert .assertFalse ;
10- import static org .junit .Assert .assertNotEquals ;
1110import static org .junit .Assert .assertTrue ;
1211
1312import org .junit .BeforeClass ;
1413import org .junit .Test ;
15- import org .usb4java .javax .descriptors .SimpleUsbInterfaceDescriptor ;
1614
1715/**
1816 * Tests the {@link SimpleUsbInterfaceDescriptor}.
@@ -25,31 +23,31 @@ public class SimpleUsbInterfaceDescriptorTest
2523 private static SimpleUsbInterfaceDescriptor descriptor ;
2624
2725 /** Value for {@link SimpleUsbInterfaceDescriptor#bLength()}. */
28- private static final byte LENGTH = 1 ;
26+ private static final byte LENGTH = ( byte ) 0xff ;
2927
3028 /** Value for {@link SimpleUsbInterfaceDescriptor#bDescriptorType()}. */
31- private static final byte DESCRIPTOR_TYPE = 2 ;
29+ private static final byte DESCRIPTOR_TYPE = ( byte ) 0xfe ;
3230
3331 /** Value for {@link SimpleUsbInterfaceDescriptor#bInterfaceNumber()}. */
34- private static final byte INTERFACE_NUMBER = 3 ;
32+ private static final byte INTERFACE_NUMBER = ( byte ) 0xfd ;
3533
3634 /** Value for {@link SimpleUsbInterfaceDescriptor#bAlternateSetting()}. */
37- private static final byte ALTERNATE_SETTING = 4 ;
35+ private static final byte ALTERNATE_SETTING = ( byte ) 0xfc ;
3836
3937 /** Value for {@link SimpleUsbInterfaceDescriptor#bNumEndpoints()}. */
40- private static final byte NUM_ENDPOINTS = 5 ;
38+ private static final byte NUM_ENDPOINTS = ( byte ) 0xfb ;
4139
4240 /** Value for {@link SimpleUsbInterfaceDescriptor#bInterfaceClass()}. */
43- private static final byte INTERFACE_CLASS = 6 ;
41+ private static final byte INTERFACE_CLASS = ( byte ) 0xfa ;
4442
4543 /** Value for {@link SimpleUsbInterfaceDescriptor#bInterfaceSubClass()}. */
46- private static final byte INTERFACE_SUB_CLASS = 7 ;
44+ private static final byte INTERFACE_SUB_CLASS = ( byte ) 0xf9 ;
4745
4846 /** Value for {@link SimpleUsbInterfaceDescriptor#bInterfaceProtocol()}. */
49- private static final byte INTERFACE_PROTOCOL = 8 ;
47+ private static final byte INTERFACE_PROTOCOL = ( byte ) 0xf8 ;
5048
5149 /** Value for {@link SimpleUsbInterfaceDescriptor#iInterface()}. */
52- private static final byte INTERFACE = 9 ;
50+ private static final byte INTERFACE = ( byte ) 0xf7 ;
5351
5452 /** A wrong value for equality test. */
5553 private static final byte WRONG = 0 ;
@@ -221,56 +219,15 @@ public void testEquals()
221219 @ Test
222220 public void testToString ()
223221 {
224- assertEquals (descriptor .toString (), descriptor .toString ());
225- assertEquals (descriptor .toString (),
226- new SimpleUsbInterfaceDescriptor (
227- LENGTH , DESCRIPTOR_TYPE , INTERFACE_NUMBER , ALTERNATE_SETTING ,
228- NUM_ENDPOINTS , INTERFACE_CLASS , INTERFACE_SUB_CLASS ,
229- INTERFACE_PROTOCOL , INTERFACE ).toString ());
230- assertNotEquals (descriptor .toString (),
231- new SimpleUsbInterfaceDescriptor (
232- WRONG , DESCRIPTOR_TYPE , INTERFACE_NUMBER , ALTERNATE_SETTING ,
233- NUM_ENDPOINTS , INTERFACE_CLASS , INTERFACE_SUB_CLASS ,
234- INTERFACE_PROTOCOL , INTERFACE ).toString ());
235- assertNotEquals (descriptor .toString (),
236- new SimpleUsbInterfaceDescriptor (
237- LENGTH , WRONG , INTERFACE_NUMBER , ALTERNATE_SETTING ,
238- NUM_ENDPOINTS , INTERFACE_CLASS , INTERFACE_SUB_CLASS ,
239- INTERFACE_PROTOCOL , INTERFACE ).toString ());
240- assertNotEquals (descriptor .toString (),
241- new SimpleUsbInterfaceDescriptor (
242- LENGTH , DESCRIPTOR_TYPE , WRONG , ALTERNATE_SETTING ,
243- NUM_ENDPOINTS , INTERFACE_CLASS , INTERFACE_SUB_CLASS ,
244- INTERFACE_PROTOCOL , INTERFACE ).toString ());
245- assertNotEquals (descriptor .toString (),
246- new SimpleUsbInterfaceDescriptor (
247- LENGTH , DESCRIPTOR_TYPE , INTERFACE_NUMBER , WRONG ,
248- NUM_ENDPOINTS , INTERFACE_CLASS , INTERFACE_SUB_CLASS ,
249- INTERFACE_PROTOCOL , INTERFACE ).toString ());
250- assertNotEquals (descriptor .toString (),
251- new SimpleUsbInterfaceDescriptor (
252- LENGTH , DESCRIPTOR_TYPE , INTERFACE_NUMBER , ALTERNATE_SETTING ,
253- WRONG , INTERFACE_CLASS , INTERFACE_SUB_CLASS ,
254- INTERFACE_PROTOCOL , INTERFACE ).toString ());
255- assertNotEquals (descriptor .toString (),
256- new SimpleUsbInterfaceDescriptor (
257- LENGTH , DESCRIPTOR_TYPE , INTERFACE_NUMBER , ALTERNATE_SETTING ,
258- NUM_ENDPOINTS , WRONG , INTERFACE_SUB_CLASS ,
259- INTERFACE_PROTOCOL , INTERFACE ).toString ());
260- assertNotEquals (descriptor .toString (),
261- new SimpleUsbInterfaceDescriptor (
262- LENGTH , DESCRIPTOR_TYPE , INTERFACE_NUMBER , ALTERNATE_SETTING ,
263- NUM_ENDPOINTS , INTERFACE_CLASS , WRONG ,
264- INTERFACE_PROTOCOL , INTERFACE ).toString ());
265- assertNotEquals (descriptor .toString (),
266- new SimpleUsbInterfaceDescriptor (
267- LENGTH , DESCRIPTOR_TYPE , INTERFACE_NUMBER , ALTERNATE_SETTING ,
268- NUM_ENDPOINTS , INTERFACE_CLASS , INTERFACE_SUB_CLASS ,
269- WRONG , INTERFACE ).toString ());
270- assertNotEquals (descriptor .toString (),
271- new SimpleUsbInterfaceDescriptor (
272- LENGTH , DESCRIPTOR_TYPE , INTERFACE_NUMBER , ALTERNATE_SETTING ,
273- NUM_ENDPOINTS , INTERFACE_CLASS , INTERFACE_SUB_CLASS ,
274- INTERFACE_PROTOCOL , WRONG ).toString ());
222+ assertEquals (String .format ("Interface Descriptor:%n"
223+ + " bLength 255%n"
224+ + " bDescriptorType 254%n"
225+ + " bInterfaceNumber 253%n"
226+ + " bAlternateSetting 252%n"
227+ + " bNumEndpoints 251%n"
228+ + " bInterfaceClass 250 Unknown%n"
229+ + " bInterfaceSubClass 249%n"
230+ + " bInterfaceProtocol 248%n"
231+ + " iInterface 247%n" ), descriptor .toString ());
275232 }
276233}
0 commit comments