File tree Expand file tree Collapse file tree
src/test/java/org/usb4java Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (C) 2014 Klaus Reimer <k@ailis.de>
3+ * See LICENSE.md for licensing information.
4+ */
5+
6+ package org .usb4java ;
7+
8+ import static org .junit .Assert .assertEquals ;
9+
10+ import org .junit .Test ;
11+
12+ /**
13+ * Tests the {@link LibUsbException} class.
14+ *
15+ * @author Klaus Reimer (k@ailis.de)
16+ */
17+ public class LibUsbExceptionTest
18+ {
19+ /**
20+ * Tests the constructor with only an error code.
21+ */
22+ @ Test
23+ public void testConstructorWithCode ()
24+ {
25+ final LibUsbException e =
26+ new LibUsbException (LibUsb .ERROR_INVALID_PARAM );
27+ assertEquals (LibUsb .ERROR_INVALID_PARAM , e .getErrorCode ());
28+ assertEquals ("USB error 2: Invalid parameter" , e .getMessage ());
29+
30+ }
31+
32+ /**
33+ * Tests the constructor with an error code and a message.
34+ */
35+ @ Test
36+ public void testConstructorWithCodeAndMessage ()
37+ {
38+ final LibUsbException e =
39+ new LibUsbException ("Custom message" , LibUsb .ERROR_INVALID_PARAM );
40+ assertEquals (LibUsb .ERROR_INVALID_PARAM , e .getErrorCode ());
41+ assertEquals ("USB error 2: Custom message: Invalid parameter" ,
42+ e .getMessage ());
43+
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments