Commit | Line | Data |
---|---|---|
866e5b51 FC |
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 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; | |
14 | ||
15 | /** | |
16 | * The class <code>ArrayDeclarationTest</code> contains tests for the class | |
17 | * <code>{@link ArrayDeclaration}</code>. | |
18 | * | |
19 | * @author ematkho | |
20 | * @version $Revision: 1.0 $ | |
21 | */ | |
22 | public class ArrayDeclarationTest { | |
23 | ||
24 | private ArrayDeclaration fixture; | |
25 | ||
26 | /** | |
27 | * Launch the test. | |
28 | * | |
29 | * @param args | |
30 | * the command line arguments | |
31 | */ | |
32 | public static void main(String[] args) { | |
33 | new org.junit.runner.JUnitCore().run(ArrayDeclarationTest.class); | |
34 | } | |
35 | ||
36 | /** | |
37 | * Perform pre-test initialization. | |
38 | */ | |
39 | @Before | |
40 | public void setUp() { | |
41 | fixture = new ArrayDeclaration(1, new StringDeclaration()); | |
42 | } | |
43 | ||
44 | /** | |
45 | * Perform post-test clean-up. | |
46 | */ | |
47 | @After | |
48 | public void tearDown() { | |
49 | // Add additional tear down code here | |
50 | } | |
51 | ||
52 | /** | |
53 | * Run the ArrayDeclaration(int,Declaration) constructor test. | |
54 | */ | |
55 | @Test | |
56 | public void testArrayDeclaration() { | |
57 | int length = 1; | |
58 | IDeclaration elemType = new StringDeclaration(); | |
59 | ArrayDeclaration result = new ArrayDeclaration(length, elemType); | |
60 | ||
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()); | |
66 | } | |
67 | ||
68 | /** | |
69 | * Run the ArrayDefinition createDefinition(DefinitionScope,String) method | |
70 | * test. | |
71 | */ | |
72 | @Test | |
73 | public void testCreateDefinition() { | |
74 | String fieldName = ""; //$NON-NLS-1$ | |
75 | IDefinitionScope definitionScope = null; | |
76 | ArrayDefinition result; | |
77 | result = fixture.createDefinition(definitionScope, fieldName); | |
78 | ||
79 | assertNotNull(result); | |
80 | } | |
81 | ||
82 | /** | |
83 | * Run the Declaration getElementType() method test. | |
84 | */ | |
85 | @Test | |
86 | public void testGetElementType() { | |
87 | IDeclaration result = fixture.getElementType(); | |
88 | assertNotNull(result); | |
89 | } | |
90 | ||
91 | /** | |
92 | * Run the int getLength() method test. | |
93 | */ | |
94 | @Test | |
95 | public void testGetLength() { | |
96 | int result = fixture.getLength(); | |
97 | assertEquals(1, result); | |
98 | } | |
99 | ||
100 | /** | |
101 | * Run the String toString() method test. | |
102 | */ | |
103 | @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()); | |
108 | ||
109 | assertEquals(left, right); | |
110 | } | |
111 | } |