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
.internal
.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 void clear() method test.
93 public void testClear() {
98 * Run the ByteBuffer getByteBuffer() method test.
101 public void testGetByteBuffer() {
102 ByteBuffer result
= fixture
.getByteBuffer();
104 assertNotNull(result
);
106 "java.nio.HeapByteBuffer[pos=0 lim=0 cap=0]", result
.toString()); //$NON-NLS-1$
107 assertEquals(false, result
.isDirect());
108 assertEquals(true, result
.hasArray());
109 assertEquals(0, result
.arrayOffset());
110 assertEquals(0, result
.limit());
111 assertEquals(0, result
.remaining());
112 assertEquals(0, result
.position());
113 assertEquals(0, result
.capacity());
114 assertEquals(false, result
.hasRemaining());
115 assertEquals(false, result
.isReadOnly());
119 * Run the ByteOrder getByteOrder() method test.
122 public void testGetByteOrder() {
123 ByteOrder result
= fixture
.getByteOrder();
125 assertNotNull(result
);
126 assertEquals("BIG_ENDIAN", result
.toString()); //$NON-NLS-1$
130 * Run the ByteOrder order() method test.
133 public void testGetOrder() {
134 ByteOrder result
= fixture
.getByteOrder();
136 assertNotNull(result
);
137 assertEquals("BIG_ENDIAN", result
.toString()); //$NON-NLS-1$
141 * Run the void order(ByteOrder) method test.
144 public void testSetOrder() {
145 ByteOrder order
= ByteOrder
.BIG_ENDIAN
;
147 fixture
.setByteOrder(order
);
151 * Run the int position() method test.
154 public void testGetPosition() {
155 int result
= fixture
.position();
157 assertEquals(1, result
);
161 * Run the void position(int) method test.
164 public void testSetPosition() {
166 fixture
.position(newPosition
);
170 * Run the void setByteBuffer(ByteBuffer) method test.
173 public void testSetByteBuffer() {
174 ByteBuffer buf
= ByteBuffer
.allocate(0);
175 fixture
.setByteBuffer(buf
);
179 * Run the void setByteBuffer(ByteBuffer) method test.
182 public void testSetByteBuffer_null() {
183 ByteBuffer buf
= null;
184 fixture
.setByteBuffer(buf
);
188 * Run the void setByteOrder(ByteOrder) method test.
191 public void testSetByteOrder() {
192 ByteOrder byteOrder
= ByteOrder
.BIG_ENDIAN
;
193 fixture
.setByteOrder(byteOrder
);
This page took 0.0353 seconds and 6 git commands to generate.