ctf: Update copyright headers and add missing ones
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / IntegerDefinitionTest.java
1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
11
12 package org.eclipse.linuxtools.ctf.core.tests.types;
13
14 import static org.junit.Assert.assertEquals;
15 import static org.junit.Assert.assertNotNull;
16
17 import java.nio.ByteOrder;
18
19 import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
20 import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
21 import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
22 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
23 import org.eclipse.linuxtools.ctf.core.event.types.IntegerDefinition;
24 import org.junit.After;
25 import org.junit.Before;
26 import org.junit.Test;
27
28 /**
29 * The class <code>IntegerDefinitionTest</code> contains tests for the class
30 * <code>{@link IntegerDefinition}</code>.
31 *
32 * @author ematkho
33 * @version $Revision: 1.0 $
34 */
35 public class IntegerDefinitionTest {
36
37 private IntegerDefinition fixture;
38 String name = "testInt"; //$NON-NLS-1$
39 String clockName = "clock"; //$NON-NLS-1$
40 /**
41 * Launch the test.
42 *
43 * @param args
44 * the command line arguments
45 */
46 public static void main(String[] args) {
47 new org.junit.runner.JUnitCore().run(IntegerDefinitionTest.class);
48 }
49
50 /**
51 * Perform pre-test initialization. We know the structDef won't be null (or
52 * else the tests will fail), so we can safely suppress the warning.
53 */
54 @Before
55 public void setUp() {
56
57 // StructDefinition structDef = null;
58 // boolean found = false;
59 IntegerDeclaration id = new IntegerDeclaration( 1, true, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
60 fixture = id.createDefinition(null, name);
61 }
62
63 /**
64 * Perform post-test clean-up.
65 */
66 @After
67 public void tearDown() {
68 // Add additional tear down code here
69 }
70
71 /**
72 * Run the IntegerDefinition(IntegerDeclaration,DefinitionScope,String)
73 * constructor test.
74 */
75 @Test
76 public void testIntegerDefinition() {
77 IntegerDeclaration declaration = new IntegerDeclaration(1, true, 1,
78 ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8);
79 IDefinitionScope definitionScope = null;
80 String fieldName = ""; //$NON-NLS-1$
81
82 IntegerDefinition result = new IntegerDefinition(declaration,
83 definitionScope, fieldName);
84 assertNotNull(result);
85 }
86
87 /**
88 * Run the IntegerDeclaration getDeclaration() method test.
89 */
90 @Test
91 public void testGetDeclaration() {
92 fixture.setValue(1L);
93
94 IntegerDeclaration result = fixture.getDeclaration();
95 assertNotNull(result);
96 }
97
98 /**
99 * Run the long getValue() method test.
100 */
101 @Test
102 public void testGetValue() {
103 fixture.setValue(1L);
104
105 long result = fixture.getValue();
106 assertEquals(1L, result);
107 }
108
109 /**
110 * Run the void read(BitBuffer) method test.
111 */
112 @Test
113 public void testRead() {
114 fixture.setValue(1L);
115 BitBuffer input = new BitBuffer(java.nio.ByteBuffer.allocateDirect(128));
116
117 fixture.read(input);
118 }
119
120 /**
121 * Run the String toString() method test.
122 */
123 @Test
124 public void testToString() {
125 fixture.setValue(1L);
126
127 String result = fixture.toString();
128 assertNotNull(result);
129 }
130 }
This page took 0.033066 seconds and 5 git commands to generate.