Search in sources :

Example 11 with NulTerminatedCharsetDecoder

use of com.facebook.buck.charset.NulTerminatedCharsetDecoder in project buck by facebook.

the class SectionTest method testCreatingFromBytesLittleEndian64Bit.

@Test
public void testCreatingFromBytesLittleEndian64Bit() throws Exception {
    Section section = SectionUtils.createFromBuffer(createBuffer(SectionTestData.getLittleEndian64Bit(), 20, ByteOrder.LITTLE_ENDIAN), true, new NulTerminatedCharsetDecoder(StandardCharsets.UTF_8.newDecoder()));
    assertThat(section.getOffsetInBinary(), equalTo(20));
    checkValues(section);
}
Also used : NulTerminatedCharsetDecoder(com.facebook.buck.charset.NulTerminatedCharsetDecoder) Test(org.junit.Test)

Example 12 with NulTerminatedCharsetDecoder

use of com.facebook.buck.charset.NulTerminatedCharsetDecoder in project buck by facebook.

the class SectionUtilsTest method testCreatingFromBytes32Bits.

@Test
public void testCreatingFromBytes32Bits() throws CharacterCodingException {
    ByteBuffer buffer = ByteBuffer.allocate(20 + SectionTestData.getBigEndian32Bit().length);
    buffer.order(ByteOrder.BIG_ENDIAN);
    buffer.position(20);
    buffer.put(SectionTestData.getBigEndian32Bit());
    buffer.position(20);
    Section section = SectionUtils.createFromBuffer(buffer, false, new NulTerminatedCharsetDecoder(StandardCharsets.UTF_8.newDecoder()));
    assertThat(section.getOffsetInBinary(), equalTo(20));
    SectionTestData.checkValues(section, false);
}
Also used : NulTerminatedCharsetDecoder(com.facebook.buck.charset.NulTerminatedCharsetDecoder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 13 with NulTerminatedCharsetDecoder

use of com.facebook.buck.charset.NulTerminatedCharsetDecoder in project buck by facebook.

the class SegmentCommandTest method testCreatingFromBytes64BitsLittleEndian.

@Test
public void testCreatingFromBytes64BitsLittleEndian() throws Exception {
    ByteBuffer byteBuffer = bufferWithBytes(SegmentCommandTestData.getLittleEndian64Bits(), 10);
    byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
    SegmentCommand command = SegmentCommandUtils.createFromBuffer(byteBuffer, new NulTerminatedCharsetDecoder(StandardCharsets.UTF_8.newDecoder()));
    assertThat(command.getLoadCommandCommonFields().getOffsetInBinary(), equalTo(10));
    SegmentCommandTestData.checkValues(command, true);
}
Also used : NulTerminatedCharsetDecoder(com.facebook.buck.charset.NulTerminatedCharsetDecoder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 14 with NulTerminatedCharsetDecoder

use of com.facebook.buck.charset.NulTerminatedCharsetDecoder in project buck by facebook.

the class SegmentCommandTest method testCreatingFromBytes64BitsBigEndian.

@Test
public void testCreatingFromBytes64BitsBigEndian() throws Exception {
    ByteBuffer byteBuffer = bufferWithBytes(SegmentCommandTestData.getBigEndian64Bits(), 10);
    byteBuffer.order(ByteOrder.BIG_ENDIAN);
    SegmentCommand command = SegmentCommandUtils.createFromBuffer(byteBuffer, new NulTerminatedCharsetDecoder(StandardCharsets.UTF_8.newDecoder()));
    assertThat(command.getLoadCommandCommonFields().getOffsetInBinary(), equalTo(10));
    SegmentCommandTestData.checkValues(command, true);
}
Also used : NulTerminatedCharsetDecoder(com.facebook.buck.charset.NulTerminatedCharsetDecoder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 15 with NulTerminatedCharsetDecoder

use of com.facebook.buck.charset.NulTerminatedCharsetDecoder in project buck by facebook.

the class SegmentCommandTest method testCreatingFromBytes32BitsBigEndian.

@Test
public void testCreatingFromBytes32BitsBigEndian() throws Exception {
    ByteBuffer byteBuffer = bufferWithBytes(SegmentCommandTestData.getBigEndian32Bits(), 10);
    byteBuffer.order(ByteOrder.BIG_ENDIAN);
    SegmentCommand command = SegmentCommandUtils.createFromBuffer(byteBuffer, new NulTerminatedCharsetDecoder(StandardCharsets.UTF_8.newDecoder()));
    assertThat(command.getLoadCommandCommonFields().getOffsetInBinary(), equalTo(10));
    SegmentCommandTestData.checkValues(command, false);
}
Also used : NulTerminatedCharsetDecoder(com.facebook.buck.charset.NulTerminatedCharsetDecoder) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Aggregations

NulTerminatedCharsetDecoder (com.facebook.buck.charset.NulTerminatedCharsetDecoder)25 Test (org.junit.Test)23 ByteBuffer (java.nio.ByteBuffer)15 ArrayList (java.util.ArrayList)4 MappedByteBuffer (java.nio.MappedByteBuffer)2 Path (java.nio.file.Path)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 ObjectPathsAbsolutifier (com.facebook.buck.macho.ObjectPathsAbsolutifier)1 RandomAccessFile (java.io.RandomAccessFile)1