Commit | Line | Data |
---|---|---|
866e5b51 FC |
1 | package org.eclipse.linuxtools.ctf.core.tests.types; |
2 | ||
3 | import static org.junit.Assert.assertNotNull; | |
4 | import static org.junit.Assert.assertNull; | |
5 | ||
6 | import java.nio.ByteOrder; | |
7 | import java.util.HashMap; | |
8 | ||
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; | |
13be1a8f | 24 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; |
866e5b51 FC |
25 | import org.junit.After; |
26 | import org.junit.Before; | |
27 | import org.junit.Test; | |
28 | ||
29 | /** | |
30 | * The class <code>VariantDefinitionTest</code> contains tests for the class | |
31 | * <code>{@link VariantDefinition}</code>. | |
284fdee8 | 32 | * |
866e5b51 FC |
33 | * @author ematkho |
34 | * @version $Revision: 1.0 $ | |
35 | */ | |
36 | public class VariantDefinitionTest { | |
37 | ||
38 | private VariantDefinition fixture; | |
39 | ||
40 | /** | |
41 | * Launch the test. | |
284fdee8 | 42 | * |
866e5b51 FC |
43 | * @param args |
44 | * the command line arguments | |
45 | */ | |
46 | public static void main(String[] args) { | |
47 | new org.junit.runner.JUnitCore().run(VariantDefinitionTest.class); | |
48 | } | |
49 | ||
50 | /** | |
51 | * Perform pre-test initialization. | |
284fdee8 | 52 | * |
866e5b51 | 53 | * Not sure it needs to be that complicated, oh well... |
13be1a8f AM |
54 | * |
55 | * @throws CTFReaderException | |
866e5b51 FC |
56 | */ |
57 | @Before | |
13be1a8f | 58 | public void setUp() throws CTFReaderException { |
866e5b51 FC |
59 | VariantDeclaration vDecl1, vDecl2, vDecl3; |
60 | VariantDefinition vDef1, vDef2; | |
61 | StructDefinition sDef1, sDef2; | |
62 | EnumDefinition eDef; | |
63 | String fName = ""; //$NON-NLS-1$ | |
64 | ||
65 | vDecl1 = new VariantDeclaration(); | |
66 | vDecl2 = new VariantDeclaration(); | |
67 | vDecl3 = new VariantDeclaration(); | |
68 | vDecl1.setTag(fName); | |
69 | vDecl2.setTag(fName); | |
70 | vDecl3.setTag(fName); | |
71 | ||
72 | vDef1 = new VariantDefinition(vDecl2, TestParams.createTrace(), fName); | |
73 | vDef2 = new VariantDefinition(vDecl3, TestParams.createTrace(), fName); | |
74 | ||
75 | sDef1 = new StructDefinition(new StructDeclaration(1L), vDef1, fName); | |
76 | sDef2 = new StructDefinition(new StructDeclaration(1L), vDef2, fName); | |
77 | ||
78 | eDef = new EnumDefinition(new EnumDeclaration(new IntegerDeclaration(1, | |
284fdee8 | 79 | true, 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, fName)), sDef2, fName); |
866e5b51 FC |
80 | |
81 | fixture = new VariantDefinition(vDecl1, sDef1, fName); | |
82 | fixture.setTagDefinition(eDef); | |
83 | fixture.setCurrentField(fName); | |
84 | } | |
85 | ||
86 | /** | |
87 | * Perform post-test clean-up. | |
88 | */ | |
89 | @After | |
90 | public void tearDown() { | |
91 | // Add additional tear down code here | |
92 | } | |
93 | ||
94 | /** | |
95 | * Run the VariantDefinition(VariantDeclaration,DefinitionScope,String) | |
13be1a8f AM |
96 | * |
97 | * @throws CTFReaderException | |
866e5b51 FC |
98 | */ |
99 | @Test | |
13be1a8f | 100 | public void testVariantDefinition() throws CTFReaderException { |
866e5b51 FC |
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$ | |
110 | ||
111 | VariantDefinition result = new VariantDefinition(declaration, | |
112 | definitionScope, fieldName); | |
113 | assertNotNull(result); | |
114 | } | |
115 | ||
116 | /** | |
117 | * Run the Definition getCurrentField() method test. | |
118 | */ | |
119 | @Test | |
120 | public void testGetCurrentField() { | |
121 | Definition result = fixture.getCurrentField(); | |
122 | assertNull(result); | |
123 | } | |
124 | ||
125 | /** | |
126 | * Run the String getCurrentFieldName() method test. | |
127 | */ | |
128 | @Test | |
129 | public void testGetCurrentFieldName() { | |
130 | String result = fixture.getCurrentFieldName(); | |
131 | assertNotNull(result); | |
132 | } | |
133 | ||
134 | /** | |
135 | * Run the VariantDeclaration getDeclaration() method test. | |
136 | */ | |
137 | @Test | |
138 | public void testGetDeclaration() { | |
139 | VariantDeclaration result = fixture.getDeclaration(); | |
140 | assertNotNull(result); | |
141 | } | |
142 | ||
143 | /** | |
144 | * Run the HashMap<String, Definition> getDefinitions() method test. | |
145 | */ | |
146 | @Test | |
147 | public void testGetDefinitions() { | |
148 | HashMap<String, Definition> result = fixture.getDefinitions(); | |
149 | assertNotNull(result); | |
150 | } | |
151 | ||
152 | /** | |
153 | * Run the String getPath() method test. | |
154 | */ | |
155 | @Test | |
156 | public void testGetPath() { | |
157 | String result = fixture.getPath(); | |
158 | assertNotNull(result); | |
159 | } | |
160 | ||
161 | /** | |
162 | * Run the EnumDefinition getTagDefinition() method test. | |
163 | */ | |
164 | @Test | |
165 | public void testGetTagDefinition() { | |
166 | EnumDefinition result = fixture.getTagDefinition(); | |
167 | assertNotNull(result); | |
168 | } | |
169 | ||
170 | /** | |
171 | * Run the ArrayDefinition lookupArray(String) method test. | |
172 | */ | |
173 | @Test | |
174 | public void testLookupArray() { | |
175 | String name = ""; //$NON-NLS-1$ | |
176 | ArrayDefinition result = fixture.lookupArray(name); | |
177 | assertNull(result); | |
178 | } | |
179 | ||
180 | /** | |
181 | * Run the Definition lookupDefinition(String) method test. | |
182 | */ | |
183 | @Test | |
184 | public void testLookupDefinition() { | |
185 | String lookupPath = ""; //$NON-NLS-1$ | |
186 | Definition result = fixture.lookupDefinition(lookupPath); | |
187 | assertNull(result); | |
188 | } | |
189 | ||
190 | /** | |
191 | * Run the EnumDefinition lookupEnum(String) method test. | |
192 | */ | |
193 | @Test | |
194 | public void testLookupEnum() { | |
195 | String name = ""; //$NON-NLS-1$ | |
196 | EnumDefinition result = fixture.lookupEnum(name); | |
197 | assertNull(result); | |
198 | } | |
199 | ||
200 | /** | |
201 | * Run the IntegerDefinition lookupInteger(String) method test. | |
202 | */ | |
203 | @Test | |
204 | public void testLookupInteger() { | |
205 | String name = ""; //$NON-NLS-1$ | |
206 | IntegerDefinition result = fixture.lookupInteger(name); | |
207 | assertNull(result); | |
208 | } | |
209 | ||
210 | /** | |
211 | * Run the SequenceDefinition lookupSequence(String) method test. | |
212 | */ | |
213 | @Test | |
214 | public void testLookupSequence_1() throws Exception { | |
215 | String name = ""; //$NON-NLS-1$ | |
216 | SequenceDefinition result = fixture.lookupSequence(name); | |
217 | assertNull(result); | |
218 | } | |
219 | ||
220 | /** | |
221 | * Run the StringDefinition lookupString(String) method test. | |
222 | */ | |
223 | @Test | |
224 | public void testLookupString() { | |
225 | String name = ""; //$NON-NLS-1$ | |
226 | StringDefinition result = fixture.lookupString(name); | |
227 | assertNull(result); | |
228 | } | |
229 | ||
230 | /** | |
231 | * Run the StructDefinition lookupStruct(String) method test. | |
232 | */ | |
233 | @Test | |
234 | public void testLookupStruct() { | |
235 | String name = ""; //$NON-NLS-1$ | |
236 | StructDefinition result = fixture.lookupStruct(name); | |
237 | assertNull(result); | |
238 | } | |
239 | ||
240 | /** | |
241 | * Run the VariantDefinition lookupVariant(String) method test. | |
242 | */ | |
243 | @Test | |
244 | public void testLookupVariant() { | |
245 | String name = ""; //$NON-NLS-1$ | |
246 | VariantDefinition result = fixture.lookupVariant(name); | |
247 | assertNull(result); | |
248 | } | |
249 | ||
250 | /** | |
251 | * Run the void setCurrentField(String) method test. | |
252 | */ | |
253 | @Test | |
254 | public void testSetCurrentField() { | |
255 | String currentField = ""; //$NON-NLS-1$ | |
256 | fixture.setCurrentField(currentField); | |
257 | } | |
258 | ||
259 | /** | |
260 | * Run the void setDeclaration(VariantDeclaration) method test. | |
261 | */ | |
262 | @Test | |
263 | public void testSetDeclaration() { | |
264 | VariantDeclaration declaration = new VariantDeclaration(); | |
265 | fixture.setDeclaration(declaration); | |
266 | } | |
267 | ||
268 | /** | |
269 | * Run the void setDefinitions(HashMap<String,Definition>) method test. | |
270 | */ | |
271 | @Test | |
272 | public void testSetDefinitions() { | |
273 | HashMap<String, Definition> definitions = new HashMap<String, Definition>(); | |
274 | fixture.setDefinitions(definitions); | |
275 | } | |
276 | ||
277 | /** | |
278 | * Run the void setTagDefinition(EnumDefinition) method test. | |
13be1a8f AM |
279 | * |
280 | * @throws CTFReaderException | |
866e5b51 FC |
281 | */ |
282 | @Test | |
13be1a8f | 283 | public void testSetTagDefinition() throws CTFReaderException { |
866e5b51 FC |
284 | VariantDeclaration vDecl; |
285 | VariantDefinition vDef; | |
286 | StructDefinition structDef; | |
287 | EnumDefinition tagDefinition; | |
288 | String fName = ""; //$NON-NLS-1$ | |
289 | ||
290 | vDecl = new VariantDeclaration(); | |
291 | vDecl.setTag(fName); | |
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, | |
284fdee8 | 296 | Encoding.ASCII, fName)), structDef, fName); |
866e5b51 FC |
297 | |
298 | fixture.setTagDefinition(tagDefinition); | |
299 | } | |
300 | } |