Merge remote-tracking branch

'origin/GT-3512_dev747368_dataconverter_fixes'
This commit is contained in:
ghidra1 2020-02-21 14:03:30 -05:00
commit 45778b0117
43 changed files with 635 additions and 758 deletions

View file

@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
* REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -36,7 +35,7 @@ class FileByteBlock implements ByteBlock {
FileByteBlock(byte[] b) {
buf = b;
converter = new LittleEndianDataConverter();
converter = LittleEndianDataConverter.INSTANCE;
}
/* (non-Javadoc)
@ -153,12 +152,7 @@ class FileByteBlock implements ByteBlock {
public void setBigEndian(boolean bigEndian) {
if (this.bigEndian != bigEndian) {
this.bigEndian = bigEndian;
if (bigEndian) {
converter = new BigEndianDataConverter();
}
else {
converter = new LittleEndianDataConverter();
}
converter = DataConverter.getInstance(bigEndian);
}
}

View file

@ -68,7 +68,7 @@ public class FileByteBlockTest extends AbstractGenericTest {
@Test
public void testGetInt() throws Exception {
block.setBigEndian(true);
DataConverter conv = new BigEndianDataConverter();
DataConverter conv = BigEndianDataConverter.INSTANCE;
for (int i = 0; i < 20; i++) {
byte[] b = new byte[4];
@ -77,7 +77,7 @@ public class FileByteBlockTest extends AbstractGenericTest {
}
block.setBigEndian(false);
conv = new LittleEndianDataConverter();
conv = LittleEndianDataConverter.INSTANCE;
for (int i = 0; i < 12; i++) {
byte[] b = new byte[4];
System.arraycopy(buf, i + 4, b, 0, b.length);
@ -89,7 +89,7 @@ public class FileByteBlockTest extends AbstractGenericTest {
@Test
public void testGetLong() throws Exception {
block.setBigEndian(true);
DataConverter conv = new BigEndianDataConverter();
DataConverter conv = BigEndianDataConverter.INSTANCE;
for (int i = 0; i < 10; i++) {
byte[] b = new byte[8];
@ -104,7 +104,7 @@ public class FileByteBlockTest extends AbstractGenericTest {
}
block.setBigEndian(false);
conv = new LittleEndianDataConverter();
conv = LittleEndianDataConverter.INSTANCE;
for (int i = 0; i < 10; i++) {
byte[] b = new byte[8];
System.arraycopy(buf, i + 8, b, 0, b.length);
@ -141,7 +141,7 @@ public class FileByteBlockTest extends AbstractGenericTest {
@Test
public void testSetInt() throws Exception {
block.setBigEndian(true);
DataConverter conv = new BigEndianDataConverter();
DataConverter conv = BigEndianDataConverter.INSTANCE;
byte[] b = new byte[4];
System.arraycopy(buf, 35, b, 0, b.length);
@ -158,7 +158,7 @@ public class FileByteBlockTest extends AbstractGenericTest {
}
block.setBigEndian(false);
conv = new LittleEndianDataConverter();
conv = LittleEndianDataConverter.INSTANCE;
b = new byte[4];
System.arraycopy(buf, 35, b, 0, b.length);
@ -179,7 +179,7 @@ public class FileByteBlockTest extends AbstractGenericTest {
@Test
public void testSetLong() throws Exception {
block.setBigEndian(true);
DataConverter conv = new BigEndianDataConverter();
DataConverter conv = BigEndianDataConverter.INSTANCE;
byte[] b = new byte[8];
System.arraycopy(buf, 35, b, 0, b.length);
@ -196,7 +196,7 @@ public class FileByteBlockTest extends AbstractGenericTest {
}
block.setBigEndian(false);
conv = new LittleEndianDataConverter();
conv = LittleEndianDataConverter.INSTANCE;
b = new byte[8];
System.arraycopy(buf, 35, b, 0, b.length);