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