private void VerifyPrint(ParseResult result, int index, string str) { Assert.NotNull(result); string realStr = SymbolPrinter.Convert(result.ParsedTypes[index]); Assert.Equal(str, realStr); }
public void BagSaveAndLoad1() { NativeProcedure p1 = new NativeProcedure("p1"); p1.Signature.ReturnType = new NativeBuiltinType(BuiltinType.NativeBoolean); NativeTypeDef td = new NativeTypeDef("LPWSTR", new NativePointer(BuiltinType.NativeWChar)); p1.Signature.Parameters.Add(new NativeParameter("param1", new NativeNamedType("LPWSTR", td))); Assert.Equal("boolean p1(LPWSTR param1)", p1.DisplayName); Assert.Equal("p1(Sig(boolean)(Sal)(param1(LPWSTR(LPWSTR(*(wchar))))(Sal)))", SymbolPrinter.Convert(p1)); var ns = new BasicSymbolStorage(); ns.AddProcedure(p1); ns.AddTypeDef(td); NativeSymbolBag bag = new NativeSymbolBag(ns); NativeProcedure ret1 = null; Assert.True(bag.TryGetGlobalSymbol("p1", out ret1)); bag.AddProcedure(ret1); Assert.True(bag.TryResolveSymbolsAndValues()); Assert.Equal(SymbolPrinter.Convert(p1), SymbolPrinter.Convert(ret1)); }
public void Typedef4() { ParseResult result = ParseFile("SampleFiles\\TypeDef4.txt"); Assert.Equal("foo1(int)", SymbolPrinter.Convert(result.NativeTypeDefs[0])); Assert.Equal("foo2(*(int))", SymbolPrinter.Convert(result.NativeTypeDefs[1])); Assert.Equal("LPWSTR(*(wchar))", SymbolPrinter.Convert(result.NativeTypeDefs[2])); Assert.Equal("FOO(*(wchar))", SymbolPrinter.Convert(result.NativeTypeDefs[3])); }
private void TestRoundTrip(INativeSymbolLookup lookup) { foreach (var util in _utilList) { util.Write(lookup); var storage = util.Read(); foreach (var name in lookup.NativeNames) { if (name.Kind == NativeNameKind.EnumValue) { continue; } var symbol = lookup.GetGlobalSymbol(name); NativeGlobalSymbol other; if (!storage.TryGetGlobalSymbol(name, out other)) { } Assert.True(storage.TryGetGlobalSymbol(name, out other)); Assert.Equal(SymbolPrinter.Convert(symbol.Symbol), SymbolPrinter.Convert(other.Symbol)); } } }
public void Complex1() { ParseResult result = FullParseFile("SampleFiles\\Complex1.txt"); VerifyPrint(result, 0, "LPWSTR(*(wchar))"); Assert.Equal(SymbolPrinter.Convert(result.NativeProcedures[0]), "p1(Sig(void)(Sal)(foo(LPWSTR)(Sal)))"); }
public void Typedef9() { ParseResult result = ParseFile("SampleFiles\\TypeDef9.txt"); Assert.Equal("td1(char)", SymbolPrinter.Convert(result.NativeTypeDefs[0])); Assert.Equal("td2(char)", SymbolPrinter.Convert(result.NativeTypeDefs[1])); }
public void Typedef8() { ParseResult result = ParseFile("SampleFiles\\TypeDef8.txt"); Assert.Equal("f1(f1(Sig(int)(Sal)))", SymbolPrinter.Convert(result.NativeTypeDefs[0])); Assert.Equal("f2(f2(Sig(*(int))(Sal)(param1(int)(Sal))))", SymbolPrinter.Convert(result.NativeTypeDefs[1])); }
public void Typedef7() { ParseResult result = ParseFile("SampleFiles\\TypeDef7.txt"); Assert.Equal("s1(_s1(m1(int)))", SymbolPrinter.Convert(result.NativeTypeDefs[0])); }
public void Typedef6() { ParseResult result = ParseFile("SampleFiles\\TypeDef6.txt"); Assert.Equal("intarray([](int))", SymbolPrinter.Convert(result.NativeTypeDefs[0])); Assert.Equal("chararray([](char))", SymbolPrinter.Convert(result.NativeTypeDefs[1])); }
public void Typedef5() { ParseResult result = ParseFile("SampleFiles\\TypeDef5.txt"); Assert.Equal("CINT(int(int))", SymbolPrinter.Convert(result.NativeTypeDefs[0])); Assert.Equal("LPCSTR(*(WCHAR))", SymbolPrinter.Convert(result.NativeTypeDefs[1])); }