Browse Source

Added unit test for in/out for primitive parameters.

pull/267/head
Tom Spilman 11 years ago
parent
commit
51fa468cfa
  1. 20
      tests/Basic/Basic.Tests.cs
  2. 12
      tests/Basic/Basic.cpp
  3. 2
      tests/Basic/Basic.cs
  4. 3
      tests/Basic/Basic.h
  5. 1
      tests/Tests.h

20
tests/Basic/Basic.Tests.cs

@ -77,6 +77,26 @@ public class BasicTests : GeneratorTestFixture @@ -77,6 +77,26 @@ public class BasicTests : GeneratorTestFixture
Assert.That(f, Is.EqualTo(10.0f));
}
[Test]
public void TestPrimitiveInOutParameters()
{
var hello = new Hello();
int i = 10;
Assert.That(hello.TestPrimitiveInOut(ref i), Is.True);
Assert.That(i, Is.EqualTo(20));
}
[Test]
public void TestPrimitiveInOutRefParameters()
{
var hello = new Hello();
int i = 10;
Assert.That(hello.TestPrimitiveInOutRef(ref i), Is.True);
Assert.That(i, Is.EqualTo(20));
}
[Test]
public void TestNullRef()
{

12
tests/Basic/Basic.cpp

@ -169,6 +169,18 @@ bool Hello::TestPrimitiveOutRef(CS_OUT float& f) @@ -169,6 +169,18 @@ bool Hello::TestPrimitiveOutRef(CS_OUT float& f)
return true;
}
bool Hello::TestPrimitiveInOut(CS_IN_OUT int* i)
{
*i += 10;
return true;
}
bool Hello::TestPrimitiveInOutRef(CS_IN_OUT int& i)
{
i += 10;
return true;
}
int unsafeFunction(const Bar& ret, char* testForString, void (*foo)(int))
{
return ret.A;

2
tests/Basic/Basic.cs

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

3
tests/Basic/Basic.h

@ -123,6 +123,9 @@ public: @@ -123,6 +123,9 @@ public:
bool TestPrimitiveOut(CS_OUT float* f);
bool TestPrimitiveOutRef(CS_OUT float& f);
bool TestPrimitiveInOut(CS_IN_OUT int* i);
bool TestPrimitiveInOutRef(CS_IN_OUT int& i);
};
class DLL_API AbstractFoo

1
tests/Tests.h

@ -23,3 +23,4 @@ @@ -23,3 +23,4 @@
#endif
#define CS_OUT
#define CS_IN_OUT
Loading…
Cancel
Save