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 .SimpleUsbEndpointDescriptor ;
1614
1715/**
1816 * Tests the {@link SimpleUsbEndpointDescriptor}.
@@ -25,22 +23,22 @@ public class SimpleUsbEndpointDescriptorTest
2523 private static SimpleUsbEndpointDescriptor descriptor ;
2624
2725 /** Value for {@link SimpleUsbEndpointDescriptor#bLength()}. */
28- private static final byte LENGTH = 1 ;
26+ private static final byte LENGTH = ( byte ) 0xff ;
2927
3028 /** Value for {@link SimpleUsbEndpointDescriptor#bDescriptorType()}. */
31- private static final byte DESCRIPTOR_TYPE = 2 ;
29+ private static final byte DESCRIPTOR_TYPE = ( byte ) 0xfe ;
3230
3331 /** Value for {@link SimpleUsbEndpointDescriptor#bEndpointAddress()}. */
34- private static final byte ENDPOINT_ADDRESS = 3 ;
32+ private static final byte ENDPOINT_ADDRESS = ( byte ) 0xfd ;
3533
3634 /** Value for {@link SimpleUsbEndpointDescriptor#bmAttributes()}. */
37- private static final byte ATTRIBUTES = 4 ;
35+ private static final byte ATTRIBUTES = ( byte ) 0xfc ;
3836
3937 /** Value for {@link SimpleUsbEndpointDescriptor#wMaxPacketSize()}. */
40- private static final short MAX_PACKET_SIZE = 5 ;
38+ private static final short MAX_PACKET_SIZE = ( short ) 0xffff ;
4139
4240 /** Value for {@link SimpleUsbEndpointDescriptor#bInterval()}. */
43- private static final byte INTERVAL = 6 ;
41+ private static final byte INTERVAL = ( byte ) 0xfb ;
4442
4543 /** A wrong value for equality test. */
4644 private static final byte WRONG = 0 ;
@@ -55,7 +53,7 @@ public static void setUp()
5553 LENGTH , DESCRIPTOR_TYPE , ENDPOINT_ADDRESS , ATTRIBUTES ,
5654 MAX_PACKET_SIZE , INTERVAL );
5755 }
58-
56+
5957 /**
6058 * Tests the {@link SimpleUsbEndpointDescriptor#bLength()} method.
6159 */
@@ -161,27 +159,15 @@ public void testEquals()
161159 @ Test
162160 public void testToString ()
163161 {
164- assertEquals (descriptor .toString (), descriptor .toString ());
165- assertEquals (descriptor .toString (), new SimpleUsbEndpointDescriptor (
166- LENGTH , DESCRIPTOR_TYPE , ENDPOINT_ADDRESS , ATTRIBUTES ,
167- MAX_PACKET_SIZE , INTERVAL ).toString ());
168- assertNotEquals (descriptor .toString (), new SimpleUsbEndpointDescriptor (
169- WRONG , DESCRIPTOR_TYPE , ENDPOINT_ADDRESS , ATTRIBUTES ,
170- MAX_PACKET_SIZE , INTERVAL ).toString ());
171- assertNotEquals (descriptor .toString (), new SimpleUsbEndpointDescriptor (
172- LENGTH , WRONG , ENDPOINT_ADDRESS , ATTRIBUTES ,
173- MAX_PACKET_SIZE , INTERVAL ).toString ());
174- assertNotEquals (descriptor .toString (), new SimpleUsbEndpointDescriptor (
175- LENGTH , DESCRIPTOR_TYPE , WRONG , ATTRIBUTES ,
176- MAX_PACKET_SIZE , INTERVAL ).toString ());
177- assertNotEquals (descriptor .toString (), new SimpleUsbEndpointDescriptor (
178- LENGTH , DESCRIPTOR_TYPE , ENDPOINT_ADDRESS , WRONG ,
179- MAX_PACKET_SIZE , INTERVAL ).toString ());
180- assertNotEquals (descriptor .toString (), new SimpleUsbEndpointDescriptor (
181- LENGTH , DESCRIPTOR_TYPE , ENDPOINT_ADDRESS , ATTRIBUTES ,
182- WRONG , INTERVAL ).toString ());
183- assertNotEquals (descriptor .toString (), new SimpleUsbEndpointDescriptor (
184- LENGTH , DESCRIPTOR_TYPE , ENDPOINT_ADDRESS , ATTRIBUTES ,
185- MAX_PACKET_SIZE , WRONG ).toString ());
162+ assertEquals (String .format ("Endpoint Descriptor:%n"
163+ + " bLength 255%n"
164+ + " bDescriptorType 254%n"
165+ + " bEndpointAddress 0xfd EP 13 IN%n"
166+ + " bmAttributes 252%n"
167+ + " Transfer Type Control%n"
168+ + " Synch Type Synchronous%n"
169+ + " Usage Type Reserved%n"
170+ + " wMaxPacketSize 65535%n"
171+ + " bInterval 251%n" ), descriptor .toString ());
186172 }
187173}
0 commit comments