Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 74a996d2114dfd13332319be397626423acac110 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*******************************************************************************
 * Copyright (c) 2000, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.jdi.tests;

import com.sun.jdi.Type;

/**
 * Tests for JDI com.sun.jdi.Type.
 */
public class TypeTest extends AbstractJDITest {
	private Type 		
		fArrayType,
		fClassType,
		fInterfaceType,
		// primitive types
		fShortType,
		fByteType,
		fIntegerType,
		fLongType,
		fFloatType,
		fDoubleType,
		fCharType,
		fBooleanType,
		// One-dimensional primitive arrays
		fByteArrayType,
		fShortArrayType,
		fIntArrayType,
		fLongArrayType,
		fFloatArrayType,
		fDoubleArrayType,
		fCharArrayType,
		fBooleanArrayType,
		// Two-dimensional primitive arrays
		fByteDoubleArrayType,
		fShortDoubleArrayType,
		fIntDoubleArrayType,
		fLongDoubleArrayType,
		fFloatDoubleArrayType,
		fDoubleDoubleArrayType,
		fCharDoubleArrayType,
		fBooleanDoubleArrayType;
		
	/**
	 * Creates a new test.
	 */
	public TypeTest() {
		super();
	}
	/**
	 * Init the fields that are used by this test only.
	 */
	@Override
	public void localSetUp() {
		// Get reference types
		fArrayType = getArrayType();
		fClassType = getMainClass();
		fInterfaceType = getInterfaceType();
		// Get primitive types
		fBooleanType = (fVM.mirrorOf(true).type());
		fByteType = (fVM.mirrorOf((byte) 1).type());
		fCharType = (fVM.mirrorOf('a').type());
		fDoubleType = (fVM.mirrorOf(12345.6789).type());
		fFloatType = (fVM.mirrorOf(12345.6789f).type());
		fIntegerType = (fVM.mirrorOf(12345).type());
		fLongType = (fVM.mirrorOf(123456789l).type());
		fShortType = (fVM.mirrorOf((short) 12345).type());
		// Get one-dimensional primitive arrays
		fByteArrayType = getByteArrayType();
		fShortArrayType = getShortArrayType();
		fIntArrayType = getIntArrayType();
		fLongArrayType = getLongArrayType();
		fFloatArrayType = getFloatArrayType();
		fDoubleArrayType = getDoubleArrayType();
		fCharArrayType = getCharArrayType();
		fBooleanArrayType = getBooleanArrayType();
		//  Get two-dimensional primitive arrays
		fByteDoubleArrayType = getByteDoubleArrayType();
		fShortDoubleArrayType = getShortDoubleArrayType();
		fIntDoubleArrayType = getIntDoubleArrayType();
		fLongDoubleArrayType = getLongDoubleArrayType();
		fFloatDoubleArrayType = getFloatDoubleArrayType();
		fDoubleDoubleArrayType = getDoubleDoubleArrayType();
		fCharDoubleArrayType = getCharDoubleArrayType();
		fBooleanDoubleArrayType = getBooleanDoubleArrayType();

	}
	/**
	 * Run all tests and output to standard output.
	 * @param args
	 */
	public static void main(java.lang.String[] args) {
		new TypeTest().runSuite(args);
	}
	/**
	 * Gets the name of the test case.
	 * @see junit.framework.TestCase#getName()
	 */
	@Override
	public String getName() {
		return "com.sun.jdi.Type";
	}
	/**
	 * Test JDI signature().
	 */
	public void testJDISignature() {
		assertEquals("1", "[Ljava/lang/String;", fArrayType.signature());
		assertEquals("2", "Lorg/eclipse/debug/jdi/tests/program/MainClass;", fClassType.signature());
		assertEquals("3", "Lorg/eclipse/debug/jdi/tests/program/Printable;", fInterfaceType.signature());
		// Primitive types
		assertEquals("4", "S", fShortType.signature());
		assertEquals("5", "B", fByteType.signature());
		assertEquals("6", "I", fIntegerType.signature());
		assertEquals("7", "J", fLongType.signature());
		assertEquals("8", "F", fFloatType.signature());
		assertEquals("9", "D", fDoubleType.signature());
		assertEquals("10", "C", fCharType.signature());
		assertEquals("11", "Z", fBooleanType.signature());
		// One-dimensional primitive arrays
		assertEquals("12", "[B", fByteArrayType.signature());
		assertEquals("13", "[S", fShortArrayType.signature());
		assertEquals("14", "[I", fIntArrayType.signature());
		assertEquals("15", "[J", fLongArrayType.signature());
		assertEquals("16", "[F", fFloatArrayType.signature());
		assertEquals("17", "[D", fDoubleArrayType.signature());
		assertEquals("18", "[C", fCharArrayType.signature());
		assertEquals("19", "[Z", fBooleanArrayType.signature());
		// Two-dimensional primitive arrays
		assertEquals("20", "[[B", fByteDoubleArrayType.signature());
		assertEquals("21", "[[S", fShortDoubleArrayType.signature());
		assertEquals("22", "[[I", fIntDoubleArrayType.signature());
		assertEquals("23", "[[J", fLongDoubleArrayType.signature());
		assertEquals("24", "[[F", fFloatDoubleArrayType.signature());
		assertEquals("25", "[[D", fDoubleDoubleArrayType.signature());
		assertEquals("26", "[[C", fCharDoubleArrayType.signature());
		assertEquals("27", "[[Z", fBooleanDoubleArrayType.signature());
	}
	/**
	 * Test JDI typeName().
	 */
	public void testJDITypeName() {
		assertEquals("1", "java.lang.String[]", fArrayType.name());
		assertEquals("2", "org.eclipse.debug.jdi.tests.program.MainClass", fClassType.name());
		assertEquals("3", "org.eclipse.debug.jdi.tests.program.Printable", fInterfaceType.name());
		// Primitive types
		assertEquals("4", "byte", fByteType.name());
		assertEquals("5", "short", fShortType.name());
		assertEquals("6", "int", fIntegerType.name());
		assertEquals("7", "long", fLongType.name());
		assertEquals("8", "float", fFloatType.name());
		assertEquals("9", "double", fDoubleType.name());
		assertEquals("10", "char", fCharType.name());
		assertEquals("11", "boolean", fBooleanType.name());
		// One-dimensional primitive arrays
		assertEquals("12", "byte[]", fByteArrayType.name());
		assertEquals("13", "short[]", fShortArrayType.name());
		assertEquals("14", "int[]", fIntArrayType.name());
		assertEquals("15", "long[]", fLongArrayType.name());
		assertEquals("16", "float[]", fFloatArrayType.name());
		assertEquals("17", "double[]", fDoubleArrayType.name());
		assertEquals("18", "char[]", fCharArrayType.name());
		assertEquals("19", "boolean[]", fBooleanArrayType.name());
		// Two-dimensional primitive arrays
		assertEquals("20", "byte[][]", fByteDoubleArrayType.name());
		assertEquals("21", "short[][]", fShortDoubleArrayType.name());
		assertEquals("22", "int[][]", fIntDoubleArrayType.name());
		assertEquals("23", "long[][]", fLongDoubleArrayType.name());
		assertEquals("24", "float[][]", fFloatDoubleArrayType.name());
		assertEquals("25", "double[][]", fDoubleDoubleArrayType.name());
		assertEquals("26", "char[][]", fCharDoubleArrayType.name());
		assertEquals("27", "boolean[][]", fBooleanDoubleArrayType.name());
	}
}

Back to the top