Browse Source

Added EnumInOut tests.

pull/269/merge
Tom Spilman 12 years ago committed by triton
parent
commit
9159e531f4
  1. 30
      tests/Basic/Basic.Tests.cs
  2. 12
      tests/Basic/Basic.cpp
  3. 2
      tests/Basic/Basic.cs
  4. 9
      tests/Basic/Basic.h

30
tests/Basic/Basic.Tests.cs

@ -116,6 +116,26 @@ public class BasicTests : GeneratorTestFixture @@ -116,6 +116,26 @@ public class BasicTests : GeneratorTestFixture
Assert.That(e, Is.EqualTo(Enum.C));
}
[Test]
public void TestEnumInOut()
{
var hello = new Hello();
var e = Enum.E;
hello.EnumInOut(ref e);
Assert.That(e, Is.EqualTo(Enum.F));
}
[Test]
public void TestEnumInOutRef()
{
var hello = new Hello();
var e = Enum.E;
hello.EnumInOut(ref e);
Assert.That(e, Is.EqualTo(Enum.F));
}
[Test]
public void TestNullRef()
{
@ -368,15 +388,5 @@ public class BasicTests : GeneratorTestFixture @@ -368,15 +388,5 @@ public class BasicTests : GeneratorTestFixture
var ret = basic.TestNullPtrTypeRet();
Assert.AreEqual(IntPtr.Zero, new IntPtr(ret));
}
[Test]
public void TestValueTypeInheritance()
{
var bar2 = new Bar2 { A = 24 };
Assert.That(bar2.RetItem1(), Is.EqualTo(Bar.Item.Item1));
Assert.That(bar2.returnPointerToValueType().A, Is.EqualTo(24));
var inheritTestIndexedPropertiesInValueType = new InheritTestIndexedPropertiesInValueType();
Assert.That(inheritTestIndexedPropertiesInValueType[2], Is.EqualTo(2));
}
}

12
tests/Basic/Basic.cpp

@ -191,6 +191,18 @@ void Hello::EnumOutRef(int value, CS_OUT Enum& e) @@ -191,6 +191,18 @@ void Hello::EnumOutRef(int value, CS_OUT Enum& e)
e = (Enum)value;
}
void Hello::EnumInOut(CS_IN_OUT Enum* e)
{
if (*e == Enum::E)
*e = Enum::F;
}
void Hello::EnumInOutRef(CS_IN_OUT Enum& e)
{
if (e == Enum::E)
e = Enum::F;
}
int unsafeFunction(const Bar& ret, char* testForString, void (*foo)(int))
{
return ret.A;

2
tests/Basic/Basic.cs

@ -35,6 +35,8 @@ namespace CppSharp.Tests @@ -35,6 +35,8 @@ namespace CppSharp.Tests
ctx.SetMethodParameterUsage("Hello", "TestPrimitiveInOutRef", 1, ParameterUsage.InOut);
ctx.SetMethodParameterUsage("Hello", "EnumOut", 2, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "EnumOutRef", 2, ParameterUsage.Out);
ctx.SetMethodParameterUsage("Hello", "EnumInOut", 1, ParameterUsage.InOut);
ctx.SetMethodParameterUsage("Hello", "EnumInOutRef", 1, ParameterUsage.InOut);
}
public static void Main(string[] args)

9
tests/Basic/Basic.h

@ -129,6 +129,9 @@ public: @@ -129,6 +129,9 @@ public:
void EnumOut(int value, CS_OUT Enum* e);
void EnumOutRef(int value, CS_OUT Enum& e);
void EnumInOut(CS_IN_OUT Enum* e);
void EnumInOutRef(CS_IN_OUT Enum& e);
};
class DLL_API AbstractFoo
@ -433,7 +436,7 @@ const foo_t& TestIndexedProperties::operator[](double f) { return p; } @@ -433,7 +436,7 @@ const foo_t& TestIndexedProperties::operator[](double f) { return p; }
TestProperties* TestIndexedProperties::operator[](unsigned char b) { return &f; }
const TestProperties& TestIndexedProperties::operator[](short b) { return f; }
struct DLL_API CS_VALUETYPE TestIndexedPropertiesInValueType
struct DLL_API TestIndexedPropertiesInValueType
{
public:
int operator[](int i);
@ -441,10 +444,6 @@ public: @@ -441,10 +444,6 @@ public:
int TestIndexedPropertiesInValueType::operator[](int i) { return i; }
struct DLL_API CS_VALUETYPE InheritTestIndexedPropertiesInValueType : public TestIndexedPropertiesInValueType
{
};
enum struct MyEnum { A, B, C };
class DLL_API TestArraysPointers

Loading…
Cancel
Save