1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 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
.tracecompass
.tmf
.ctf
.core
.tests
.context
;
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
.tracecompass
.tmf
.ctf
.core
.context
.CtfLocationInfo
;
20 import org
.junit
.Before
;
21 import org
.junit
.Test
;
24 * Collection of tests for the {@link CtfLocationInfo}
28 public class CtfLocationDataTest
{
30 private CtfLocationInfo fixture
;
33 * Perform pre-test initialization.
37 fixture
= new CtfLocationInfo(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 CtfLocationInfo same
= new CtfLocationInfo(1, 0);
67 CtfLocationInfo diff1
= new CtfLocationInfo(100, 0);
68 CtfLocationInfo diff2
= new CtfLocationInfo(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 CtfLocationInfo same
= new CtfLocationInfo(1, 0);
81 CtfLocationInfo smaller
= new CtfLocationInfo(0, 0);
82 CtfLocationInfo bigger1
= new CtfLocationInfo(1000, 500);
83 CtfLocationInfo bigger2
= new CtfLocationInfo(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]";
97 assertEquals(expected
, fixture
.toString());
This page took 0.036229 seconds and 5 git commands to generate.