tmf.ctf: Move each CtfIteratorManager into its own trace object
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ctf.core.tests / src / org / eclipse / tracecompass / tmf / ctf / core / tests / CtfLocationDataTest.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.ctf.core.tests;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertFalse;
17 import static org.junit.Assert.assertTrue;
18
19 import org.eclipse.tracecompass.tmf.ctf.core.CtfLocationInfo;
20 import org.junit.Before;
21 import org.junit.Test;
22
23 /**
24 * Collection of tests for the {@link CtfLocationInfo}
25 *
26 * @author alexmont
27 */
28 public class CtfLocationDataTest {
29
30 private CtfLocationInfo fixture;
31
32 /**
33 * Perform pre-test initialization.
34 */
35 @Before
36 public void setUp() {
37 fixture = new CtfLocationInfo(1, 0);
38 }
39
40 /**
41 * Test for the .getTimestamp() and .getIndex() methods
42 */
43 @Test
44 public void testGetters() {
45 long timestamp = fixture.getTimestamp();
46 long index = fixture.getIndex();
47
48 assertEquals(1, timestamp);
49 assertEquals(0, index);
50 }
51
52 /**
53 * Test for the .hashCode() method
54 */
55 @Test
56 public void testHashCode() {
57 int code = fixture.hashCode();
58 assertEquals(962, code);
59 }
60
61 /**
62 * Test for the .equals() method
63 */
64 @Test
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);
69
70 assertTrue(fixture.equals(same));
71 assertFalse(fixture.equals(diff1));
72 assertFalse(fixture.equals(diff2));
73 }
74
75 /**
76 * Test for the .compareTo() method
77 */
78 @Test
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);
84
85 assertEquals(0, same.compareTo(fixture));
86 assertEquals(-1, smaller.compareTo(fixture));
87 assertEquals(1, bigger1.compareTo(fixture));
88 assertEquals(1, bigger2.compareTo(fixture));
89 }
90
91 /**
92 * Test for the .toString() method
93 */
94 @Test
95 public void testToString() {
96 String expected = "Element [1/0]";
97 assertEquals(expected, fixture.toString());
98 }
99 }
This page took 0.032952 seconds and 5 git commands to generate.