Browse Source

Added tests for out enums.

pull/268/head
Tom Spilman 12 years ago
parent
commit
5e63406de0
  1. 22
      tests/Basic/Basic.Tests.cs
  2. 10
      tests/Basic/Basic.cpp
  3. 2
      tests/Basic/Basic.cs
  4. 3
      tests/Basic/Basic.h

22
tests/Basic/Basic.Tests.cs

@ -77,6 +77,28 @@ public class BasicTests : GeneratorTestFixture
Assert.That(f, Is.EqualTo(10.0f)); Assert.That(f, Is.EqualTo(10.0f));
} }
[Test]
public void TestEnumOut()
{
var hello = new Hello();
int value = (int)Enum.C;
Enum e;
hello.EnumOut(value, out e);
Assert.That(e, Is.EqualTo(value));
}
[Test]
public void TestEnumOutRef()
{
var hello = new Hello();
int value = (int)Enum.C;
Enum e;
hello.EnumOutRef(value, out e);
Assert.That(e, Is.EqualTo(value));
}
[Test] [Test]
public void TestNullRef() public void TestNullRef()
{ {

10
tests/Basic/Basic.cpp

@ -169,6 +169,16 @@ bool Hello::TestPrimitiveOutRef(CS_OUT float& f)
return true; return true;
} }
void Hello::EnumOut(int value, CS_OUT Enum* e)
{
*e = (Enum)value;
}
void Hello::EnumOutRef(int value, CS_OUT Enum& e)
{
e = (Enum)value;
}
int unsafeFunction(const Bar& ret, char* testForString, void (*foo)(int)) int unsafeFunction(const Bar& ret, char* testForString, void (*foo)(int))
{ {
return ret.A; return ret.A;

2
tests/Basic/Basic.cs

@ -31,6 +31,8 @@ namespace CppSharp.Tests
ctx.SetClassAsValueType("Bar2"); ctx.SetClassAsValueType("Bar2");
ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOut", 1, ParameterUsage.Out); ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOut", 1, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOutRef", 1, ParameterUsage.Out); ctx.SetMethodParameterUsage("Hello", "TestPrimitiveOutRef", 1, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "EnumOut", 2, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "EnumOutRef", 2, ParameterUsage.Out);
} }
public static void Main(string[] args) public static void Main(string[] args)

3
tests/Basic/Basic.h

@ -123,6 +123,9 @@ public:
bool TestPrimitiveOut(CS_OUT float* f); bool TestPrimitiveOut(CS_OUT float* f);
bool TestPrimitiveOutRef(CS_OUT float& f); bool TestPrimitiveOutRef(CS_OUT float& f);
void EnumOut(int value, CS_OUT Enum* e);
void EnumOutRef(int value, CS_OUT Enum& e);
}; };
class DLL_API AbstractFoo class DLL_API AbstractFoo

Loading…
Cancel
Save