mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GT-3347 tweak hex formatting of out-of-range values
This commit is contained in:
parent
3faebfebe8
commit
4c57727282
3 changed files with 26 additions and 26 deletions
|
@ -121,7 +121,7 @@ public class StringRenderBuilder {
|
|||
if (valStr.length() < 2) {
|
||||
sb.append("0");
|
||||
}
|
||||
sb.append(valStr);
|
||||
sb.append(valStr).append("h");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,33 +157,33 @@ public class CharDataTypesRenderTest extends AbstractGTest {
|
|||
|
||||
// wchar32
|
||||
String result = wchar32DT.getRepresentation(buf32, normset, wchar32DT.getLength());
|
||||
assertEquals("AA,AA,AA,AA", result);
|
||||
assertEquals("AAh,AAh,AAh,AAh", result);
|
||||
|
||||
result = wchar32DT.getRepresentation(buf32, escseq, wchar32DT.getLength());
|
||||
assertEquals("AA,AA,AA,AA", result);
|
||||
assertEquals("AAh,AAh,AAh,AAh", result);
|
||||
|
||||
result = wchar32DT.getRepresentation(buf32, byteseq, wchar32DT.getLength());
|
||||
assertEquals("AA,AA,AA,AA", result);
|
||||
assertEquals("AAh,AAh,AAh,AAh", result);
|
||||
|
||||
// wchar16
|
||||
result = wchar16DT.getRepresentation(buf16_be, normset, wchar16DT.getLength());
|
||||
assertEquals("D8,00", result);
|
||||
assertEquals("D8h,00h", result);
|
||||
|
||||
result = wchar16DT.getRepresentation(buf16_be, escseq, wchar16DT.getLength());
|
||||
assertEquals("D8,00", result);
|
||||
assertEquals("D8h,00h", result);
|
||||
|
||||
result = wchar16DT.getRepresentation(buf16_be, byteseq, wchar16DT.getLength());
|
||||
assertEquals("D8,00", result);
|
||||
assertEquals("D8h,00h", result);
|
||||
|
||||
// charDT
|
||||
result = charDT.getRepresentation(buf8, normset, charDT.getLength());
|
||||
assertEquals("85", result);
|
||||
assertEquals("85h", result);
|
||||
|
||||
result = charDT.getRepresentation(buf8, escseq, charDT.getLength());
|
||||
assertEquals("85", result);
|
||||
assertEquals("85h", result);
|
||||
|
||||
result = charDT.getRepresentation(buf8, byteseq, charDT.getLength());
|
||||
assertEquals("85", result);
|
||||
assertEquals("85h", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -200,6 +200,6 @@ public class CharDataTypesRenderTest extends AbstractGTest {
|
|||
|
||||
result = wchar16DT.getRepresentation(mb(false, 0xfd, 0xff),
|
||||
newset().set(RENDER_ENUM.BYTE_SEQ), wchar16DT.getLength());
|
||||
assertEquals("FD,FF", result);
|
||||
assertEquals("FDh,FFh", result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ public class StringDataTypeTest extends AbstractGTest {
|
|||
public void testProbeGetStringRep_LeadingBinaryBytes() {
|
||||
ByteMemBufferImpl buf = mb(false, 1, 2, 'x');
|
||||
|
||||
assertEquals("01,02,\"x\"",
|
||||
assertEquals("01h,02h,\"x\"",
|
||||
fixedlenString.getRepresentation(buf, newset(), buf.getLength()));
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ public class StringDataTypeTest extends AbstractGTest {
|
|||
ByteMemBufferImpl buf = mb(false, 'h', 'e', 'l', 'l', 'o', 0, 'a', '\n', 'b', 255, 0);
|
||||
|
||||
// US-ASCII charset doesn't map 0x80-0xff, they result in error characters
|
||||
assertEquals("\"hello\\0a\\nb\",FF",
|
||||
assertEquals("\"hello\\0a\\nb\",FFh",
|
||||
fixedlenString.getRepresentation(buf, newset(), buf.getLength()));
|
||||
}
|
||||
|
||||
|
@ -420,19 +420,19 @@ public class StringDataTypeTest extends AbstractGTest {
|
|||
//@formatter:off
|
||||
String expected =
|
||||
"\"\\0\"," +
|
||||
"01,02,03,04,05,06,"+
|
||||
"\"\\a\\b\\t\\n\\v\\f\\r\",0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,\""+
|
||||
"01h,02h,03h,04h,05h,06h,"+
|
||||
"\"\\a\\b\\t\\n\\v\\f\\r\",0Eh,0Fh,10h,11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h,D3h,D4h,D5h,D6h,D7h,D8h,D9h,DAh,DBh,DCh,DDh,DEh,DFh,"+
|
||||
"E0h,E1h,E2h,E3h,E4h,E5h,E6h,E7h,E8h,E9h,EAh,EBh,ECh,EDh,EEh,EFh,"+
|
||||
"F0h,F1h,F2h,F3h,F4h,F5h,F6h,F7h,F8h,F9h,FAh,FBh,FCh,FDh,FEh,FFh";
|
||||
//@formatter:on
|
||||
|
||||
assertEquals("String rep w/java US-ASCII charset mapping failed", expected, actual);
|
||||
|
@ -465,8 +465,8 @@ public class StringDataTypeTest extends AbstractGTest {
|
|||
assertEquals(e1, fixedUtf16String.getRepresentation(buf_be, newset(), buf_be.getLength()));
|
||||
assertEquals(e1, fixedUtf16String.getRepresentation(buf_le, newset(), buf_le.getLength()));
|
||||
|
||||
String e2_be = "u\"ab\",CC,01,12,02";
|
||||
String e2_le = "u\"ab\",01,CC,02,12";
|
||||
String e2_be = "u\"ab\",CCh,01h,12h,02h";
|
||||
String e2_le = "u\"ab\",01h,CCh,02h,12h";
|
||||
assertEquals(e2_be, fixedUtf16String.getRepresentation(buf_be,
|
||||
newset().set(RENDER_ENUM.BYTE_SEQ), buf_be.getLength()));
|
||||
assertEquals(e2_le, fixedUtf16String.getRepresentation(buf_le,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue