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
.After
;
21 import org
.junit
.Before
;
22 import org
.junit
.Test
;
25 * Collection of tests for the {@link CtfLocationData}
29 public class CtfLocationDataTest
{
31 private CtfLocationData fixture
;
37 * the command line arguments
39 public static void main(String
[] args
) {
40 new org
.junit
.runner
.JUnitCore().run(CtfLocationDataTest
.class);
44 * Perform pre-test initialization.
48 fixture
= new CtfLocationData(1, 0);
52 * Perform post-test clean-up.
55 public void tearDown() {
56 // Add additional tear down code here
61 * Test for the .getTimestamp() and .getIndex() methods
64 public void testGetters() {
65 long timestamp
= fixture
.getTimestamp();
66 long index
= fixture
.getIndex();
68 assertEquals(1, timestamp
);
69 assertEquals(0, index
);
73 * Test for the .hashCode() method
76 public void testHashCode() {
77 int code
= fixture
.hashCode();
78 assertEquals(962, code
);
82 * Test for the .equals() method
85 public void testEquals() {
86 CtfLocationData same
= new CtfLocationData(1, 0);
87 CtfLocationData diff1
= new CtfLocationData(100, 0);
88 CtfLocationData diff2
= new CtfLocationData(1, 10);
90 assertTrue(fixture
.equals(same
));
91 assertFalse(fixture
.equals(diff1
));
92 assertFalse(fixture
.equals(diff2
));
96 * Test for the .compareTo() method
99 public void testCompareTo() {
100 CtfLocationData same
= new CtfLocationData(1, 0);
101 CtfLocationData smaller
= new CtfLocationData(0, 0);
102 CtfLocationData bigger1
= new CtfLocationData(1000, 500);
103 CtfLocationData bigger2
= new CtfLocationData(1, 1);
105 assertEquals(0, same
.compareTo(fixture
));
106 assertEquals(-1, smaller
.compareTo(fixture
));
107 assertEquals(1, bigger1
.compareTo(fixture
));
108 assertEquals(1, bigger2
.compareTo(fixture
));
112 * Test for the .toString() method
115 public void testToString() {
116 String expected
= "Element [1/0]"; //$NON-NLS-1$
117 assertEquals(expected
, fixture
.toString());
This page took 0.034403 seconds and 5 git commands to generate.