01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.bytes;
05:
06: import junit.framework.TestCase;
07:
08: public class TCByteBufferTest extends TestCase {
09:
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: // expected
32: }
33:
34: try {
35: buf.putUint(0, -1);
36: fail("I was allowed to write an illegal value (-1)");
37: } catch (IllegalArgumentException iae) {
38: // expected
39: }
40:
41: }
42: }
|