LTTng: CPU usage analysis from the LTTng kernel trace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfLocationDataTest.java
CommitLineData
132a02b0 1/*******************************************************************************
61759503 2 * Copyright (c) 2012, 2013 Ericsson
132a02b0
MK
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
13package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
14
15import static org.junit.Assert.assertEquals;
16import static org.junit.Assert.assertFalse;
17import static org.junit.Assert.assertTrue;
18
f5df94f8 19import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
132a02b0
MK
20import org.junit.Before;
21import org.junit.Test;
22
23/**
f5df94f8 24 * Collection of tests for the {@link CtfLocationInfo}
132a02b0
MK
25 *
26 * @author alexmont
27 */
28public class CtfLocationDataTest {
29
f5df94f8 30 private CtfLocationInfo fixture;
132a02b0 31
132a02b0
MK
32 /**
33 * Perform pre-test initialization.
34 */
35 @Before
36 public void setUp() {
f5df94f8 37 fixture = new CtfLocationInfo(1, 0);
132a02b0
MK
38 }
39
132a02b0
MK
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() {
f5df94f8
AM
66 CtfLocationInfo same = new CtfLocationInfo(1, 0);
67 CtfLocationInfo diff1 = new CtfLocationInfo(100, 0);
68 CtfLocationInfo diff2 = new CtfLocationInfo(1, 10);
132a02b0
MK
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() {
f5df94f8
AM
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);
132a02b0
MK
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() {
cad06250 96 String expected = "Element [1/0]";
132a02b0
MK
97 assertEquals(expected, fixture.toString());
98 }
99}
This page took 0.040882 seconds and 5 git commands to generate.