blob: ef1b1937de50c43ecd0b0fe5e0d2c7fde9b450d4 (
plain)
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
|
import gnu.test.*;
/**
* Test the Byte object wrapper class.
*
* @author Brian Jones (cbj@gnu.org)
*/
public class ByteTest
{
public static class constructorTest1 implements Test
{
byte b = 1;
public String getName() {
return "Byte(byte)";
}
public Result test() {
try {
Byte byteObject = new Byte(b);
} catch (Exception e) {
return new Fail(e.getMessage());
} catch (Error err) {
return new Fail(err.getMessage());
}
return new Pass();
}
}
public static class constructorTest2 implements Test
{
Byte byteObject = null;
public String getName() {
return "Byte(String)";
}
public Result test() {
try {
byteObject = new Byte("1");
} catch (Exception e) {
return new Fail(e.getMessage());
} catch (Error err) {
return new Fail(err.getMessage());
}
return new Pass();
}
}
public static class byteValueTest implements Test
{
public String getName() {
return "Byte.byteValue()";
}
public Result test() {
byte b = 1;
Byte byteObject = new Byte(b);
if (byteObject.byteValue() == b)
return new Pass();
else
return new Fail();
}
}
public static class decodeTest implements Test
{
public String getName() {
return "Byte.decode(String)";
}
public Result test() {
Byte obj = Byte.decode("1");
if (obj.byteValue() == 1)
return new Pass();
else
return new Fail();
}
}
public static class doubleValueTest implements Test
{
public String getName() {
return "Byte.doubleValue()";
}
public Result test() {
byte b = 4;
double d = b;
Byte obj = new Byte(b);
if (obj.doubleValue() == d)
return new Pass();
else
return new Fail();
}
}
public static class equalsTest1 implements Test
{
public String getName() {
return "Byte.equals(Object)";
}
public Result test() {
Byte obj1 = null, obj2 = null;
obj1 = new Byte((byte)1);
obj2 = new Byte((byte)2);
if (obj1.equals(obj2))
return new Fail("1 != 2");
else
return new Pass("1 != 2");
}
}
public static class equalsTest2 implements Test
{
public String getName() {
return "Byte.equals(Object)";
}
public Result test() {
Byte obj1 = null, obj2 = null;
obj1 = new Byte((byte)1);
obj2 = new Byte((byte)2);
obj2 = obj1;
if (obj1.equals(obj2))
return new Pass("1 == 1");
else
return new Fail("1 == 1");
}
}
public static class floatValueTest implements Test
{
public String getName() {
return "Byte.floatValue()";
}
public Result test() {
byte b = 4;
float f = b;
Byte obj = new Byte(b);
if (obj.floatValue() == f)
return new Pass();
else
return new Fail();
}
}
public static class hashCodeTest implements Test
{
public String getName() {
return "Byte.hashCode()";
}
public Result test() {
boolean caught = false;
Byte obj = new Byte((byte)1);
int i = obj.hashCode();
if (i == 1)
return new Pass();
else
return new Fail("hash is " + i + ". It should be 1.");
}
}
public static class intValueTest implements Test
{
public String getName() {
return "Byte.intValue()";
}
public Result test() {
byte b = 4;
int i = b;
Byte obj = new Byte(b);
if (obj.intValue() == i)
return new Pass();
else
return new Fail();
}
}
public static class longValueTest implements Test
{
public String getName() {
return "Byte.longValue()";
}
public Result test() {
byte b = 4;
long l = b;
Byte obj = new Byte(b);
if (obj.longValue() == l)
return new Pass();
else
return new Fail();
}
}
public static class parseByteTest1 implements Test
{
public String getName() {
return "Byte.parseByte(String)";
}
public Result test() {
byte b = Byte.parseByte("1");
if (b == (byte)1)
return new Pass();
else
return new Fail();
}
}
public static class parseByteTest2 implements Test
{
public String getName() {
return "Byte.parseByte(String, int)";
}
public Result test() {
byte b = Byte.parseByte("-4", 10);
if (b == (byte)-4)
return new Pass();
else
return new Fail();
}
}
public static class shortValueTest implements Test
{
public String getName() {
return "Byte.shortValue()";
}
public Result test() {
byte b = 4;
short s = b;
Byte obj = new Byte(b);
if (obj.shortValue() == s)
return new Pass();
else
return new Fail();
}
}
public static class toStringTest1 implements Test
{
public String getName() {
return "Byte.toString()";
}
public Result test() {
Byte obj = new Byte((byte)-2);
String x = obj.toString();
if (x.equals("-2"))
return new Pass();
else
return new Fail();
}
}
public static class toStringTest2 implements Test
{
public String getName() {
return "Byte.toString(byte)";
}
public Result test() {
String x = Byte.toString((byte)-2);
if (x.equals("-2"))
return new Pass();
else
return new Fail();
}
}
public static class valueOfTest1 implements Test
{
public String getName() {
return "Byte.valueOf(String, int)";
}
public Result test() {
Byte obj1 = Byte.valueOf("2",10);
Byte obj2 = new Byte((byte)2);
if (obj1.intValue() == obj2.intValue())
return new Pass();
else
return new Fail();
}
}
public static class valueOfTest2 implements Test
{
public String getName() {
return "Byte.valueOf(String)";
}
public Result test() {
Byte obj1 = Byte.valueOf("2");
if (obj1.intValue() == 2)
return new Pass();
else
return new Fail();
}
}
public static class variablesTest1 implements Test
{
public String getName() {
return "Byte.MIN_VALUE";
}
public Result test() {
byte min = Byte.MIN_VALUE;
byte max = Byte.MAX_VALUE;
if (min == (byte)-128)
return new Pass("Byte.MIN_VALUE is -128");
else
return new Fail("Byte.MIN_VALUE is " + min + " != -128");
}
}
public static class variablesTest2 implements Test
{
public String getName() {
return "Byte.MAX_VALUE";
}
public Result test() {
byte min = Byte.MIN_VALUE;
byte max = Byte.MAX_VALUE;
if (max == (byte)127)
return new Pass("Byte.MAX_VALUE is 127");
else
return new Fail("Byte.MAX_VALUE is " + max + " != 127");
}
}
public static class variablesTest3 implements Test
{
public String getName() {
return "Byte.TYPE.getName()";
}
public Result test() {
String x = Byte.TYPE.getName();
if (x.equals("byte") != true)
return new Fail("Byte.TYPE.getName() is " + x + " != byte");
else
return new Pass("Byte.TYPE.getName() is byte");
}
}
public static class typeInstance implements Test
{
public String getName() {
return "Byte.TYPE.newInstance()";
}
public Result test() {
try {
Object b = Byte.TYPE.newInstance();
return new Fail("Byte.TYPE.newInstance succeeded.");
}
catch (InstantiationException e) {
return new Pass("Byte.TYPE.newInstance failed with exception '" +
e.toString() + "'");
}
catch (Exception ex) {
return new Fail("Byte.TYPE.newInstance threw incorrect exception '"
+ ex.toString() + "'");
}
}
}
}
|