1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.types
;
3 import static org
.junit
.Assert
.assertEquals
;
4 import static org
.junit
.Assert
.assertNotNull
;
6 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.ArrayDeclaration
;
7 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.ArrayDefinition
;
8 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDeclaration
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.IDefinitionScope
;
10 import org
.eclipse
.linuxtools
.ctf
.core
.event
.types
.StringDeclaration
;
11 import org
.junit
.After
;
12 import org
.junit
.Before
;
13 import org
.junit
.Test
;
16 * The class <code>ArrayDeclarationTest</code> contains tests for the class
17 * <code>{@link ArrayDeclaration}</code>.
20 * @version $Revision: 1.0 $
22 public class ArrayDeclarationTest
{
24 private ArrayDeclaration fixture
;
30 * the command line arguments
32 public static void main(String
[] args
) {
33 new org
.junit
.runner
.JUnitCore().run(ArrayDeclarationTest
.class);
37 * Perform pre-test initialization.
41 fixture
= new ArrayDeclaration(1, new StringDeclaration());
45 * Perform post-test clean-up.
48 public void tearDown() {
49 // Add additional tear down code here
53 * Run the ArrayDeclaration(int,Declaration) constructor test.
56 public void testArrayDeclaration() {
58 IDeclaration elemType
= new StringDeclaration();
59 ArrayDeclaration result
= new ArrayDeclaration(length
, elemType
);
61 assertNotNull(result
);
62 String left
= "[declaration] array["; //$NON-NLS-1$
63 String right
= result
.toString().substring(0, left
.length());
64 assertEquals(left
, right
);
65 assertEquals(1, result
.getLength());
69 * Run the ArrayDefinition createDefinition(DefinitionScope,String) method
73 public void testCreateDefinition() {
74 String fieldName
= ""; //$NON-NLS-1$
75 IDefinitionScope definitionScope
= null;
76 ArrayDefinition result
;
77 result
= fixture
.createDefinition(definitionScope
, fieldName
);
79 assertNotNull(result
);
83 * Run the Declaration getElementType() method test.
86 public void testGetElementType() {
87 IDeclaration result
= fixture
.getElementType();
88 assertNotNull(result
);
92 * Run the int getLength() method test.
95 public void testGetLength() {
96 int result
= fixture
.getLength();
97 assertEquals(1, result
);
101 * Run the String toString() method test.
104 public void testToString() {
105 String result
= fixture
.toString();
106 String left
= "[declaration] array["; //$NON-NLS-1$
107 String right
= result
.substring(0, left
.length());
109 assertEquals(left
, right
);