Browse Source

Add a test for passing by value of structs with copy ctors.

pull/1211/head
Joao Matos 6 years ago committed by João Matos
parent
commit
76ef6b046e
  1. 9
      tests/Common/Common.Tests.cs
  2. 8
      tests/Common/Common.cpp
  3. 9
      tests/Common/Common.h

9
tests/Common/Common.Tests.cs

@ -896,4 +896,13 @@ This is a very long string. This is a very long string. This is a very long stri @@ -896,4 +896,13 @@ This is a very long string. This is a very long string. This is a very long stri
Assert.That(foo.ReturnChar16(), Is.EqualTo('a'));
}
}
[Test, Ignore("Indirect parameters not supported yet")]
public void TestStructWithCopyCtorByValue()
{
var structWithCopyCtor = new StructWithCopyCtor();
structWithCopyCtor.MBits = 10;
var ret = Common.TestStructWithCopyCtorByValue(structWithCopyCtor);
Assert.That(ret, Is.EqualTo(10));
}
}

8
tests/Common/Common.cpp

@ -1048,3 +1048,11 @@ void overloadPointer(void* p, int i) @@ -1048,3 +1048,11 @@ void overloadPointer(void* p, int i)
void overloadPointer(const void* p, int i)
{
}
StructWithCopyCtor::StructWithCopyCtor() {}
StructWithCopyCtor::StructWithCopyCtor(const StructWithCopyCtor& other) : mBits(other.mBits) {}
uint16_t TestStructWithCopyCtorByValue(StructWithCopyCtor s)
{
return s.mBits;
}

9
tests/Common/Common.h

@ -1508,3 +1508,12 @@ DLL_API void takeReferenceToVoidStar(const void*& p); @@ -1508,3 +1508,12 @@ DLL_API void takeReferenceToVoidStar(const void*& p);
DLL_API void takeVoidStarStar(void** p);
DLL_API void overloadPointer(void* p, int i = 0);
DLL_API void overloadPointer(const void* p, int i = 0);
struct DLL_API StructWithCopyCtor
{
StructWithCopyCtor();
StructWithCopyCtor(const StructWithCopyCtor& other);
uint16_t mBits;
};
uint16_t DLL_API TestStructWithCopyCtorByValue(StructWithCopyCtor s);

Loading…
Cancel
Save