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
.types
.Encoding
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDeclaration
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDefinition
;
12 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.io
.BitBuffer
;
13 import org
.junit
.After
;
14 import org
.junit
.Before
;
15 import org
.junit
.Test
;
18 * The class <code>IntegerDefinitionTest</code> contains tests for the class
19 * <code>{@link IntegerDefinition}</code>.
22 * @version $Revision: 1.0 $
24 public class IntegerDefinitionTest
{
26 private IntegerDefinition fixture
;
27 String name
= "testInt"; //$NON-NLS-1$
28 String clockName
= "clock"; //$NON-NLS-1$
33 * the command line arguments
35 public static void main(String
[] args
) {
36 new org
.junit
.runner
.JUnitCore().run(IntegerDefinitionTest
.class);
40 * Perform pre-test initialization. We know the structDef won't be null (or
41 * else the tests will fail), so we can safely suppress the warning.
46 // StructDefinition structDef = null;
47 // boolean found = false;
48 IntegerDeclaration id
= new IntegerDeclaration( 1, true, 1, ByteOrder
.BIG_ENDIAN
, Encoding
.NONE
, clockName
, 8);
49 fixture
= id
.createDefinition(null, name
);
53 * Perform post-test clean-up.
56 public void tearDown() {
57 // Add additional tear down code here
61 * Run the IntegerDefinition(IntegerDeclaration,DefinitionScope,String)
65 public void testIntegerDefinition() {
66 IntegerDeclaration declaration
= new IntegerDeclaration(1, true, 1,
67 ByteOrder
.BIG_ENDIAN
, Encoding
.ASCII
, null, 8);
68 IDefinitionScope definitionScope
= null;
69 String fieldName
= ""; //$NON-NLS-1$
71 IntegerDefinition result
= new IntegerDefinition(declaration
,
72 definitionScope
, fieldName
);
73 assertNotNull(result
);
77 * Run the IntegerDeclaration getDeclaration() method test.
80 public void testGetDeclaration() {
83 IntegerDeclaration result
= fixture
.getDeclaration();
84 assertNotNull(result
);
88 * Run the long getValue() method test.
91 public void testGetValue() {
94 long result
= fixture
.getValue();
95 assertEquals(1L, result
);
99 * Run the void read(BitBuffer) method test.
102 public void testRead() {
103 fixture
.setValue(1L);
104 BitBuffer input
= new BitBuffer(java
.nio
.ByteBuffer
.allocateDirect(128));
110 * Run the String toString() method test.
113 public void testToString() {
114 fixture
.setValue(1L);
116 String result
= fixture
.toString();
117 assertNotNull(result
);