1 4 package com.tc.bytes; 5 6 import junit.framework.TestCase; 7 8 public class TCByteBufferTest extends TestCase { 9 10 public void testUint() { 11 TCByteBuffer buf = TCByteBufferFactory.getInstance(false, 4); 12 13 buf.putUint(0, 0); 14 assertEquals(0, buf.getUint(0)); 15 16 buf.putUint(0, 1); 17 assertEquals(1, buf.getUint(0)); 18 19 long highBit = 0x80000000L; 20 buf.putUint(0, highBit); 21 assertEquals(highBit, buf.getUint(0)); 22 23 final long max = 0xFFFFFFFFL; 24 buf.putUint(0, max); 25 assertEquals(max, buf.getUint(0)); 26 27 try { 28 buf.putUint(0, max + 1); 29 fail("I was allowed to write an illegal value"); 30 } catch (IllegalArgumentException iae) { 31 } 33 34 try { 35 buf.putUint(0, -1); 36 fail("I was allowed to write an illegal value (-1)"); 37 } catch (IllegalArgumentException iae) { 38 } 40 41 } 42 } 43 | Popular Tags |