ctf: Fix Javadoc for all public methods
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core.tests / src / org / eclipse / linuxtools / ctf / core / tests / types / SequenceDeclarationTest.java
1 package org.eclipse.linuxtools.ctf.core.tests.types;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5
6 import java.nio.ByteOrder;
7
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;
19
20 /**
21 * The class <code>SequenceDeclarationTest</code> contains tests for the class
22 * <code>{@link SequenceDeclaration}</code>.
23 *
24 * @author ematkho
25 * @version $Revision: 1.0 $
26 */
27 @SuppressWarnings("javadoc")
28 public class SequenceDeclarationTest {
29
30 private SequenceDeclaration fixture;
31
32 static final String fieldName = "LengthName"; //$NON-NLS-1$
33 /**
34 * Launch the test.
35 *
36 * @param args
37 * the command line arguments
38 */
39 public static void main(String[] args) {
40 new org.junit.runner.JUnitCore().run(SequenceDeclarationTest.class);
41 }
42
43 @Before
44 public void setUp() {
45 fixture = new SequenceDeclaration(fieldName, new StringDeclaration());
46 }
47
48 @After
49 public void tearDown() {
50 // Add additional tear down code here
51 }
52
53 /**
54 * Run the SequenceDeclaration(String,Declaration) constructor test.
55 */
56 @Test
57 public void testSequenceDeclaration() {
58 String lengthName = ""; //$NON-NLS-1$
59 IDeclaration elemType = new StringDeclaration();
60
61 SequenceDeclaration result = new SequenceDeclaration(lengthName,
62 elemType);
63 assertNotNull(result);
64 String string = "[declaration] sequence["; //$NON-NLS-1$
65 assertEquals(string, result.toString().substring(0, string.length()));
66 }
67
68 /**
69 * Run the SequenceDefinition createDefinition(DefinitionScope,String)
70 * method test.
71 */
72 @Test
73 public void testCreateDefinition() {
74 IntegerDeclaration id = new IntegerDeclaration(8, false, 8,
75 ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null, 32);
76
77 StructDeclaration structDec = new StructDeclaration(0);
78 structDec.addField(fieldName, id);
79 StructDefinition structDef = new StructDefinition(structDec, null, "x"); //$NON-NLS-1$
80 long seqLen = 10;
81 structDef.lookupInteger(fieldName).setValue(seqLen);
82 SequenceDefinition result = this.fixture.createDefinition(structDef,
83 fieldName);
84 assertNotNull(result);
85 }
86
87 /**
88 * Run the Declaration getElementType() method test.
89 */
90 @Test
91 public void testGetElementType() {
92 IDeclaration result = fixture.getElementType();
93 assertNotNull(result);
94 }
95
96 /**
97 * Run the String toString() method test.
98 */
99 @Test
100 public void testToString() {
101 String result = fixture.toString();
102 String left = "[declaration] sequence["; //$NON-NLS-1$
103 assertEquals(left, result.substring(0, left.length()));
104 }
105 }
This page took 0.035506 seconds and 6 git commands to generate.