Skip to content

Commit

Permalink
Input stream mark and reset do not preserve endianness #63
Browse files Browse the repository at this point in the history
Signed-off-by: David Marina <David.Marina@esa.int>
  • Loading branch information
dmarina-esa authored and russgold committed Apr 27, 2020
1 parent d47af4a commit cb3122e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,7 @@ public StreamMemento() {
valueHandler_ = valueHandler;
specialNoOptionalDataState_ = specialNoOptionalDataState;
byteBuffer_ = byteBuffer.duplicate();
byteBuffer_.order(byteBuffer.order());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.omg.CORBA.TypeCodePackage.BadKind;

import java.io.IOException;
import java.nio.ByteOrder;
import java.util.Arrays;

import static org.junit.Assert.*;
Expand Down Expand Up @@ -463,6 +464,17 @@ public void whenUsingV1_2_headerPaddingForces8ByteAlignmentOnce() {
assertEquals(-1, getInputObject().read_long());
}

@Test
public void whenMarkIsSetInV1_0_restorePreservesByteOrder() {
useV1_0();
setMessageBody(1);
getInputObject().consumeEndian();
assertEquals(ByteOrder.LITTLE_ENDIAN, getInputObject().getByteOrder());
getInputObject().mark(0);
getInputObject().reset();
assertEquals(ByteOrder.LITTLE_ENDIAN, getInputObject().getByteOrder());
}

@Test
public void whenMarkIsSetInV1_0_restoreAllowsReread() {
useV1_0();
Expand Down

0 comments on commit cb3122e

Please sign in to comment.