/** Tests the {@link Transfer#status()} methods. */
 @Test
 public void testGetStatus() {
   assumeUsbTestsEnabled();
   final Transfer transfer = LibUsb.allocTransfer(0);
   assertEquals(0, transfer.status());
   LibUsb.freeTransfer(transfer);
 }
 /** Tests the {@link Transfer#setTimeout(long)} and {@link Transfer#timeout()} methods. */
 @Test
 public void testTimeout() {
   assumeUsbTestsEnabled();
   final Transfer transfer = LibUsb.allocTransfer(0);
   assertEquals(0, transfer.timeout());
   transfer.setTimeout(1);
   assertEquals(1, transfer.timeout());
   transfer.setTimeout(0);
   assertEquals(0, transfer.timeout());
   LibUsb.freeTransfer(transfer);
 }
 /** Tests the {@link Transfer#setType(byte)} and {@link Transfer#type()} methods. */
 @Test
 public void testType() {
   assumeUsbTestsEnabled();
   final Transfer transfer = LibUsb.allocTransfer(0);
   assertEquals(0, transfer.type());
   transfer.setType((byte) 1);
   assertEquals(1, transfer.type());
   transfer.setType((byte) 0);
   assertEquals(0, transfer.type());
   LibUsb.freeTransfer(transfer);
 }
  /** Tests allocating and freeing a transfer object. */
  @Test
  public void testAllocAndFree() {
    assumeUsbTestsEnabled();
    final Transfer transfer = LibUsb.allocTransfer(0);
    assertNotNull(transfer);
    LibUsb.freeTransfer(transfer);

    try {
      LibUsb.freeTransfer(transfer);
      fail("Double-free should throw IllegalStateException");
    } catch (final IllegalStateException e) {
      // Expected behavior
    }
  }
 /**
  * Tests the {@link Transfer#setDevHandle(DeviceHandle)} and {@link Transfer#devHandle()} methods.
  */
 @Test
 public void testDevHandle() {
   assumeUsbTestsEnabled();
   final Transfer transfer = LibUsb.allocTransfer(0);
   final DeviceHandle handle = new DeviceHandle();
   this.setPointer(handle, 1);
   final DeviceHandle handle2 = new DeviceHandle();
   this.setPointer(handle2, 2);
   assertNull(transfer.devHandle());
   transfer.setDevHandle(handle);
   assertNotNull(transfer.devHandle());
   assertNotSame(handle, transfer.devHandle());
   assertNotEquals(handle2, transfer.devHandle());
   assertEquals(handle, transfer.devHandle());
   transfer.setDevHandle(null);
   assertNull(transfer.devHandle());
   LibUsb.freeTransfer(transfer);
 }