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
.Before
;
24 import org
.junit
.Test
;
27 * The class <code>CtfLocationTest</code> contains tests for the class
28 * <code>{@link CtfLocation}</code>.
33 public class CtfLocationTest
{
35 private CtfLocation fixture
;
38 * Perform pre-test initialization.
42 fixture
= new CtfLocation(new CtfLocationData(1, 0));
46 * Run the CtfLocation(Long) constructor test.
49 public void testCtfLocation_long() {
50 CtfLocationData location
= new CtfLocationData(1, 0);
51 CtfLocation result
= new CtfLocation(location
);
53 assertNotNull(result
);
54 assertEquals(Long
.valueOf(1), (Long
)result
.getLocationInfo().getTimestamp());
58 * Run the CtfLocation(ITmfTimestamp) constructor test.
61 public void testCtfLocation_timestamp() {
62 ITmfTimestamp timestamp
= new TmfTimestamp();
63 CtfLocation result
= new CtfLocation(timestamp
);
65 assertNotNull(result
);
66 assertEquals(new Long(0L), (Long
)result
.getLocationInfo().getTimestamp());
70 * Run the CtfLocation clone() method test.
73 public void testClone() {
74 CtfLocation result
= fixture
.clone();
76 assertNotNull(result
);
77 assertEquals(Long
.valueOf(1), (Long
)result
.getLocationInfo().getTimestamp());
81 * Run the Long getLocation() method test.
84 public void testGetLocation() {
85 CtfLocationData location
= fixture
.getLocationInfo();
86 Long result
= location
.getTimestamp();
87 assertNotNull(result
);
88 assertEquals("1", result
.toString()); //$NON-NLS-1$
89 assertEquals((byte) 1, result
.byteValue());
90 assertEquals((short) 1, result
.shortValue());
91 assertEquals(1, result
.intValue());
92 assertEquals(1L, result
.longValue());
93 assertEquals(1.0f
, result
.floatValue(), 1.0f
);
94 assertEquals(1.0, result
.doubleValue(), 1.0);
98 * Run the void setLocation(Long) method test.
101 public void testSetLocation() {
102 CtfLocationData location
= new CtfLocationData(1337, 7331);
103 fixture
= new CtfLocation(location
);
107 * Test the toString() method with a valid location.
110 public void testToString_valid(){
111 CtfLocation fixture2
= new CtfLocation(new CtfLocationData(1337, 7331));
112 assertEquals("CtfLocation: Element [1337/7331]",fixture2
.toString()); //$NON-NLS-1$
116 * Test the toString() method with an invalid location.
119 public void testToString_invalid(){
120 CtfLocation fixture2
= new CtfLocation(new CtfLocationData(-1, -1));
121 assertEquals("CtfLocation: INVALID",fixture2
.toString()); //$NON-NLS-1$
This page took 0.034698 seconds and 6 git commands to generate.