Commit | Line | Data |
---|---|---|
866e5b51 FC |
1 | package org.eclipse.linuxtools.ctf.core.tests.trace; |
2 | ||
3 | import static org.junit.Assert.assertEquals; | |
4 | import static org.junit.Assert.assertNotNull; | |
5 | ||
6 | import java.util.UUID; | |
7 | ||
8 | import org.eclipse.linuxtools.ctf.core.trace.Utils; | |
9 | import org.junit.After; | |
10 | import org.junit.Before; | |
11 | import org.junit.Test; | |
12 | ||
13 | /** | |
14 | * The class <code>UtilsTest</code> contains tests for the class | |
15 | * <code>{@link Utils}</code>. | |
16 | * | |
17 | * @author ematkho | |
18 | * @version $Revision: 1.0 $ | |
19 | */ | |
20 | public class UtilsTest { | |
21 | ||
22 | /** | |
23 | * Launch the test. | |
24 | * | |
25 | * @param args | |
26 | * the command line arguments | |
27 | */ | |
28 | public static void main(String[] args) { | |
29 | new org.junit.runner.JUnitCore().run(UtilsTest.class); | |
30 | } | |
31 | ||
32 | /** | |
33 | * Perform pre-test initialization. | |
34 | */ | |
35 | @Before | |
36 | public void setUp() { | |
37 | // add additional set up code here | |
38 | } | |
39 | ||
40 | /** | |
41 | * Perform post-test clean-up. | |
42 | */ | |
43 | @After | |
44 | public void tearDown() { | |
45 | // Add additional tear down code here | |
46 | } | |
47 | ||
48 | /** | |
49 | * Run the Utils() constructor test. | |
50 | */ | |
51 | @Test | |
52 | public void testUtils() { | |
53 | Utils result = new Utils(); | |
54 | assertNotNull(result); | |
55 | } | |
56 | ||
57 | /** | |
58 | * Run the UUID makeUUID(byte[]) method test. | |
59 | */ | |
60 | @Test | |
61 | public void testMakeUUID() { | |
62 | int byteSize = 32; | |
63 | byte[] bytes = new byte[byteSize]; | |
64 | for (int i = 0; i < byteSize; i++) { | |
65 | bytes[i] = (byte) (i); | |
66 | } | |
67 | ||
68 | UUID result = Utils.makeUUID(bytes); | |
69 | assertNotNull(result); | |
70 | } | |
71 | ||
72 | /** | |
73 | * Run the UUID makeUUID(byte[]) method test. | |
74 | */ | |
75 | @Test | |
76 | public void testMakeUUID_2() { | |
77 | byte[] bytes = new byte[] { (byte) 1, (byte) 1, (byte) 0, (byte) 0, | |
78 | (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 1, | |
79 | (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }; | |
80 | ||
81 | UUID result = Utils.makeUUID(bytes); | |
82 | ||
83 | assertNotNull(result); | |
84 | assertEquals(72339069014638592L, result.getLeastSignificantBits()); | |
85 | assertEquals(72339069014638592L, result.getMostSignificantBits()); | |
86 | assertEquals("01010000-0000-0000-0101-000000000000", result.toString()); //$NON-NLS-1$ | |
87 | assertEquals(0, result.variant()); | |
88 | assertEquals(0, result.version()); | |
89 | } | |
90 | ||
91 | /** | |
92 | * Run the UUID makeUUID(byte[]) method test. | |
93 | */ | |
94 | @Test | |
95 | public void testMakeUUID_3() { | |
96 | byte[] bytes = new byte[] { (byte) 0, (byte) 0, (byte) 0, (byte) 0, | |
97 | (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, | |
98 | (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }; | |
99 | ||
100 | UUID result = Utils.makeUUID(bytes); | |
101 | ||
102 | assertNotNull(result); | |
103 | assertEquals(0L, result.getLeastSignificantBits()); | |
104 | assertEquals(0L, result.getMostSignificantBits()); | |
105 | assertEquals("00000000-0000-0000-0000-000000000000", result.toString()); //$NON-NLS-1$ | |
106 | assertEquals(0, result.variant()); | |
107 | assertEquals(0, result.version()); | |
108 | } | |
109 | ||
110 | /** | |
111 | * Run the int unsignedCompare(long,long) method test. | |
112 | */ | |
113 | @Test | |
114 | public void testUnsignedCompare() { | |
115 | long a = 1L; | |
116 | long b = 1L; | |
117 | ||
118 | int result = Utils.unsignedCompare(a, b); | |
119 | assertEquals(0, result); | |
120 | } | |
121 | } |