forked from usb4java/usb4java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibUsbExceptionTest.java
More file actions
45 lines (38 loc) · 1.1 KB
/
LibUsbExceptionTest.java
File metadata and controls
45 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (C) 2014 Klaus Reimer <[email protected]>
* See LICENSE.md for licensing information.
*/
package org.usb4java;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
* Tests the {@link LibUsbException} class.
*
* @author Klaus Reimer ([email protected])
*/
public class LibUsbExceptionTest
{
/**
* Tests the constructor with only an error code.
*/
@Test
public void testConstructorWithCode()
{
final LibUsbException e =
new LibUsbException(LibUsb.ERROR_INVALID_PARAM);
assertEquals(LibUsb.ERROR_INVALID_PARAM, e.getErrorCode());
assertEquals("USB error 2: Invalid parameter", e.getMessage());
}
/**
* Tests the constructor with an error code and a message.
*/
@Test
public void testConstructorWithCodeAndMessage()
{
final LibUsbException e =
new LibUsbException("Custom message", LibUsb.ERROR_INVALID_PARAM);
assertEquals(LibUsb.ERROR_INVALID_PARAM, e.getErrorCode());
assertEquals("USB error 2: Custom message: Invalid parameter",
e.getMessage());
}
}