KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > bytes > TCByteBufferTest


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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 JavaDoc iae) {
31       // expected
32
}
33
34     try {
35       buf.putUint(0, -1);
36       fail("I was allowed to write an illegal value (-1)");
37     } catch (IllegalArgumentException JavaDoc iae) {
38       // expected
39
}
40
41   }
42 }
43
Popular Tags