/**
* Part of the BitBuffet tests with test the methods to read/write integers.
* These are separated from the main file because the fixture is different.
- *
+ *
* @author alexmont
- *
+ *
*/
public class BitBufferIntTest {
/**
* Launch the test.
- *
+ *
* @param args
* the command line arguments
*/
@Test
public void testGetInt_signed() {
fixture.position(1);
- int index = 1;
int length = 0;
boolean signed = true;
- int result = fixture.getInt(index, length, signed);
+ int result = fixture.getInt(length, signed);
assertEquals(0, result);
}
@Test
public void testGetInt_signed_length1() {
fixture.position(1);
- int index = 1;
int length = 1;
boolean signed = true;
- int result = fixture.getInt(index, length, signed);
+ int result = fixture.getInt(length, signed);
assertEquals(0, result);
}
le_fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
createBuffer(le_fixture);
le_fixture.position(1);
- int index = 1;
int length = 24;
- int result = le_fixture.getInt(index, length, false);
+ int result = le_fixture.getInt(length, false);
/* 0x020100 downshifted */
assertEquals(0x810080, result);
le_fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
createBuffer(le_fixture);
le_fixture.position(0);
- int index = 0;
int length = 24;
- int result = le_fixture.getInt(index, length, false);
+ int result = le_fixture.getInt(length, false);
assertEquals(0x020100, result);
}
small_fixture.setByteOrder(ByteOrder.BIG_ENDIAN);
createBuffer(small_fixture, 2);
small_fixture.position(1);
- int index = 1;
int length = 64;
boolean signed = true;
- int result = small_fixture.getInt(index, length, signed);
+ int result = small_fixture.getInt(length, signed);
assertEquals(0, result);
}
*/
@Test
public void testPutInt_length0() {
- int index = 1;
int length = 0;
int value = 1;
fixture.position(1);
- fixture.putInt(index, length, value);
+ fixture.putInt(length, value);
}
/**
*/
@Test
public void testPutInt_length1() {
- int index = 1;
int length = 1;
int value = 1;
fixture.position(1);
- fixture.putInt(index, length, value);
+ fixture.putInt(length, value);
}
/**
*/
@Test
public void testPutInt_hex() {
- int value = 0x010203;
+ final int value = 0x010203;
+ int read;
- fixture.position(1);
- fixture.putInt(value);
- int read = fixture.getInt();
- assertEquals(value, read);
+ for (int i = 0; i <= 32; i++) {
+ fixture.position(i);
+ fixture.putInt(value);
+
+ fixture.position(i);
+ read = fixture.getInt();
+
+ assertEquals(value, read);
+ }
}
/**
createBuffer(fixture2, 4);
fixture2.position(1);
- int index = 16;
int length = 32;
int value = 1;
- fixture2.putInt(index, length, value);
+ fixture2.putInt(length, value);
int read = fixture2.getInt(1, true);
assertEquals(value, read);