tmf: Rename TmfLocation.fLocation to .fLocationData
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core.tests / src / org / eclipse / linuxtools / tmf / core / tests / ctfadaptor / CtfLocationTest.java
CommitLineData
95bf10e7
AM
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
81c8e6f7
MK
14package org.eclipse.linuxtools.tmf.core.tests.ctfadaptor;
15
19e45ccc
MK
16import static org.junit.Assert.assertEquals;
17import static org.junit.Assert.assertNotNull;
18
81c8e6f7 19import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocation;
132a02b0 20import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfLocationData;
81c8e6f7
MK
21import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
22import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
19e45ccc
MK
23import org.junit.After;
24import org.junit.Before;
25import org.junit.Test;
81c8e6f7
MK
26
27/**
95bf10e7
AM
28 * The class <code>CtfLocationTest</code> contains tests for the class
29 * <code>{@link CtfLocation}</code>.
81c8e6f7 30 *
81c8e6f7 31 * @author ematkho
95bf10e7 32 * @version 1.0
81c8e6f7
MK
33 */
34public class CtfLocationTest {
95bf10e7
AM
35
36 private CtfLocation fixture;
37
81c8e6f7 38 /**
95bf10e7 39 * Launch the test.
81c8e6f7 40 *
95bf10e7
AM
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() {
132a02b0
MK
53 fixture = new CtfLocation(new CtfLocationData(1, 0));
54 fixture.setLocation(new CtfLocationData(1, 0));
95bf10e7
AM
55 }
56
57 /**
58 * Perform post-test clean-up.
59 */
60 @After
61 public void tearDown() {
62 // Add additional tear down code here
63 }
64
65
66 /**
67 * Run the CtfLocation(Long) constructor test.
81c8e6f7
MK
68 */
69 @Test
95bf10e7 70 public void testCtfLocation_long() {
132a02b0 71 CtfLocationData location = new CtfLocationData(1, 0);
81c8e6f7
MK
72 CtfLocation result = new CtfLocation(location);
73
81c8e6f7 74 assertNotNull(result);
6bab4511 75 assertEquals(Long.valueOf(1), (Long)result.getLocationData().getTimestamp());
81c8e6f7
MK
76 }
77
78 /**
79 * Run the CtfLocation(ITmfTimestamp) constructor test.
81c8e6f7
MK
80 */
81 @Test
95bf10e7 82 public void testCtfLocation_timestamp() {
81c8e6f7 83 ITmfTimestamp timestamp = new TmfTimestamp();
81c8e6f7
MK
84 CtfLocation result = new CtfLocation(timestamp);
85
81c8e6f7 86 assertNotNull(result);
6bab4511 87 assertEquals(new Long(0L), (Long)result.getLocationData().getTimestamp());
81c8e6f7
MK
88 }
89
90 /**
91 * Run the CtfLocation clone() method test.
81c8e6f7
MK
92 */
93 @Test
95bf10e7 94 public void testClone() {
81c8e6f7
MK
95 CtfLocation result = fixture.clone();
96
81c8e6f7 97 assertNotNull(result);
6bab4511 98 assertEquals(Long.valueOf(1), (Long)result.getLocationData().getTimestamp());
81c8e6f7
MK
99 }
100
101 /**
102 * Run the Long getLocation() method test.
81c8e6f7
MK
103 */
104 @Test
95bf10e7 105 public void testGetLocation() {
6bab4511 106 CtfLocationData location = fixture.getLocationData();
132a02b0 107 Long result = location.getTimestamp();
81c8e6f7 108 assertNotNull(result);
19e45ccc 109 assertEquals("1", result.toString()); //$NON-NLS-1$
81c8e6f7
MK
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);
116 }
117
118 /**
119 * Run the void setLocation(Long) method test.
81c8e6f7
MK
120 */
121 @Test
95bf10e7 122 public void testSetLocation() {
132a02b0 123 CtfLocationData location = new CtfLocationData(1337, 7331);
81c8e6f7 124 fixture.setLocation(location);
19e45ccc
MK
125 }
126
81c8e6f7 127 /**
95bf10e7 128 * Test the toString() method with a valid location.
81c8e6f7 129 */
95bf10e7
AM
130 @Test
131 public void testToString_valid(){
132a02b0
MK
132 CtfLocation fixture2 = new CtfLocation(new CtfLocationData(1337, 7331));
133 assertEquals("CtfLocation: Element [1337/7331]",fixture2.toString()); //$NON-NLS-1$
81c8e6f7
MK
134 }
135
136 /**
95bf10e7 137 * Test the toString() method with an invalid location.
81c8e6f7 138 */
95bf10e7
AM
139 @Test
140 public void testToString_invalid(){
132a02b0 141 CtfLocation fixture2 = new CtfLocation(new CtfLocationData(-1, -1));
95bf10e7 142 assertEquals("CtfLocation: INVALID",fixture2.toString()); //$NON-NLS-1$
81c8e6f7 143 }
95bf10e7 144}
This page took 0.032922 seconds and 5 git commands to generate.