tmf: Move timestamps to their own package
[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.CtfLocationInfo;
21 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
22 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
23 import org.junit.Before;
24 import org.junit.Test;
25
26 /**
27 * The class <code>CtfLocationTest</code> contains tests for the class
28 * <code>{@link CtfLocation}</code>.
29 *
30 * @author ematkho
31 * @version 1.0
32 */
33 public class CtfLocationTest {
34
35 private CtfLocation fixture;
36
37 /**
38 * Perform pre-test initialization.
39 */
40 @Before
41 public void setUp() {
42 fixture = new CtfLocation(new CtfLocationInfo(1, 0));
43 }
44
45 /**
46 * Run the CtfLocation(Long) constructor test.
47 */
48 @Test
49 public void testCtfLocation_long() {
50 CtfLocationInfo location = new CtfLocationInfo(1, 0);
51 CtfLocation result = new CtfLocation(location);
52
53 assertNotNull(result);
54 assertEquals(Long.valueOf(1), (Long)result.getLocationInfo().getTimestamp());
55 }
56
57 /**
58 * Run the CtfLocation(ITmfTimestamp) constructor test.
59 */
60 @Test
61 public void testCtfLocation_timestamp() {
62 ITmfTimestamp timestamp = new TmfTimestamp();
63 CtfLocation result = new CtfLocation(timestamp);
64
65 assertNotNull(result);
66 assertEquals(new Long(0L), (Long)result.getLocationInfo().getTimestamp());
67 }
68
69 /**
70 * Run the Long getLocation() method test.
71 */
72 @Test
73 public void testGetLocation() {
74 CtfLocationInfo location = fixture.getLocationInfo();
75 Long result = location.getTimestamp();
76 assertNotNull(result);
77 assertEquals("1", result.toString()); //$NON-NLS-1$
78 assertEquals((byte) 1, result.byteValue());
79 assertEquals((short) 1, result.shortValue());
80 assertEquals(1, result.intValue());
81 assertEquals(1L, result.longValue());
82 assertEquals(1.0f, result.floatValue(), 1.0f);
83 assertEquals(1.0, result.doubleValue(), 1.0);
84 }
85
86 /**
87 * Run the void setLocation(Long) method test.
88 */
89 @Test
90 public void testSetLocation() {
91 CtfLocationInfo location = new CtfLocationInfo(1337, 7331);
92 fixture = new CtfLocation(location);
93 }
94
95 /**
96 * Test the toString() method with a valid location.
97 */
98 @Test
99 public void testToString_valid(){
100 CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(1337, 7331));
101 assertEquals("CtfLocation [fLocationInfo=Element [1337/7331]]", fixture2.toString()); //$NON-NLS-1$
102 }
103
104 /**
105 * Test the toString() method with an invalid location.
106 */
107 @Test
108 public void testToString_invalid(){
109 CtfLocation fixture2 = new CtfLocation(new CtfLocationInfo(-1, -1));
110 assertEquals("CtfLocation [INVALID]", fixture2.toString()); //$NON-NLS-1$
111 }
112 }
This page took 0.038229 seconds and 6 git commands to generate.