ctf: Fix some Sonar warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / trace / UtilsTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
11
12 package org.eclipse.linuxtools.ctf.core.tests.trace;
13
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertNotNull;
16
17 import java.util.UUID;
18
19 import org.eclipse.linuxtools.ctf.core.trace.Utils;
20 import org.junit.Test;
21
22 /**
23 * The class <code>UtilsTest</code> contains tests for the class
24 * {@link Utils}.
25 *
26 * @author ematkho
27 * @version $Revision: 1.0 $
28 */
29 public class UtilsTest {
30
31 /**
32 * Run the UUID makeUUID(byte[]) method test.
33 */
34 @Test
35 public void testMakeUUID() {
36 int byteSize = 32;
37 byte[] bytes = new byte[byteSize];
38 for (int i = 0; i < byteSize; i++) {
39 bytes[i] = (byte) (i);
40 }
41
42 UUID result = Utils.makeUUID(bytes);
43 assertNotNull(result);
44 }
45
46 /**
47 * Run the UUID makeUUID(byte[]) method test.
48 */
49 @Test
50 public void testMakeUUID_2() {
51 byte[] bytes = new byte[] { (byte) 1, (byte) 1, (byte) 0, (byte) 0,
52 (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1, (byte) 1,
53 (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
54
55 UUID result = Utils.makeUUID(bytes);
56
57 assertNotNull(result);
58 assertEquals(72339069014638592L, result.getLeastSignificantBits());
59 assertEquals(72339069014638592L, result.getMostSignificantBits());
60 assertEquals("01010000-0000-0000-0101-000000000000", result.toString());
61 assertEquals(0, result.variant());
62 assertEquals(0, result.version());
63 }
64
65 /**
66 * Run the UUID makeUUID(byte[]) method test.
67 */
68 @Test
69 public void testMakeUUID_3() {
70 byte[] bytes = new byte[] { (byte) 0, (byte) 0, (byte) 0, (byte) 0,
71 (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0,
72 (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 };
73
74 UUID result = Utils.makeUUID(bytes);
75
76 assertNotNull(result);
77 assertEquals(0L, result.getLeastSignificantBits());
78 assertEquals(0L, result.getMostSignificantBits());
79 assertEquals("00000000-0000-0000-0000-000000000000", result.toString());
80 assertEquals(0, result.variant());
81 assertEquals(0, result.version());
82 }
83
84 /**
85 * Run the int unsignedCompare(long,long) method test.
86 */
87 @Test
88 public void testUnsignedCompare() {
89 long a = 1L;
90 long b = 1L;
91
92 int result = Utils.unsignedCompare(a, b);
93 assertEquals(0, result);
94 }
95 }
This page took 0.031758 seconds and 5 git commands to generate.