Browse Source

Add failing CppField test

pull/1/head
Alex Corrado 14 years ago
parent
commit
997f43cd73
  1. 27
      tests/FieldTests.cs
  2. 4
      tests/Makefile.am
  3. 8
      tests/Native/FieldTests.cpp
  4. 7
      tests/Native/FieldTests.h
  5. 5
      tests/Tests.csproj

27
tests/FieldTests.cs

@ -0,0 +1,27 @@
using System;
using NUnit.Framework;
namespace Tests {
[TestFixture]
public class FieldTests {
[Test]
public void TestReadCppObject ()
{
var hf1 = new HasField (1, null);
var hf2 = new HasField (2, hf1);
var hf3 = new HasField (3, hf2);
Assert.IsNull (hf1.other, "#1");
Assert.AreEqual (1, hf1.number);
Assert.AreSame (hf2.other, hf1, "#2");
Assert.AreEqual (1, hf2.other.number);
Assert.AreSame (hf3.other.other, hf1, "#3");
Assert.AreEqual (1, hf3.other.other.number, "#4");
}
}
}

4
tests/Makefile.am

@ -8,9 +8,11 @@ TEST_DLL = $(BUILD_DIR)/Test.dll
NATIVE = \ NATIVE = \
MarshalingTests \ MarshalingTests \
InheritanceTests InheritanceTests \
FieldTests
MANAGED = \ MANAGED = \
FieldTests.cs \
InheritanceTests.cs \ InheritanceTests.cs \
MarshalingTests.cs \ MarshalingTests.cs \
Support/CppNUnitAsserts.cs Support/CppNUnitAsserts.cs

8
tests/Native/FieldTests.cpp

@ -0,0 +1,8 @@
#include "FieldTests.h"
HasField::HasField (int number, HasField* other)
{
this->number = number;
this->other = other;
}

7
tests/Native/FieldTests.h

@ -0,0 +1,7 @@
class HasField {
public:
int number;
HasField* other;
HasField (int number, HasField* other);
};

5
tests/Tests.csproj

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -53,6 +53,7 @@
<Compile Include="Support\CppNUnitAsserts.cs" /> <Compile Include="Support\CppNUnitAsserts.cs" />
<Compile Include="MarshalingTests.cs" /> <Compile Include="MarshalingTests.cs" />
<Compile Include="InheritanceTests.cs" /> <Compile Include="InheritanceTests.cs" />
<Compile Include="FieldTests.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup> <ItemGroup>
@ -73,6 +74,8 @@
<None Include="Native\MarshalingTests.h" /> <None Include="Native\MarshalingTests.h" />
<None Include="Native\InheritanceTests.h" /> <None Include="Native\InheritanceTests.h" />
<None Include="Native\InheritanceTests.cpp" /> <None Include="Native\InheritanceTests.cpp" />
<None Include="Native\FieldTests.h" />
<None Include="Native\FieldTests.cpp" />
</ItemGroup> </ItemGroup>
<ProjectExtensions> <ProjectExtensions>
<MonoDevelop> <MonoDevelop>

Loading…
Cancel
Save