mirror of https://github.com/mono/CppSharp.git
2 changed files with 0 additions and 157 deletions
@ -1,106 +0,0 @@
@@ -1,106 +0,0 @@
|
||||
using CppSharp.AST; |
||||
using CppSharp.Generators.CLI; |
||||
using CppSharp.Types; |
||||
using NUnit.Framework; |
||||
|
||||
namespace CppSharp.Generator.Tests |
||||
{ |
||||
[TypeMap("FnPtr3")] |
||||
public class CLITypePrinterTypeMap : TypeMap |
||||
{ |
||||
public override string CLISignature(CLITypePrinterContext ctx) |
||||
{ |
||||
return "TypedefFn3"; |
||||
} |
||||
} |
||||
|
||||
[TestFixture] |
||||
public class CLITypePrinterTest : HeaderTestFixture |
||||
{ |
||||
CLITypePrinter printer; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void Init() |
||||
{ |
||||
ParseLibrary("CLITypes.h"); |
||||
printer = new CLITypePrinter(Driver, new CLITypePrinterContext()); |
||||
} |
||||
|
||||
public void CheckType<T>(T decl, string check) where T : ITypedDecl |
||||
{ |
||||
var type = decl.Type.Visit(printer); |
||||
Assert.That(type, Is.EqualTo(check)); |
||||
} |
||||
|
||||
public void CheckDecl<T>(T decl, string check) where T : Declaration |
||||
{ |
||||
var output = decl.Visit(printer); |
||||
Assert.That(output, Is.EqualTo(check)); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestPrimitive() |
||||
{ |
||||
var p = AstContext.Class("Primitives"); |
||||
CheckType(p.Field("B"), "bool"); |
||||
CheckType(p.Field("C"), "char"); |
||||
CheckType(p.Field("UC"), "unsigned char"); |
||||
CheckType(p.Field("S"), "short"); |
||||
CheckType(p.Field("US"), "unsigned short"); |
||||
CheckType(p.Field("I"), "int"); |
||||
CheckType(p.Field("UI"), "unsigned int"); |
||||
CheckType(p.Field("L"), "int"); |
||||
CheckType(p.Field("UL"), "unsigned int"); |
||||
CheckType(p.Field("LL"), "long long"); |
||||
CheckType(p.Field("ULL"), "unsigned long long"); |
||||
|
||||
CheckType(p.Field("F"), "float"); |
||||
CheckType(p.Field("D"), "double"); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestArray() |
||||
{ |
||||
var c = AstContext.Class("Arrays"); |
||||
CheckType(c.Field("Array"), "cli::array<float>^"); |
||||
CheckType(c.Field("Prim"), "cli::array<::Primitives^>^"); |
||||
|
||||
} |
||||
|
||||
[Test] |
||||
public void TestPointers() |
||||
{ |
||||
var p = AstContext.Class("Pointers"); |
||||
CheckType(p.Field("pv"), "System::IntPtr"); |
||||
CheckType(p.Field("pc"), "System::IntPtr"); |
||||
CheckType(p.Field("puc"), "System::IntPtr"); |
||||
CheckType(p.Field("cpc"), "System::String^"); |
||||
CheckType(p.Field("pi"), "System::IntPtr"); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestFunctionPointers() |
||||
{ |
||||
var p = AstContext.Class("FunctionPointers"); |
||||
CheckType(p.Field("fn"), "::FnPtr^"); |
||||
CheckType(p.Field("fn2"), "::FnPtr2^"); |
||||
CheckType(p.Field("fn3"), "::FnPtr3^"); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestTypedefs() |
||||
{ |
||||
CheckType(AstContext.Typedef("FnPtr"), "System::Func<int, double>^"); |
||||
CheckType(AstContext.Typedef("FnPtr2"), "System::Action<char, float>^"); |
||||
CheckType(AstContext.Typedef("FnPtr3"), "System::Action^"); |
||||
} |
||||
|
||||
[Test] |
||||
public void TestTags() |
||||
{ |
||||
var p = AstContext.Class("Tag"); |
||||
CheckType(p.Field("p"), "::Primitives^"); |
||||
CheckType(p.Field("e"), "::E"); |
||||
} |
||||
} |
||||
} |
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
struct Primitives |
||||
{ |
||||
bool B; |
||||
char C; |
||||
unsigned char UC; |
||||
short S; |
||||
unsigned short US; |
||||
int I; |
||||
unsigned int UI; |
||||
long L; |
||||
unsigned long UL; |
||||
long long LL; |
||||
unsigned long long ULL; |
||||
float F; |
||||
double D; |
||||
}; |
||||
|
||||
struct Arrays |
||||
{ |
||||
float Array[2]; |
||||
Primitives Prim[1]; |
||||
}; |
||||
|
||||
struct Pointers |
||||
{ |
||||
void * pv; |
||||
char * pc; |
||||
unsigned char * puc; |
||||
const char * cpc; |
||||
int * pi; |
||||
}; |
||||
|
||||
typedef int (*FnPtr)(double); |
||||
typedef void (*FnPtr2)(char, float); |
||||
typedef void (*FnPtr3)(void); |
||||
|
||||
struct FunctionPointers |
||||
{ |
||||
FnPtr fn; |
||||
FnPtr2 fn2; |
||||
FnPtr3 fn3; |
||||
}; |
||||
|
||||
enum E { E1, E2 }; |
||||
|
||||
struct Tag |
||||
{ |
||||
Primitives p; |
||||
E e; |
||||
}; |
||||
|
Loading…
Reference in new issue