Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfLocationTest.java
1 /*******************************************************************************
2 * Copyright (c) 2012 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 * Matthew Khouzam - Initial generation with CodePro tools
11 * Alexandre Montplaisir - Clean up, consolidate redundant tests
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
15
16 import static org.junit.Assert.assertEquals;
17 import static org.junit.Assert.assertNotNull;
18
19 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
20 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationData;
21 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
22 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
23 import org.junit.After;
24 import org.junit.Before;
25 import org.junit.Test;
26
27 /**
28 * The class <code>CtfLocationTest</code> contains tests for the class
29 * <code>{@link CtfLocation}</code>.
30 *
31 * @author ematkho
32 * @version 1.0
33 */
34 public class CtfLocationTest {
35
36 private CtfLocation fixture;
37
38 /**
39 * Launch the test.
40 *
41 * @param args
42 * the command line arguments
43 */
44 public static void main(String[] args) {
45 new org.junit.runner.JUnitCore().run(CtfLocationTest.class);
46 }
47
48 /**
49 * Perform pre-test initialization.
50 */
51 @Before
52 public void setUp() {
53 fixture = new CtfLocation(new CtfLocationData(1, 0));
54 }
55
56 /**
57 * Perform post-test clean-up.
58 */
59 @After
60 public void tearDown() {
61 // Add additional tear down code here
62 }
63
64
65 /**
66 * Run the CtfLocation(Long) constructor test.
67 */
68 @Test
69 public void testCtfLocation_long() {
70 CtfLocationData location = new CtfLocationData(1, 0);
71 CtfLocation result = new CtfLocation(location);
72
73 assertNotNull(result);
74 assertEquals(Long.valueOf(1), (Long)result.getLocationInfo().getTimestamp());
75 }
76
77 /**
78 * Run the CtfLocation(ITmfTimestamp) constructor test.
79 */
80 @Test
81 public void testCtfLocation_timestamp() {
82 ITmfTimestamp timestamp = new TmfTimestamp();
83 CtfLocation result = new CtfLocation(timestamp);
84
85 assertNotNull(result);
86 assertEquals(new Long(0L), (Long)result.getLocationInfo().getTimestamp());
87 }
88
89 /**
90 * Run the CtfLocation clone() method test.
91 */
92 @Test
93 public void testClone() {
94 CtfLocation result = fixture.clone();
95
96 assertNotNull(result);
97 assertEquals(Long.valueOf(1), (Long)result.getLocationInfo().getTimestamp());
98 }
99
100 /**
101 * Run the Long getLocation() method test.
102 */
103 @Test
104 public void testGetLocation() {
105 CtfLocationData location = fixture.getLocationInfo();
106 Long result = location.getTimestamp();
107 assertNotNull(result);
108 assertEquals("1", result.toString()); //$NON-NLS-1$
109 assertEquals((byte) 1, result.byteValue());
110 assertEquals((short) 1, result.shortValue());
111 assertEquals(1, result.intValue());
112 assertEquals(1L, result.longValue());
113 assertEquals(1.0f, result.floatValue(), 1.0f);
114 assertEquals(1.0, result.doubleValue(), 1.0);
115 }
116
117 /**
118 * Run the void setLocation(Long) method test.
119 */
120 @Test
121 public void testSetLocation() {
122 CtfLocationData location = new CtfLocationData(1337, 7331);
123 fixture = new CtfLocation(location);
124 }
125
126 /**
127 * Test the toString() method with a valid location.
128 */
129 @Test
130 public void testToString_valid(){
131 CtfLocation fixture2 = new CtfLocation(new CtfLocationData(1337, 7331));
132 assertEquals("CtfLocation: Element [1337/7331]",fixture2.toString()); //$NON-NLS-1$
133 }
134
135 /**
136 * Test the toString() method with an invalid location.
137 */
138 @Test
139 public void testToString_invalid(){
140 CtfLocation fixture2 = new CtfLocation(new CtfLocationData(-1, -1));
141 assertEquals("CtfLocation: INVALID",fixture2.toString()); //$NON-NLS-1$
142 }
143 }
This page took 0.043876 seconds and 6 git commands to generate.