diff --git a/Ghidra/Features/MicrosoftDemangler/src/test/java/ghidra/app/util/demangler/microsoft/MicrosoftDemanglerTest.java b/Ghidra/Features/MicrosoftDemangler/src/test/java/ghidra/app/util/demangler/microsoft/MicrosoftDemanglerTest.java index e7fecec70f..1fb648c4ab 100644 --- a/Ghidra/Features/MicrosoftDemangler/src/test/java/ghidra/app/util/demangler/microsoft/MicrosoftDemanglerTest.java +++ b/Ghidra/Features/MicrosoftDemangler/src/test/java/ghidra/app/util/demangler/microsoft/MicrosoftDemanglerTest.java @@ -238,6 +238,20 @@ public class MicrosoftDemanglerTest extends AbstractGenericTest { fail(); // We are expecting an exception. } + @Test + public void testSimpleDemangleType() throws Exception { + String mangled = ".?AUname0@name1@@"; + Address address = addr("01001000"); + String expected = "struct name1::name0"; + + MicrosoftDemangler demangler = new MicrosoftDemangler(); + DemanglerOptions options = new MicrosoftDemanglerOptions(); + MangledContext mangledContext = + demangler.createMangledContext(mangled, options, program, address); + DemangledDataType dt = demangler.demangleType(mangledContext); + assertEquals(expected, dt.toString()); + } + private Address addr(String address) { return program.getAddressFactory().getAddress(address); } diff --git a/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDMangExtraTest.java b/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDMangExtraTest.java index 0d6f31f058..c54bb6e9bf 100644 --- a/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDMangExtraTest.java +++ b/Ghidra/Features/MicrosoftDmang/src/test/java/mdemangler/MDMangExtraTest.java @@ -22,6 +22,7 @@ import java.util.List; import org.junit.Test; import generic.test.AbstractGenericTest; +import mdemangler.datatype.MDDataType; import mdemangler.naming.MDQualification; import mdemangler.object.MDObjectCPP; import mdemangler.typeinfo.MDVxTable; @@ -136,6 +137,20 @@ public class MDMangExtraTest extends AbstractGenericTest { assertEquals("_anon_FEDCBA98::a", qualifications.get(1).toString()); } + @Test + public void testSimpleDemangleType() throws Exception { + String mangled = ".?AUname0@name1@@"; + String expected = "struct name1::name0"; + + MDMangGhidra demangler = new MDMangGhidra(); + demangler.setMangledSymbol(mangled); + demangler.setErrorOnRemainingChars(true); + MDDataType item = demangler.demangleType(); + + String demangled = item.toString(); + assertEquals(expected, demangled); + } + // Need to test the demangleType() method to make sure it does the retry with LLVM mode @Test public void testDemangleTypeWithRetry() throws Exception {