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
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.trace
;
14 import static org
.junit
.Assert
.assertEquals
;
15 import static org
.junit
.Assert
.assertNotNull
;
17 import java
.util
.UUID
;
19 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Utils
;
20 import org
.junit
.Test
;
23 * The class <code>UtilsTest</code> contains tests for the class
27 * @version $Revision: 1.0 $
29 public class UtilsTest
{
32 * Run the UUID makeUUID(byte[]) method test.
35 public void testMakeUUID() {
37 byte[] bytes
= new byte[byteSize
];
38 for (int i
= 0; i
< byteSize
; i
++) {
39 bytes
[i
] = (byte) (i
);
42 UUID result
= Utils
.makeUUID(bytes
);
43 assertNotNull(result
);
47 * Run the UUID makeUUID(byte[]) method 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 };
55 UUID result
= Utils
.makeUUID(bytes
);
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());
66 * Run the UUID makeUUID(byte[]) method 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 };
74 UUID result
= Utils
.makeUUID(bytes
);
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());
85 * Run the int unsignedCompare(long,long) method test.
88 public void testUnsignedCompare() {
93 result
= Utils
.unsignedCompare(a
, b
);
94 assertEquals(0, result
);
96 result
= Utils
.unsignedCompare(0L, 1L);
97 assertEquals(-1, result
);
98 result
= Utils
.unsignedCompare(0xFFFFFFFFL
, 0x100000000L
);
99 assertEquals(-1, result
);
100 result
= Utils
.unsignedCompare(-4L, -1L);
101 assertEquals(-1, result
);
102 result
= Utils
.unsignedCompare(-0x80000000L
, -1L);
103 assertEquals(-1, result
);
104 result
= Utils
.unsignedCompare(0x7FFFFFFFFFFFFFFEL
, 0x7FFFFFFFFFFFFFFFL
);
105 assertEquals(-1, result
);
107 result
= Utils
.unsignedCompare(1L, 0L);
108 assertEquals(1, result
);
109 result
= Utils
.unsignedCompare(0x100000000L
, 0xFFFFFFFFL
);
110 assertEquals(1, result
);
111 result
= Utils
.unsignedCompare(-1L, -4L);
112 assertEquals(1, result
);
113 result
= Utils
.unsignedCompare(-1L, -0x80000000L
);
114 assertEquals(1, result
);
115 result
= Utils
.unsignedCompare(0x7FFFFFFFFFFFFFFFL
, 0x7FFFFFFFFFFFFFFEL
);
116 assertEquals(1, result
);
This page took 0.039243 seconds and 5 git commands to generate.