1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
3 import static org
.junit
.Assert
.assertNotNull
;
4 import static org
.junit
.Assert
.assertNull
;
6 import java
.nio
.ByteOrder
;
7 import java
.util
.HashMap
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.ArrayDefinition
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Encoding
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.EnumDeclaration
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.EnumDefinition
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDeclaration
;
16 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDefinition
;
17 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.SequenceDefinition
;
18 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDefinition
;
19 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
20 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDefinition
;
21 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.VariantDeclaration
;
22 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.VariantDefinition
;
23 import org
.eclipse
.linuxtools
.ctf
.core
.tests
.TestParams
;
24 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFReaderException
;
25 import org
.junit
.After
;
26 import org
.junit
.Before
;
27 import org
.junit
.Test
;
30 * The class <code>VariantDefinitionTest</code> contains tests for the class
31 * <code>{@link VariantDefinition}</code>.
34 * @version $Revision: 1.0 $
36 public class VariantDefinitionTest
{
38 private VariantDefinition fixture
;
44 * the command line arguments
46 public static void main(String
[] args
) {
47 new org
.junit
.runner
.JUnitCore().run(VariantDefinitionTest
.class);
51 * Perform pre-test initialization.
53 * Not sure it needs to be that complicated, oh well...
55 * @throws CTFReaderException
58 public void setUp() throws CTFReaderException
{
59 VariantDeclaration vDecl1
, vDecl2
, vDecl3
;
60 VariantDefinition vDef1
, vDef2
;
61 StructDefinition sDef1
, sDef2
;
63 String fName
= ""; //$NON-NLS-1$
65 vDecl1
= new VariantDeclaration();
66 vDecl2
= new VariantDeclaration();
67 vDecl3
= new VariantDeclaration();
72 vDef1
= new VariantDefinition(vDecl2
, TestParams
.createTrace(), fName
);
73 vDef2
= new VariantDefinition(vDecl3
, TestParams
.createTrace(), fName
);
75 sDef1
= new StructDefinition(new StructDeclaration(1L), vDef1
, fName
);
76 sDef2
= new StructDefinition(new StructDeclaration(1L), vDef2
, fName
);
78 eDef
= new EnumDefinition(new EnumDeclaration(new IntegerDeclaration(1,
79 true, 1, ByteOrder
.BIG_ENDIAN
, Encoding
.ASCII
, fName
)), sDef2
, fName
);
81 fixture
= new VariantDefinition(vDecl1
, sDef1
, fName
);
82 fixture
.setTagDefinition(eDef
);
83 fixture
.setCurrentField(fName
);
87 * Perform post-test clean-up.
90 public void tearDown() {
91 // Add additional tear down code here
95 * Run the VariantDefinition(VariantDeclaration,DefinitionScope,String)
97 * @throws CTFReaderException
100 public void testVariantDefinition() throws CTFReaderException
{
101 VariantDeclaration declaration
= new VariantDeclaration();
102 declaration
.setTag(""); //$NON-NLS-1$
103 VariantDeclaration variantDeclaration
= new VariantDeclaration();
104 variantDeclaration
.setTag(""); //$NON-NLS-1$
105 VariantDefinition variantDefinition
= new VariantDefinition(
106 variantDeclaration
, TestParams
.createTrace(), ""); //$NON-NLS-1$
107 IDefinitionScope definitionScope
= new StructDefinition(
108 new StructDeclaration(1L), variantDefinition
, ""); //$NON-NLS-1$
109 String fieldName
= ""; //$NON-NLS-1$
111 VariantDefinition result
= new VariantDefinition(declaration
,
112 definitionScope
, fieldName
);
113 assertNotNull(result
);
117 * Run the Definition getCurrentField() method test.
120 public void testGetCurrentField() {
121 Definition result
= fixture
.getCurrentField();
126 * Run the String getCurrentFieldName() method test.
129 public void testGetCurrentFieldName() {
130 String result
= fixture
.getCurrentFieldName();
131 assertNotNull(result
);
135 * Run the VariantDeclaration getDeclaration() method test.
138 public void testGetDeclaration() {
139 VariantDeclaration result
= fixture
.getDeclaration();
140 assertNotNull(result
);
144 * Run the HashMap<String, Definition> getDefinitions() method test.
147 public void testGetDefinitions() {
148 HashMap
<String
, Definition
> result
= fixture
.getDefinitions();
149 assertNotNull(result
);
153 * Run the String getPath() method test.
156 public void testGetPath() {
157 String result
= fixture
.getPath();
158 assertNotNull(result
);
162 * Run the EnumDefinition getTagDefinition() method test.
165 public void testGetTagDefinition() {
166 EnumDefinition result
= fixture
.getTagDefinition();
167 assertNotNull(result
);
171 * Run the ArrayDefinition lookupArray(String) method test.
174 public void testLookupArray() {
175 String name
= ""; //$NON-NLS-1$
176 ArrayDefinition result
= fixture
.lookupArray(name
);
181 * Run the Definition lookupDefinition(String) method test.
184 public void testLookupDefinition() {
185 String lookupPath
= ""; //$NON-NLS-1$
186 Definition result
= fixture
.lookupDefinition(lookupPath
);
191 * Run the EnumDefinition lookupEnum(String) method test.
194 public void testLookupEnum() {
195 String name
= ""; //$NON-NLS-1$
196 EnumDefinition result
= fixture
.lookupEnum(name
);
201 * Run the IntegerDefinition lookupInteger(String) method test.
204 public void testLookupInteger() {
205 String name
= ""; //$NON-NLS-1$
206 IntegerDefinition result
= fixture
.lookupInteger(name
);
211 * Run the SequenceDefinition lookupSequence(String) method test.
214 public void testLookupSequence_1() throws Exception
{
215 String name
= ""; //$NON-NLS-1$
216 SequenceDefinition result
= fixture
.lookupSequence(name
);
221 * Run the StringDefinition lookupString(String) method test.
224 public void testLookupString() {
225 String name
= ""; //$NON-NLS-1$
226 StringDefinition result
= fixture
.lookupString(name
);
231 * Run the StructDefinition lookupStruct(String) method test.
234 public void testLookupStruct() {
235 String name
= ""; //$NON-NLS-1$
236 StructDefinition result
= fixture
.lookupStruct(name
);
241 * Run the VariantDefinition lookupVariant(String) method test.
244 public void testLookupVariant() {
245 String name
= ""; //$NON-NLS-1$
246 VariantDefinition result
= fixture
.lookupVariant(name
);
251 * Run the void setCurrentField(String) method test.
254 public void testSetCurrentField() {
255 String currentField
= ""; //$NON-NLS-1$
256 fixture
.setCurrentField(currentField
);
260 * Run the void setDeclaration(VariantDeclaration) method test.
263 public void testSetDeclaration() {
264 VariantDeclaration declaration
= new VariantDeclaration();
265 fixture
.setDeclaration(declaration
);
269 * Run the void setDefinitions(HashMap<String,Definition>) method test.
272 public void testSetDefinitions() {
273 HashMap
<String
, Definition
> definitions
= new HashMap
<String
, Definition
>();
274 fixture
.setDefinitions(definitions
);
278 * Run the void setTagDefinition(EnumDefinition) method test.
280 * @throws CTFReaderException
283 public void testSetTagDefinition() throws CTFReaderException
{
284 VariantDeclaration vDecl
;
285 VariantDefinition vDef
;
286 StructDefinition structDef
;
287 EnumDefinition tagDefinition
;
288 String fName
= ""; //$NON-NLS-1$
290 vDecl
= new VariantDeclaration();
292 vDef
= new VariantDefinition(vDecl
, TestParams
.createTrace(), fName
);
293 structDef
= new StructDefinition(new StructDeclaration(1L), vDef
, fName
);
294 tagDefinition
= new EnumDefinition(new EnumDeclaration(
295 new IntegerDeclaration(1, true, 1, ByteOrder
.BIG_ENDIAN
,
296 Encoding
.ASCII
, fName
)), structDef
, fName
);
298 fixture
.setTagDefinition(tagDefinition
);