Skip to content

Commit 76ef6b0

Browse files
committed
Add a test for passing by value of structs with copy ctors.
1 parent 3eee343 commit 76ef6b0

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

tests/Common/Common.Tests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,4 +896,13 @@ public void TestReturnChar16()
896896
Assert.That(foo.ReturnChar16(), Is.EqualTo('a'));
897897
}
898898
}
899+
900+
[Test, Ignore("Indirect parameters not supported yet")]
901+
public void TestStructWithCopyCtorByValue()
902+
{
903+
var structWithCopyCtor = new StructWithCopyCtor();
904+
structWithCopyCtor.MBits = 10;
905+
var ret = Common.TestStructWithCopyCtorByValue(structWithCopyCtor);
906+
Assert.That(ret, Is.EqualTo(10));
907+
}
899908
}

tests/Common/Common.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,3 +1048,11 @@ void overloadPointer(void* p, int i)
10481048
void overloadPointer(const void* p, int i)
10491049
{
10501050
}
1051+
1052+
StructWithCopyCtor::StructWithCopyCtor() {}
1053+
StructWithCopyCtor::StructWithCopyCtor(const StructWithCopyCtor& other) : mBits(other.mBits) {}
1054+
1055+
uint16_t TestStructWithCopyCtorByValue(StructWithCopyCtor s)
1056+
{
1057+
return s.mBits;
1058+
}

tests/Common/Common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,3 +1508,12 @@ DLL_API void takeReferenceToVoidStar(const void*& p);
15081508
DLL_API void takeVoidStarStar(void** p);
15091509
DLL_API void overloadPointer(void* p, int i = 0);
15101510
DLL_API void overloadPointer(const void* p, int i = 0);
1511+
1512+
struct DLL_API StructWithCopyCtor
1513+
{
1514+
StructWithCopyCtor();
1515+
StructWithCopyCtor(const StructWithCopyCtor& other);
1516+
uint16_t mBits;
1517+
};
1518+
1519+
uint16_t DLL_API TestStructWithCopyCtorByValue(StructWithCopyCtor s);

0 commit comments

Comments
 (0)