1 17 18 package org.apache.tools.zip; 19 20 import junit.framework.TestCase; 21 22 26 public class ZipLongTest extends TestCase { 27 28 public ZipLongTest(String name) { 29 super(name); 30 } 31 32 35 public void testToBytes() { 36 ZipLong zl = new ZipLong(0x12345678); 37 byte[] result = zl.getBytes(); 38 assertEquals("length getBytes", 4, result.length); 39 assertEquals("first byte getBytes", 0x78, result[0]); 40 assertEquals("second byte getBytes", 0x56, result[1]); 41 assertEquals("third byte getBytes", 0x34, result[2]); 42 assertEquals("fourth byte getBytes", 0x12, result[3]); 43 } 44 45 48 public void testFromBytes() { 49 byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12}; 50 ZipLong zl = new ZipLong(val); 51 assertEquals("value from bytes", 0x12345678, zl.getValue()); 52 } 53 54 57 public void testEquals() { 58 ZipLong zl = new ZipLong(0x12345678); 59 ZipLong zl2 = new ZipLong(0x12345678); 60 ZipLong zl3 = new ZipLong(0x87654321); 61 62 assertTrue("reflexive", zl.equals(zl)); 63 64 assertTrue("works", zl.equals(zl2)); 65 assertTrue("works, part two", !zl.equals(zl3)); 66 67 assertTrue("symmetric", zl2.equals(zl)); 68 69 assertTrue("null handling", !zl.equals(null)); 70 assertTrue("non ZipLong handling", !zl.equals(new Integer (0x1234))); 71 } 72 73 76 public void testSign() { 77 ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); 78 assertEquals(0x00000000FFFFFFFFl, zl.getValue()); 79 } 80 81 } 82 | Popular Tags |