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 * Matthew Khouzam - Initial generation with CodePro tools
11 * Alexandre Montplaisir - Clean up, consolidate redundant tests
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.ctfadaptor
;
16 import static org
.junit
.Assert
.assertEquals
;
17 import static org
.junit
.Assert
.assertNotNull
;
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
;
28 * The class <code>CtfLocationTest</code> contains tests for the class
29 * <code>{@link CtfLocation}</code>.
34 public class CtfLocationTest
{
36 private CtfLocation fixture
;
42 * the command line arguments
44 public static void main(String
[] args
) {
45 new org
.junit
.runner
.JUnitCore().run(CtfLocationTest
.class);
49 * Perform pre-test initialization.
53 fixture
= new CtfLocation(new CtfLocationData(1, 0));
54 fixture
.setLocation(new CtfLocationData(1, 0));
58 * Perform post-test clean-up.
61 public void tearDown() {
62 // Add additional tear down code here
67 * Run the CtfLocation(Long) constructor test.
70 public void testCtfLocation_long() {
71 CtfLocationData location
= new CtfLocationData(1, 0);
72 CtfLocation result
= new CtfLocation(location
);
74 assertNotNull(result
);
75 assertEquals(Long
.valueOf(1), (Long
)result
.getLocation().getTimestamp());
79 * Run the CtfLocation(ITmfTimestamp) constructor test.
82 public void testCtfLocation_timestamp() {
83 ITmfTimestamp timestamp
= new TmfTimestamp();
84 CtfLocation result
= new CtfLocation(timestamp
);
86 assertNotNull(result
);
87 assertEquals(new Long(0L), (Long
)result
.getLocation().getTimestamp());
91 * Run the CtfLocation clone() method test.
94 public void testClone() {
95 CtfLocation result
= fixture
.clone();
97 assertNotNull(result
);
98 assertEquals(Long
.valueOf(1), (Long
)result
.getLocation().getTimestamp());
102 * Run the Long getLocation() method test.
105 public void testGetLocation() {
106 CtfLocationData location
= fixture
.getLocation();
107 Long result
= location
.getTimestamp();
108 assertNotNull(result
);
109 assertEquals("1", result
.toString()); //$NON-NLS-1$
110 assertEquals((byte) 1, result
.byteValue());
111 assertEquals((short) 1, result
.shortValue());
112 assertEquals(1, result
.intValue());
113 assertEquals(1L, result
.longValue());
114 assertEquals(1.0f
, result
.floatValue(), 1.0f
);
115 assertEquals(1.0, result
.doubleValue(), 1.0);
119 * Run the void setLocation(Long) method test.
122 public void testSetLocation() {
123 CtfLocationData location
= new CtfLocationData(1337, 7331);
124 fixture
.setLocation(location
);
128 * Test the toString() method with a valid location.
131 public void testToString_valid(){
132 CtfLocation fixture2
= new CtfLocation(new CtfLocationData(1337, 7331));
133 assertEquals("CtfLocation: Element [1337/7331]",fixture2
.toString()); //$NON-NLS-1$
137 * Test the toString() method with an invalid location.
140 public void testToString_invalid(){
141 CtfLocation fixture2
= new CtfLocation(new CtfLocationData(-1, -1));
142 assertEquals("CtfLocation: INVALID",fixture2
.toString()); //$NON-NLS-1$
This page took 0.035252 seconds and 6 git commands to generate.