1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
3 import static org
.junit
.Assert
.assertEquals
;
4 import static org
.junit
.Assert
.assertNotNull
;
6 import java
.nio
.ByteOrder
;
8 import org
.eclipse
.linuxtools
.ctf
.core
.event
.EventDefinition
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Encoding
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDeclaration
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDefinition
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDefinition
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.TestParams
;
16 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
17 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTrace
;
18 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFTraceReader
;
19 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.io
.BitBuffer
;
20 import org
.junit
.After
;
21 import org
.junit
.Before
;
22 import org
.junit
.Test
;
25 * The class <code>IntegerDefinitionTest</code> contains tests for the class
26 * <code>{@link IntegerDefinition}</code>.
29 * @version $Revision: 1.0 $
31 public class IntegerDefinitionTest
{
33 private IntegerDefinition fixture
;
39 * the command line arguments
41 public static void main(String
[] args
) {
42 new org
.junit
.runner
.JUnitCore().run(IntegerDefinitionTest
.class);
46 * Perform pre-test initialization. We know the structDef won't be null (or
47 * else the tests will fail), so we can safely suppress the warning.
49 * @throws CTFReaderException
52 public void setUp() throws CTFReaderException
{
53 CTFTrace trace
= TestParams
.createTrace();
54 CTFTraceReader tr
= new CTFTraceReader(trace
);
55 String name
= ""; //$NON-NLS-1$
56 StructDefinition structDef
= null;
57 boolean found
= false;
59 while (tr
.hasMoreEvents() && !found
) {
61 EventDefinition ed
= tr
.getCurrentEventDef();
62 for (String key
: ed
.fields
.getDefinitions().keySet()) {
63 structDef
= ed
.fields
;
64 Definition d
= structDef
.lookupDefinition(key
);
65 if (d
instanceof IntegerDefinition
) {
72 assert (structDef
!= null);
73 fixture
= structDef
.lookupInteger(name
);
77 * Perform post-test clean-up.
80 public void tearDown() {
81 // Add additional tear down code here
85 * Run the IntegerDefinition(IntegerDeclaration,DefinitionScope,String)
89 public void testIntegerDefinition() {
90 IntegerDeclaration declaration
= new IntegerDeclaration(1, true, 1,
91 ByteOrder
.BIG_ENDIAN
, Encoding
.ASCII
, null);
92 IDefinitionScope definitionScope
= null;
93 String fieldName
= ""; //$NON-NLS-1$
95 IntegerDefinition result
= new IntegerDefinition(declaration
,
96 definitionScope
, fieldName
);
97 assertNotNull(result
);
101 * Run the IntegerDeclaration getDeclaration() method test.
104 public void testGetDeclaration() {
105 fixture
.setValue(1L);
107 IntegerDeclaration result
= fixture
.getDeclaration();
108 assertNotNull(result
);
112 * Run the long getValue() method test.
115 public void testGetValue() {
116 fixture
.setValue(1L);
118 long result
= fixture
.getValue();
119 assertEquals(1L, result
);
123 * Run the void read(BitBuffer) method test.
126 public void testRead() {
127 fixture
.setValue(1L);
128 BitBuffer input
= new BitBuffer(java
.nio
.ByteBuffer
.allocateDirect(128));
134 * Run the String toString() method test.
137 public void testToString() {
138 fixture
.setValue(1L);
140 String result
= fixture
.toString();
141 assertNotNull(result
);