mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Corrected convertBytesToString with offset and length
This commit is contained in:
parent
146a83f953
commit
4614567590
2 changed files with 10 additions and 2 deletions
|
@ -670,7 +670,7 @@ public final class NumericUtilities {
|
|||
*/
|
||||
public static String convertBytesToString(byte[] bytes, int start, int len, String delimeter) {
|
||||
|
||||
Iterator<Byte> iterator = IteratorUtils.arrayIterator(bytes, start, len);
|
||||
Iterator<Byte> iterator = IteratorUtils.arrayIterator(bytes, start, start + len);
|
||||
return convertBytesToString(iterator, delimeter);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
package ghidra.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -95,6 +96,13 @@ public class NumericUtilitiesTest {
|
|||
assertEquals("012380ff00", str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertBytesToStringWithOffsetAndLength() {
|
||||
byte[] bytes = new byte[] { (byte) 0x1, (byte) 0x23, (byte) 0x80, (byte) 0xff, (byte) 0 };
|
||||
String str = NumericUtilities.convertBytesToString(bytes, 2, 2, " ");
|
||||
assertEquals("80 ff", str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConvertBytesToStringWithDelimiter() {
|
||||
byte[] bytes = new byte[] { (byte) 0x1, (byte) 0x23, (byte) 0x80, (byte) 0xff, (byte) 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue