1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
3 import static org
.junit
.Assert
.assertEquals
;
4 import static org
.junit
.Assert
.assertNotNull
;
5 import static org
.junit
.Assert
.assertTrue
;
7 import java
.util
.HashMap
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDeclaration
;
11 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDeclaration
;
12 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDeclaration
;
13 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StructDefinition
;
14 import org
.junit
.After
;
15 import org
.junit
.Before
;
16 import org
.junit
.Test
;
19 * The class <code>StructDeclarationTest</code> contains tests for the class
20 * <code>{@link StructDeclaration}</code>.
23 * @version $Revision: 1.0 $
25 public class StructDeclarationTest
{
27 private StructDeclaration fixture
;
33 * the command line arguments
35 public static void main(String
[] args
) {
36 new org
.junit
.runner
.JUnitCore().run(StructDeclarationTest
.class);
40 * Perform pre-test initialization.
44 fixture
= new StructDeclaration(1L);
48 * Perform post-test clean-up.
51 public void tearDown() {
52 // Add additional tear down code here
56 * Run the StructDeclaration(long) constructor test.
59 public void testStructDeclaration() {
60 assertNotNull(fixture
);
61 assertEquals(1L, fixture
.getMinAlign());
63 String regex
= "^\\[declaration\\] struct\\[[0-9a-f]{1,8}\\]$"; //$NON-NLS-1$
64 assertTrue(fixture
.toString().matches(regex
));
68 * Run the void addField(String,Declaration) method test.
71 public void testAddField() {
72 String name
= ""; //$NON-NLS-1$
73 IDeclaration declaration
= new StringDeclaration();
74 fixture
.addField(name
, declaration
);
78 * Run the StructDefinition createDefinition(DefinitionScope,String) method
82 public void testCreateDefinition() {
83 String fieldName
= ""; //$NON-NLS-1$
84 StructDefinition result
= fixture
.createDefinition(null, fieldName
);
85 assertNotNull(result
);
89 * Run the HashMap<String, Declaration> getFields() method test.
92 public void testGetFields() {
93 HashMap
<String
, IDeclaration
> result
= fixture
.getFields();
95 assertNotNull(result
);
96 assertEquals(0, result
.size());
100 * Run the List<String> getFieldsList() method test.
103 public void testGetFieldsList() {
104 List
<String
> result
= fixture
.getFieldsList();
106 assertNotNull(result
);
107 assertEquals(0, result
.size());
111 * Run the long getMinAlign() method test.
114 public void testGetMinAlign() {
115 long result
= fixture
.getMinAlign();
116 assertEquals(1L, result
);
120 * Run the boolean hasField(String) method test.
123 public void testHasField() {
124 String name
= ""; //$NON-NLS-1$
125 boolean result
= fixture
.hasField(name
);
127 assertEquals(false, result
);
131 * Run the void setMinAlign(long) method test.
134 public void testSetMinAlign() {
136 fixture
.setMinAlign(minAlign
);
140 * Run the String toString() method test.
143 public void testToString() {
144 String result
= fixture
.toString();
145 String trunc
= result
.substring(0, 21);
147 assertEquals("[declaration] struct[", trunc
); //$NON-NLS-1$