Home | History | Annotate | Download | only in lang

Lines Matching refs:Byte

24      * @tests java.lang.Byte#valueOf(byte)
27 assertEquals(new Byte(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE));
28 assertEquals(new Byte(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE));
29 assertEquals(new Byte((byte) 0), Byte.valueOf((byte) 0));
31 byte b = Byte.MIN_VALUE + 1;
32 while (b < Byte.MAX_VALUE) {
33 assertEquals(new Byte(b), Byte.valueOf(b));
34 assertSame(Byte.valueOf(b), Byte.valueOf(b));
40 * @tests java.lang.Byte#hashCode()
43 assertEquals(1, new Byte((byte) 1).hashCode());
44 assertEquals(2, new Byte((byte) 2).hashCode());
45 assertEquals(0, new Byte((byte) 0).hashCode());
46 assertEquals(-1, new Byte((byte) -1).hashCode());
50 * @tests java.lang.Byte#Byte(String)
53 assertEquals(new Byte((byte) 0), new Byte("0"));
54 assertEquals(new Byte((byte) 1), new Byte("1"));
55 assertEquals(new Byte((byte) -1), new Byte("-1"));
58 new Byte("0x1");
64 new Byte("9.2");
70 new Byte("");
76 new Byte(null);
83 * @tests java.lang.Byte#Byte(byte)
86 assertEquals(1, new Byte((byte) 1).byteValue());
87 assertEquals(2, new Byte((byte) 2).byteValue());
88 assertEquals(0, new Byte((byte) 0).byteValue());
89 assertEquals(-1, new Byte((byte) -1).byteValue());
93 * @tests java.lang.Byte#byteValue()
96 assertEquals(1, new Byte((byte) 1).byteValue());
97 assertEquals(2, new Byte((byte) 2).byteValue());
98 assertEquals(0, new Byte((byte) 0).byteValue());
99 assertEquals(-1, new Byte((byte) -1).byteValue());
103 * @tests java.lang.Byte#equals(Object)
106 assertEquals(new Byte((byte) 0), Byte.valueOf((byte) 0));
107 assertEquals(new Byte((byte) 1), Byte.valueOf((byte) 1));
108 assertEquals(new Byte((byte) -1), Byte.valueOf((byte) -1));
110 Byte fixture = new Byte((byte) 25);
113 assertFalse(fixture.equals("Not a Byte"));
117 * @tests java.lang.Byte#toString()
120 assertEquals("-1", new Byte((byte) -1).toString());
121 assertEquals("0", new Byte((byte) 0).toString());
122 assertEquals("1", new Byte((byte) 1).toString());
123 assertEquals("-1", new Byte((byte) 0xFF).toString());
127 * @tests java.lang.Byte#toString(byte)
130 assertEquals("-1", Byte.toString((byte) -1));
131 assertEquals("0", Byte.toString((byte) 0));
132 assertEquals("1", Byte.toString((byte) 1));
133 assertEquals("-1", Byte.toString((byte) 0xFF));
137 * @tests java.lang.Byte#valueOf(String)
140 assertEquals(new Byte((byte) 0), Byte.valueOf("0"));
141 assertEquals(new Byte((byte) 1), Byte.valueOf("1"));
142 assertEquals(new Byte((byte) -1), Byte.valueOf("-1"));
145 Byte.valueOf("0x1");
151 Byte.valueOf("9.2");
157 Byte.valueOf("");
163 Byte.valueOf(null);
170 * @tests java.lang.Byte#valueOf(String,int)
173 assertEquals(new Byte((byte) 0), Byte.valueOf("0", 10));
174 assertEquals(new Byte((byte) 1), Byte.valueOf("1", 10));
175 assertEquals(new Byte((byte) -1), Byte.valueOf("-1", 10));
178 assertEquals(Character.digit('1', 2), Byte.valueOf("1", 2).byteValue());
179 assertEquals(Character.digit('F', 16), Byte.valueOf("F", 16).byteValue());
182 Byte.valueOf("0x1", 10);
188 Byte.valueOf("9.2", 10);
194 Byte.valueOf("", 10);
200 Byte.valueOf(null, 10);
207 * @tests java.lang.Byte#parseByte(String)
210 assertEquals(0, Byte.parseByte("0"));
211 assertEquals(1, Byte.parseByte("1"));
212 assertEquals(-1, Byte.parseByte("-1"));
215 Byte.parseByte("0x1");
221 Byte.parseByte("9.2");
227 Byte.parseByte("");
233 Byte.parseByte(null);
240 * @tests java.lang.Byte#parseByte(String,int)
243 assertEquals(0, Byte.parseByte("0", 10));
244 assertEquals(1, Byte.parseByte("1", 10));
245 assertEquals(-1, Byte.parseByte("-1", 10));
248 assertEquals(Character.digit('1', 2), Byte.parseByte("1", 2));
249 assertEquals(Character.digit('F', 16), Byte.parseByte("F", 16));
252 Byte.parseByte("0x1", 10);
258 Byte.parseByte("9.2", 10);
264 Byte.parseByte("", 10);
270 Byte.parseByte(null, 10);
277 * @tests java.lang.Byte#decode(String)
280 assertEquals(new Byte((byte) 0), Byte.decode("0"));
281 assertEquals(new Byte((byte) 1), Byte.decode("1"));
282 assertEquals(new Byte((byte) -1), Byte.decode("-1"));
283 assertEquals(new Byte((byte) 0xF), Byte.decode("0xF"));
284 assertEquals(new Byte((byte) 0xF), Byte.decode("#F"));
285 assertEquals(new Byte((byte) 0xF), Byte.decode("0XF"));
286 assertEquals(new Byte((byte) 07), Byte.decode("07"));
289 Byte.decode("9.2");
295 Byte.decode("");
301 Byte.decode(null);
309 * @tests java.lang.Byte#doubleValue()
312 assertEquals(-1D, new Byte((byte) -1).doubleValue(), 0D);
313 assertEquals(0D, new Byte((byte) 0).doubleValue(), 0D);
314 assertEquals(1D, new Byte((byte) 1).doubleValue(), 0D);
318 * @tests java.lang.Byte#floatValue()
321 assertEquals(-1F, new Byte((byte) -1).floatValue(), 0F);
322 assertEquals(0F, new Byte((byte) 0).floatValue(), 0F);
323 assertEquals(1F, new Byte((byte) 1).floatValue(), 0F);
327 * @tests java.lang.Byte#intValue()
330 assertEquals(-1, new Byte((byte) -1).intValue());
331 assertEquals(0, new Byte((byte) 0).intValue());
332 assertEquals(1, new Byte((byte) 1).intValue());
336 * @tests java.lang.Byte#longValue()
339 assertEquals(-1L, new Byte((byte) -1).longValue());
340 assertEquals(0L, new Byte((byte) 0).longValue());
341 assertEquals(1L, new Byte((byte) 1).longValue());
345 * @tests java.lang.Byte#shortValue()
348 assertEquals(-1, new Byte((byte) -1).shortValue());
349 assertEquals(0, new Byte((byte) 0).shortValue());
350 assertEquals(1, new Byte((byte) 1).shortValue());
354 * @tests java.lang.Byte#compareTo(Byte)
357 final Byte min = new Byte(Byte.MIN_VALUE);
358 final Byte zero = new Byte((byte) 0);
359 final Byte max = new Byte(Byte.MAX_VALUE);
382 * @tests java.lang.Byte#Byte(byte)
385 // Test for method java.lang.Byte(byte)
387 Byte b = new Byte((byte) 127);
388 assertTrue("Byte creation failed", b.byteValue() == (byte) 127);
392 * @tests java.lang.Byte#Byte(java.lang.String)
395 // Test for method java.lang.Byte(java.lang.String)
397 Byte b = new Byte("127");
398 Byte nb = new Byte("-128");
399 assertTrue("Incorrect Byte Object created", b.byteValue() == (byte) 127
400 && (nb.byteValue() == (byte) -128));
405 * @tests java.lang.Byte#byteValue()
408 // Test for method byte java.lang.Byte.byteValue()
409 assertTrue("Returned incorrect byte value",
410 new Byte((byte) 127).byteValue() == (byte) (127));
414 * @tests java.lang.Byte#compareTo(java.lang.Byte)
417 // Test for method int java.lang.Byte.compareTo(java.lang.Byte)
418 assertTrue("Comparison failed", new Byte((byte) 1).compareTo(new Byte((byte) 2)) < 0);
419 assertTrue("Comparison failed", new Byte((byte) 1).compareTo(new Byte((byte) -2)) > 0);
420 assertEquals("Comparison failed", 0, new Byte((byte) 1).compareTo(new Byte((byte) 1)));
424 * @tests java.lang.Byte#decode(java.lang.String)
427 // Test for method java.lang.Byte
428 // java.lang.Byte.decode(java.lang.String)
429 assertTrue("String decoded incorrectly, wanted: 1 got: " + Byte.decode("1").toString(),
430 Byte.decode("1").equals(new Byte((byte) 1)));
432 + Byte.decode("-1").toString(), Byte.decode("-1").equals(new Byte((byte) -1)));
434 + Byte.decode("127").toString(), Byte.decode("127")
435 .equals(new Byte((byte) 127)));
437 + Byte.decode("-128").toString(), Byte.decode("-128").equals(
438 new Byte((byte) -128)));
440 + Byte.decode("0x7f").toString(), Byte.decode("0x7f").equals(
441 new Byte((byte) 127)));
443 + Byte.decode("-0x80").toString(), Byte.decode("-0x80").equals(
444 new Byte((byte) -128)));
448 Byte.decode("128");
457 Byte.decode("-129");
466 Byte.decode("0x80");
475 Byte.decode("-0x81");
484 * @tests java.lang.Byte#doubleValue()
487 assertEquals(127D, new Byte((byte) 127).doubleValue(), 0.0);
491 * @tests java.lang.Byte#equals(java.lang.Object)
494 Byte.equals(java.lang.Object)
495 Byte b1 = new Byte((byte) 90);
496 Byte b2 = new Byte((byte) 90);
497 Byte b3 = new Byte((byte) -90);
503 * @tests java.lang.Byte#floatValue()
506 assertEquals(127F, new Byte((byte) 127).floatValue(), 0.0);
510 * @tests java.lang.Byte#hashCode()
513 // Test for method int java.lang.Byte.hashCode()
514 assertEquals("Incorrect hash returned", 127, new Byte((byte) 127).hashCode());
518 * @tests java.lang.Byte#intValue()
521 // Test for method int java.lang.Byte.intValue()
522 assertEquals("Returned incorrect int value", 127, new Byte((byte) 127).intValue());
526 * @tests java.lang.Byte#longValue()
529 // Test for method long java.lang.Byte.longValue()
530 assertEquals("Returned incorrect long value", 127L, new Byte((byte) 127).longValue());
534 * @tests java.lang.Byte#parseByte(java.lang.String)
537 assertEquals((byte)127, Byte.parseByte("127"));
538 assertEquals((byte)-128, Byte.parseByte("-128"));
539 assertEquals((byte)0, Byte.parseByte("0"));
540 assertEquals((byte)0x80, Byte.parseByte("-128"));
541 assertEquals((byte)0x7F, Byte.parseByte("127"));
544 Byte.parseByte("-1000");
550 Byte.parseByte("128");
556 Byte.parseByte("-129");
563 * @tests java.lang.Byte#parseByte(java.lang.String, int)
566 // Test for method byte java.lang.Byte.parseByte(java.lang.String, int)
567 byte b = Byte.parseByte("127", 10);
568 byte bn = Byte.parseByte("-128", 10);
569 assertTrue("Invalid parse of dec byte", b == (byte) 127 && (bn == (byte) -128));
570 assertEquals("Failed to parse hex value", 10, Byte.parseByte("A", 16));
571 assertEquals("Returned incorrect value for 0 hex", 0, Byte.parseByte("0", 16));
572 assertTrue("Returned incorrect value for most negative value hex", Byte.parseByte(
573 "-80", 16) == (byte) 0x80);
574 assertTrue("Returned incorrect value for most positive value hex", Byte.parseByte("7f",
576 assertEquals("Returned incorrect value for 0 decimal", 0, Byte.parseByte("0", 10));
577 assertTrue("Returned incorrect value for most negative value decimal", Byte.parseByte(
578 "-128", 10) == (byte) 0x80);
579 assertTrue("Returned incorrect value for most positive value decimal", Byte.parseByte(
583 Byte.parseByte("-1000", 10);
589 Byte.parseByte("128", 10);
595 Byte.parseByte("-129", 10);
601 Byte.parseByte("80", 16);
607 Byte.parseByte("-81", 16);
614 * @tests java.lang.Byte#shortValue()
617 assertEquals((short)127, new Byte((byte)127).shortValue());
621 * @tests java.lang.Byte#toString()
624 assertEquals("Returned incorrect String", "127", new Byte((byte) 127).toString());
625 assertEquals("Returned incorrect String", "-127", new Byte((byte) -127).toString());
626 assertEquals("Returned incorrect String", "-128", new Byte((byte) -128).toString());
630 * @tests java.lang.Byte#toString(byte)
633 assertEquals("Returned incorrect String", "127", Byte.toString((byte) 127));
634 assertEquals("Returned incorrect String", "-127", Byte.toString((byte) -127));
635 assertEquals("Returned incorrect String", "-128", Byte.toString((byte) -128));
639 * @tests java.lang.Byte#valueOf(java.lang.String)
642 assertEquals("Returned incorrect byte", 0, Byte.valueOf("0").byteValue());
643 assertEquals("Returned incorrect byte", 127, Byte.valueOf("127").byteValue());
644 assertEquals("Returned incorrect byte", -127, Byte.valueOf("-127").byteValue());
645 assertEquals("Returned incorrect byte", -128, Byte.valueOf("-128").byteValue());
648 Byte.valueOf("128");
649 fail("Failed to throw exception when passes value > byte");
655 * @tests java.lang.Byte#valueOf(java.lang.String, int)
658 assertEquals("Returned incorrect byte", 10, Byte.valueOf("A", 16).byteValue());
659 assertEquals("Returned incorrect byte", 127, Byte.valueOf("127", 10).byteValue());
660 assertEquals("Returned incorrect byte", -127, Byte.valueOf("-127", 10).byteValue());
661 assertEquals("Returned incorrect byte", -128, Byte.valueOf("-128", 10).byteValue());
662 assertEquals("Returned incorrect byte", 127, Byte.valueOf("7f", 16).byteValue());
663 assertEquals("Returned incorrect byte", -127, Byte.valueOf("-7f", 16).byteValue());
664 assertEquals("Returned incorrect byte", -128, Byte.valueOf("-80", 16).byteValue());
667 Byte.valueOf("128", 10);
668 fail("Failed to throw exception when passes value > byte");