1 package org
.eclipse
.linuxtools
.ctf
.core
.tests
.io
;
3 import static org
.junit
.Assert
.assertEquals
;
4 import static org
.junit
.Assert
.assertNotNull
;
6 import java
.nio
.ByteBuffer
;
7 import java
.nio
.ByteOrder
;
9 import org
.eclipse
.linuxtools
.ctf
.core
.event
.io
.BitBuffer
;
10 import org
.junit
.After
;
11 import org
.junit
.Before
;
12 import org
.junit
.Test
;
15 * The class <code>BitBufferTest</code> contains tests for the class
16 * <code>{@link BitBuffer}</code>.
19 * @version $Revision: 1.0 $
21 public class BitBufferTest
{
23 private BitBuffer fixture
;
29 * the command line arguments
31 public static void main(String
[] args
) {
32 new org
.junit
.runner
.JUnitCore().run(BitBufferTest
.class);
36 * Perform pre-test initialization.
40 fixture
= new BitBuffer(java
.nio
.ByteBuffer
.allocateDirect(128));
41 fixture
.setByteOrder(ByteOrder
.BIG_ENDIAN
);
42 fixture
.setByteBuffer(ByteBuffer
.allocate(0));
47 * Perform post-test clean-up.
50 public void tearDown() {
51 // Add additional tear down code here
55 * Run the BitBuffer() constructor test.
58 public void testBitBuffer() {
59 BitBuffer result
= new BitBuffer();
61 assertNotNull(result
);
62 assertEquals(0, result
.position());
63 assertEquals(null, result
.getByteBuffer());
67 * Run the BitBuffer(ByteBuffer) constructor test.
70 public void testBitBuffer_fromByteBuffer() {
71 ByteBuffer buf
= ByteBuffer
.allocate(0);
72 BitBuffer result
= new BitBuffer(buf
);
74 assertNotNull(result
);
75 assertEquals(0, result
.position());
79 * Run the boolean canRead(int) method test.
82 public void testCanRead_1param() {
84 boolean result
= fixture
.canRead(length
);
86 assertEquals(false, result
);
90 * Run the boolean canRead(int,int) method test.
93 public void testCanRead_2params() {
96 boolean result
= fixture
.canRead(index
, length
);
98 assertEquals(false, result
);
102 * Run the void clear() method test.
105 public void testClear() {
110 * Run the ByteBuffer getByteBuffer() method test.
113 public void testGetByteBuffer() {
114 ByteBuffer result
= fixture
.getByteBuffer();
116 assertNotNull(result
);
118 "java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]", result
.toString()); //$NON-NLS-1$
119 assertEquals(false, result
.isDirect());
120 assertEquals(true, result
.hasArray());
121 assertEquals(0, result
.arrayOffset());
122 assertEquals(0, result
.limit());
123 assertEquals(0, result
.remaining());
124 assertEquals(0, result
.position());
125 assertEquals(0, result
.capacity());
126 assertEquals(false, result
.hasRemaining());
127 assertEquals(false, result
.isReadOnly());
131 * Run the ByteOrder getByteOrder() method test.
134 public void testGetByteOrder() {
135 ByteOrder result
= fixture
.getByteOrder();
137 assertNotNull(result
);
138 assertEquals("BIG_ENDIAN", result
.toString()); //$NON-NLS-1$
142 * Run the ByteOrder order() method test.
145 public void testGetOrder() {
146 ByteOrder result
= fixture
.order();
148 assertNotNull(result
);
149 assertEquals("BIG_ENDIAN", result
.toString()); //$NON-NLS-1$
153 * Run the void order(ByteOrder) method test.
156 public void testSetOrder() {
157 ByteOrder order
= ByteOrder
.BIG_ENDIAN
;
159 fixture
.order(order
);
163 * Run the int position() method test.
166 public void testGetPosition() {
167 int result
= fixture
.position();
169 assertEquals(1, result
);
173 * Run the void position(int) method test.
176 public void testSetPosition() {
178 fixture
.position(newPosition
);
182 * Run the void setByteBuffer(ByteBuffer) method test.
185 public void testSetByteBuffer() {
186 ByteBuffer buf
= ByteBuffer
.allocate(0);
187 fixture
.setByteBuffer(buf
);
191 * Run the void setByteBuffer(ByteBuffer) method test.
194 public void testSetByteBuffer_null() {
195 ByteBuffer buf
= null;
196 fixture
.setByteBuffer(buf
);
200 * Run the void setByteOrder(ByteOrder) method test.
203 public void testSetByteOrder() {
204 ByteOrder byteOrder
= ByteOrder
.BIG_ENDIAN
;
205 fixture
.setByteOrder(byteOrder
);
This page took 0.038337 seconds and 6 git commands to generate.