1 18 19 package com.martiansoftware.nailgun; 20 21 import junit.framework.TestCase; 22 23 27 public class TestLongUtils extends TestCase { 28 29 private void testToFromArray(long l, byte b0, byte b1, byte b2, byte b3) { 30 byte[] buf = new byte[4]; 31 LongUtils.toArray(l, buf, 0); 32 assertEquals(b0, buf[0]); 33 assertEquals(b1, buf[1]); 34 assertEquals(b2, buf[2]); 35 assertEquals(b3, buf[3]); 36 assertEquals(l, LongUtils.fromArray(buf, 0)); 37 } 38 39 public void testLongUtils() { 40 testToFromArray(0, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00); 41 testToFromArray(4294967295l, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff); 42 testToFromArray(305419896l, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78); 43 } 44 45 } 46 | Popular Tags |