1 package org
.eclipse
.linuxtools
.tmf
.core
.tests
.ctfadaptor
;
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
.ArrayDeclaration
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Definition
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.Encoding
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.FloatDeclaration
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.FloatDefinition
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IntegerDeclaration
;
14 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.SequenceDeclaration
;
15 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDeclaration
;
16 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
17 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDefinition
;
18 import org
.eclipse
.linuxtools
.internal
.ctf
.core
.event
.io
.BitBuffer
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEventField
;
20 import org
.junit
.After
;
21 import org
.junit
.Before
;
22 import org
.junit
.Test
;
25 * The class <code>CtfTmfEventFieldTest</code> contains tests for the class
26 * <code>{@link CtfTmfEventField}</code>.
28 * @generatedBy CodePro at 03/05/12 2:29 PM
30 * @version $Revision: 1.0 $
32 public class CtfTmfEventFieldTest
{
34 private static final String ROOT
= "root"; //$NON-NLS-1$
35 private static final String SEQ
= "seq"; //$NON-NLS-1$
36 private static final String ARRAY
= "array"; //$NON-NLS-1$
37 private static final String STR
= "str"; //$NON-NLS-1$
38 private static final String FLOAT
= "float"; //$NON-NLS-1$
39 private static final String LEN
= "len"; //$NON-NLS-1$
40 private static final String INT
= "int"; //$NON-NLS-1$
41 private static final String NAME
= "test"; //$NON-NLS-1$
44 * Run the CtfTmfEventField parseField(Definition,String) method test.
46 * @generatedBy CodePro at 03/05/12 2:29 PM
49 public void testParseField_1() {
50 FloatDefinition fieldDef
= (FloatDefinition
) fixture
51 .lookupDefinition(FLOAT
);
52 CtfTmfEventField result
= CtfTmfEventField
.parseField(fieldDef
, "_"+NAME
); //$NON-NLS-1$
53 String result2
=CtfTmfEventField
.copyFrom(result
).toString();
54 assertEquals( result2
, "test=9.551467814359616E-38"); //$NON-NLS-1$
58 * Run the CtfTmfEventField parseField(Definition,String) method test.
60 * @generatedBy CodePro at 03/05/12 2:29 PM
63 public void testParseField_2() {
64 CtfTmfEventField result
= CtfTmfEventField
.parseField(
65 fixture
.lookupArray(ARRAY
), NAME
);
66 String result2
=CtfTmfEventField
.copyFrom(result
).toString();
67 assertEquals( result2
, "test={ 2, 2}"); //$NON-NLS-1$
71 * Run the CtfTmfEventField parseField(Definition,String) method test.
73 * @generatedBy CodePro at 03/05/12 2:29 PM
76 public void testParseField_3() {
77 Definition fieldDef
= fixture
.lookupDefinition(INT
);
78 CtfTmfEventField result
= CtfTmfEventField
.parseField(fieldDef
, NAME
);
79 String result2
=CtfTmfEventField
.copyFrom(result
).toString();
80 assertEquals( result2
, "test=2"); //$NON-NLS-1$
84 * Run the CtfTmfEventField parseField(Definition,String) method test.
86 * @generatedBy CodePro at 03/05/12 2:29 PM
89 public void testParseField_4() {
90 Definition fieldDef
= fixture
.lookupDefinition(SEQ
);
91 CtfTmfEventField result
= CtfTmfEventField
.parseField(fieldDef
, NAME
);
92 String result2
=CtfTmfEventField
.copyFrom(result
).toString();
93 assertEquals( result2
, "test={ 2, 2}"); //$NON-NLS-1$
97 * Run the CtfTmfEventField parseField(Definition,String) method test.
101 * @generatedBy CodePro at 03/05/12 2:29 PM
104 public void testParseField_5() {
105 Definition fieldDef
= fixture
.lookupDefinition(STR
);
106 CtfTmfEventField result
= CtfTmfEventField
.parseField(fieldDef
, NAME
);
107 String result2
=CtfTmfEventField
.copyFrom(result
).toString();
108 assertEquals( result2
, "test=\ 2\ 2\ 2\ 2\ 2\ 2\ 2\ 2\ 2\ 2\ 2\ 2\ 2\ 2"); //$NON-NLS-1$
112 public void testClone() {
113 Definition fieldDef
= fixture
.lookupDefinition(STR
);
114 CtfTmfEventField result
= CtfTmfEventField
.parseField(fieldDef
, NAME
);
115 assertNotNull(result
.clone());
119 StructDefinition fixture
;
122 * Perform pre-test initialization.
125 * if the initialization fails for some reason
127 * @generatedBy CodePro at 03/05/12 2:29 PM
130 public void setUp() throws Exception
{
131 StructDeclaration sDec
= new StructDeclaration(1l);
132 StringDeclaration strDec
= new StringDeclaration();
133 IntegerDeclaration intDec
= new IntegerDeclaration(8, false, 8,
134 ByteOrder
.BIG_ENDIAN
, Encoding
.NONE
, null, 8);
135 FloatDeclaration flDec
= new FloatDeclaration(8, 24,
136 ByteOrder
.BIG_ENDIAN
, 8);
137 ArrayDeclaration arrDec
= new ArrayDeclaration(2, intDec
);
138 SequenceDeclaration seqDec
= new SequenceDeclaration(LEN
, intDec
);
139 sDec
.addField(INT
, intDec
);
140 sDec
.addField(LEN
, intDec
);
141 sDec
.addField(FLOAT
, flDec
);
142 sDec
.addField(STR
, strDec
);
143 sDec
.addField(ARRAY
, arrDec
);
144 sDec
.addField(SEQ
, seqDec
);
145 fixture
= sDec
.createDefinition(fixture
, ROOT
);
147 java
.nio
.ByteBuffer bb
= java
.nio
.ByteBuffer
.allocateDirect(capacity
);
148 for (int i
= 0; i
< capacity
; i
++) {
154 fixture
.read(new BitBuffer(bb
));
158 * Perform post-test clean-up.
161 * if the clean-up fails for some reason
163 * @generatedBy CodePro at 03/05/12 2:29 PM
166 public void tearDown() throws Exception
{
167 // Add additional tear down code here
174 * the command line arguments
176 * @generatedBy CodePro at 03/05/12 2:29 PM
178 public static void main(String
[] args
) {
179 new org
.junit
.runner
.JUnitCore().run(CtfTmfEventFieldTest
.class);