Browse Source

Moved the tests for copy ctors to separate classes.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/203/head
Dimitar Dobrev 11 years ago
parent
commit
7477b90023
  1. 1
      src/Generator/Passes/CheckStaticClass.cs
  2. 8
      tests/Basic/Basic.Tests.cs
  3. 16
      tests/Basic/Basic.cpp
  4. 10
      tests/Basic/Basic.h
  5. 9
      tests/CSharpTemp/CSharpTemp.Tests.cs
  6. 12
      tests/CSharpTemp/CSharpTemp.cpp
  7. 5
      tests/CSharpTemp/CSharpTemp.cs
  8. 9
      tests/CSharpTemp/CSharpTemp.h

1
src/Generator/Passes/CheckStaticClass.cs

@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
using System.Linq;
using System.Threading;
using CppSharp.AST;
namespace CppSharp.Passes

8
tests/Basic/Basic.Tests.cs

@ -202,10 +202,10 @@ public class BasicTests : GeneratorTestFixture @@ -202,10 +202,10 @@ public class BasicTests : GeneratorTestFixture
Assert.That(foo.A, Is.EqualTo(copyFoo.A));
Assert.That(foo.B, Is.EqualTo(copyFoo.B));
Bar bar = new Bar { A = 10, B = 5 };
var copyBar = new Bar(bar);
Assert.That(bar.A, Is.EqualTo(copyBar.A));
Assert.That(bar.B, Is.EqualTo(copyBar.B));
var testCopyConstructorRef = new TestCopyConstructorRef { A = 10, B = 5 };
var copyBar = new TestCopyConstructorRef(testCopyConstructorRef);
Assert.That(testCopyConstructorRef.A, Is.EqualTo(copyBar.A));
Assert.That(testCopyConstructorRef.B, Is.EqualTo(copyBar.B));
}
}

16
tests/Basic/Basic.cpp

@ -27,12 +27,6 @@ Bar::Bar() @@ -27,12 +27,6 @@ Bar::Bar()
{
}
Bar::Bar(const Bar& bar)
{
A = bar.A;
B = bar.B;
}
Bar::Item Bar::RetItem1()
{
return Bar::Item1;
@ -223,3 +217,13 @@ Bar::Item operator |(Bar::Item left, Bar::Item right) @@ -223,3 +217,13 @@ Bar::Item operator |(Bar::Item left, Bar::Item right)
{
return left | right;
}
TestCopyConstructorRef::TestCopyConstructorRef()
{
}
TestCopyConstructorRef::TestCopyConstructorRef(const TestCopyConstructorRef& other)
{
A = other.A;
B = other.B;
}

10
tests/Basic/Basic.h

@ -28,7 +28,6 @@ struct DLL_API Bar @@ -28,7 +28,6 @@ struct DLL_API Bar
};
Bar();
Bar(const Bar& bar);
Item RetItem1();
int A;
float B;
@ -279,3 +278,12 @@ class DependentTypeWithNestedIndependent @@ -279,3 +278,12 @@ class DependentTypeWithNestedIndependent
long l;
};
};
class DLL_API TestCopyConstructorRef
{
public:
TestCopyConstructorRef();
TestCopyConstructorRef(const TestCopyConstructorRef& other);
int A;
float B;
};

9
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -107,4 +107,13 @@ public class CSharpTempTests : GeneratorTestFixture @@ -107,4 +107,13 @@ public class CSharpTempTests : GeneratorTestFixture
bar.ArrayOfPrimitivePointers = array;
Assert.That(i, Is.EqualTo(*(int*) bar.ArrayOfPrimitivePointers[0]));
}
[Test]
public void TestCopyConstructorValue()
{
var testCopyConstructorVal = new TestCopyConstructorVal { A = 10, B = 5 };
var copyBar = new TestCopyConstructorVal(testCopyConstructorVal);
Assert.That(testCopyConstructorVal.A, Is.EqualTo(copyBar.A));
Assert.That(testCopyConstructorVal.B, Is.EqualTo(copyBar.B));
}
}

12
tests/CSharpTemp/CSharpTemp.cpp

@ -190,4 +190,14 @@ void P::setIsBool(bool value) @@ -190,4 +190,14 @@ void P::setIsBool(bool value)
}
int TestDestructors::Marker = 0;
int TestDestructors::Marker = 0;
TestCopyConstructorVal::TestCopyConstructorVal()
{
}
TestCopyConstructorVal::TestCopyConstructorVal(const TestCopyConstructorVal& other)
{
A = other.A;
B = other.B;
}

5
tests/CSharpTemp/CSharpTemp.cs

@ -64,6 +64,11 @@ namespace CppSharp.Tests @@ -64,6 +64,11 @@ namespace CppSharp.Tests
driver.TranslationUnitPasses.AddPass(new TestAttributesPass());
}
public override void Preprocess(Driver driver, ASTContext ctx)
{
ctx.SetClassAsValueType("TestCopyConstructorVal");
}
public override void Postprocess(Driver driver, ASTContext lib)
{
new CaseRenamePass(

9
tests/CSharpTemp/CSharpTemp.h

@ -138,3 +138,12 @@ struct DLL_API TestDestructors @@ -138,3 +138,12 @@ struct DLL_API TestDestructors
TestDestructors() { Marker = 0xf00d; }
~TestDestructors() { Marker = 0xcafe; }
};
class DLL_API TestCopyConstructorVal
{
public:
TestCopyConstructorVal();
TestCopyConstructorVal(const TestCopyConstructorVal& other);
int A;
float B;
};

Loading…
Cancel
Save