1 | void testFromBytes() {↵ | | 1 | void testFromBytes() {↵
|
2 | byte[] val = new byte[] {0x34, 0x12};↵ | | 2 | byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12};↵
|
3 | ZipShort zs = new ZipShort(val);↵ | | 3 | ZipLong zl = new ZipLong(val);↵
|
4 | assertEquals("value from bytes", 0x1234, zs.getValue());↵ | | 4 | assertEquals("value from bytes", 0x12345678, zl.getValue());↵
|
5 | }↵ | | 5 | }↵
|
|
6 | /**↵ | | 6 | /**↵
|
7 | * Test the contract of the equals method.↵ | | 7 | * Test the contract of the equals method.↵
|
8 | */↵ | | 8 | */↵
|
9 | public void testEquals() {↵ | | 9 | public void testEquals() {↵
|
10 | ZipShort zs = new ZipShort(0x1234);↵ | | 10 | ZipLong zl = new ZipLong(0x12345678);↵
|
11 | ZipShort zs2 = new ZipShort(0x1234);↵ | | 11 | ZipLong zl2 = new ZipLong(0x12345678);↵
|
12 | ZipShort zs3 = new ZipShort(0x5678);↵ | | 12 | ZipLong zl3 = new ZipLong(0x87654321);↵
|
|
13 | assertTrue("reflexive", zs.equals(zs));↵ | | 13 | assertTrue("reflexive", zl.equals(zl));↵
|
|
14 | assertTrue("works", zs.equals(zs2));↵ | | 14 | assertTrue("works", zl.equals(zl2));↵
|
15 | assertTrue("works, part two", !zs.equals(zs3));↵ | | 15 | assertTrue("works, part two", !zl.equals(zl3));↵
|
|
16 | assertTrue("symmetric", zs2.equals(zs));↵ | | 16 | assertTrue("symmetric", zl2.equals(zl));↵
|
|
17 | assertTrue("null handling", !zs.equals(null));↵ | | 17 | assertTrue("null handling", !zl.equals(null));↵
|
18 | assertTrue("non ZipShort handling", !zs.equals(new Integer(0x1234)));↵ | | 18 | assertTrue("non ZipLong handling", !zl.equals(new Integer(0x1234)));↵
|
19 | }↵ | | 19 | }↵
|
|
20 | /**↵ | | 20 | /**↵
|
21 | * Test sign handling.↵ | | 21 | * Test sign handling.↵
|
22 | */↵ | | 22 | */↵
|
23 | public void testSign() {↵ | | 23 | public void testSign() {↵
|
24 | ZipShort zs = new ZipShort(new byte[] {(byte)0xFF, (byte)0xFF});↵ | | 24 | ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF});↵
|
25 | assertEquals(0x0000FFFF, zs.getValue());↵ | | 25 | assertEquals(0x00000000FFFFFFFFl, zl.getValue());↵
|
26 | | | 26 |
|