1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.ctfadaptor
;
15 import static org
.junit
.Assert
.assertEquals
;
16 import static org
.junit
.Assert
.assertFalse
;
17 import static org
.junit
.Assert
.assertTrue
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfLocationData
;
20 import org
.junit
.Before
;
21 import org
.junit
.Test
;
24 * Collection of tests for the {@link CtfLocationData}
28 public class CtfLocationDataTest
{
30 private CtfLocationData fixture
;
33 * Perform pre-test initialization.
37 fixture
= new CtfLocationData(1, 0);
41 * Test for the .getTimestamp() and .getIndex() methods
44 public void testGetters() {
45 long timestamp
= fixture
.getTimestamp();
46 long index
= fixture
.getIndex();
48 assertEquals(1, timestamp
);
49 assertEquals(0, index
);
53 * Test for the .hashCode() method
56 public void testHashCode() {
57 int code
= fixture
.hashCode();
58 assertEquals(962, code
);
62 * Test for the .equals() method
65 public void testEquals() {
66 CtfLocationData same
= new CtfLocationData(1, 0);
67 CtfLocationData diff1
= new CtfLocationData(100, 0);
68 CtfLocationData diff2
= new CtfLocationData(1, 10);
70 assertTrue(fixture
.equals(same
));
71 assertFalse(fixture
.equals(diff1
));
72 assertFalse(fixture
.equals(diff2
));
76 * Test for the .compareTo() method
79 public void testCompareTo() {
80 CtfLocationData same
= new CtfLocationData(1, 0);
81 CtfLocationData smaller
= new CtfLocationData(0, 0);
82 CtfLocationData bigger1
= new CtfLocationData(1000, 500);
83 CtfLocationData bigger2
= new CtfLocationData(1, 1);
85 assertEquals(0, same
.compareTo(fixture
));
86 assertEquals(-1, smaller
.compareTo(fixture
));
87 assertEquals(1, bigger1
.compareTo(fixture
));
88 assertEquals(1, bigger2
.compareTo(fixture
));
92 * Test for the .toString() method
95 public void testToString() {
96 String expected
= "Element [1/0]"; //$NON-NLS-1$
97 assertEquals(expected
, fixture
.toString());
This page took 0.032448 seconds and 5 git commands to generate.