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
.IDeclaration
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDeclaration
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.SequenceDeclaration
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.SequenceDefinition
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDeclaration
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDefinition
;
16 import org
.junit
.After
;
17 import org
.junit
.Before
;
18 import org
.junit
.Test
;
21 * The class <code>SequenceDeclarationTest</code> contains tests for the class
22 * <code>{@link SequenceDeclaration}</code>.
25 * @version $Revision: 1.0 $
27 public class SequenceDeclarationTest
{
29 private SequenceDeclaration fixture
;
35 * the command line arguments
37 public static void main(String
[] args
) {
38 new org
.junit
.runner
.JUnitCore().run(SequenceDeclarationTest
.class);
43 fixture
= new SequenceDeclaration("", new StringDeclaration()); //$NON-NLS-1$
47 public void tearDown() {
48 // Add additional tear down code here
52 * Run the SequenceDeclaration(String,Declaration) constructor test.
55 public void testSequenceDeclaration() {
56 String lengthName
= ""; //$NON-NLS-1$
57 IDeclaration elemType
= new StringDeclaration();
59 SequenceDeclaration result
= new SequenceDeclaration(lengthName
,
61 assertNotNull(result
);
62 String string
= "[declaration] sequence["; //$NON-NLS-1$
63 assertEquals(string
, result
.toString().substring(0, string
.length()));
67 * Run the SequenceDefinition createDefinition(DefinitionScope,String)
71 public void testCreateDefinition() {
72 IntegerDeclaration id
= new IntegerDeclaration(8, false, 8,
73 ByteOrder
.LITTLE_ENDIAN
, Encoding
.UTF8
);
74 String fieldName
= "LengthName"; //$NON-NLS-1$
75 StructDeclaration structDec
= new StructDeclaration(0);
76 structDec
.addField(fieldName
, id
);
77 StructDefinition structDef
= new StructDefinition(structDec
, null, "x"); //$NON-NLS-1$
79 structDef
.lookupInteger(fieldName
).setValue(seqLen
);
80 SequenceDefinition result
= this.fixture
.createDefinition(structDef
,
82 assertNotNull(result
);
86 * Run the Declaration getElementType() method test.
89 public void testGetElementType() {
90 IDeclaration result
= fixture
.getElementType();
91 assertNotNull(result
);
95 * Run the String toString() method test.
98 public void testToString() {
99 String result
= fixture
.toString();
100 String left
= "[declaration] sequence["; //$NON-NLS-1$
101 assertEquals(left
, result
.substring(0, left
.length()));