1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*******************************************************************************
* Copyright (c) 2012, 2013 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Matthew Khouzam - Initial generation with CodePro tools
* Alexandre Montplaisir - Clean up, consolidate redundant tests
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationInfo;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.junit.Before;
import org.junit.Test;
/**
* The class <code>CtfLocationTest</code> contains tests for the class
* <code>{@link CtfLocation}</code>.
*
* @author ematkho
* @version 1.0
*/
public class CtfLocationTest {
private CtfLocation fixture;
/**
* Perform pre-test initialization.
*/
@Before
public void setUp() {
fixture = new CtfLocation(new CtfLocationInfo(1, 0));
}
/**
* Run the CtfLocation(Long) constructor test.
*/
@Test
public void testCtfLocation_long() {
CtfLocationInfo location = new CtfLocationInfo(1, 0);
CtfLocation result = new CtfLocation(location);
assertNotNull(result);
assertEquals(Long.valueOf(1), (Long)result.getLocationInfo().getTimestamp());
}
/**
* Run the CtfLocation(ITmfTimestamp) constructor test.
*/
@Test
public void testCtfLocation_timestamp() {
ITmfTimestamp timestamp = new TmfTimestamp();
CtfLocation result = new CtfLocation(timestamp);
assertNotNull(result);
assertEquals(new Long(0L), (Long)result.getLocationInfo().getTimestamp());
}
/**
* Run the Long getLocation() method test.
*/
@Test
public void testGetLocation() {
CtfLocationInfo location = fixture.getLocationInfo();
Long result = location.getTimestamp();
assertNotNull(result);
assertEquals("1", result.toString()); //$NON-NLS-1$
assertEquals((byte) 1, result.byteValue());
assertEquals((short) 1, result.shortValue());
assertEquals(1, result.intValue());
assertEquals(1L, result.longValue());
assertEquals(1.0f, result.floatValue(), 1.0f);
assertEquals(1.0, result.doubleValue(), 1.0);
}
/**
* Run the void setLocation(Long) method test.
*/
@Test
public void testSetLocation() {
CtfLocationInfo location = new CtfLocationInfo(1337, 7331);
fixture = new CtfLocation(location);
}
/**
* Test the toString() method with a valid location.
*/
@Test
public void testToString_valid(){
CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(1337, 7331));
assertEquals("CtfLocation [fLocationInfo=Element [1337/7331]]", fixture2.toString()); //$NON-NLS-1$
}
/**
* Test the toString() method with an invalid location.
*/
@Test
public void testToString_invalid(){
CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(-1, -1));
assertEquals("CtfLocation [INVALID]", fixture2.toString()); //$NON-NLS-1$
}
}
|