Browse Source

Cleaned up tests regarding indexed properties.

pull/233/head
Elias Holzer 11 years ago
parent
commit
7478c5329e
  1. 10
      tests/Basic/Basic.Tests.cs
  2. 21
      tests/Basic/Basic.h

10
tests/Basic/Basic.Tests.cs

@ -238,11 +238,11 @@ public class BasicTests : GeneratorTestFixture @@ -238,11 +238,11 @@ public class BasicTests : GeneratorTestFixture
[Test]
public unsafe void TestIndexers()
{
var someStruct = new SomeStruct();
Assert.That(someStruct[0], Is.EqualTo(1));
Assert.That(someStruct["foo"], Is.EqualTo(1));
someStruct[0] = 2;
Assert.That(someStruct[0], Is.EqualTo(2));
var properties = new TestIndexedProperties();
Assert.AreEqual(1, properties[0]);
Assert.AreEqual(1, properties["foo"]);
properties[0] = 2;
Assert.AreEqual(2, properties[0]);
}
[Test]

21
tests/Basic/Basic.h

@ -336,17 +336,11 @@ typedef unsigned long foo_t; @@ -336,17 +336,11 @@ typedef unsigned long foo_t;
typedef struct DLL_API SomeStruct
{
SomeStruct();
foo_t& operator[](int i);
// CSharp backend can't deal with a setter here
foo_t operator[](const char* name);
foo_t p;
} SomeStruct;
SomeStruct::SomeStruct() : p(1) {}
foo_t& SomeStruct::operator[](int i) { return p; }
foo_t SomeStruct::operator[](const char* name) { return p; }
class DLL_API SomeClassExtendingTheStruct : public SomeStruct
{
};
@ -396,6 +390,21 @@ TestProperties::TestProperties() : Field(0) {} @@ -396,6 +390,21 @@ TestProperties::TestProperties() : Field(0) {}
int TestProperties::getFieldValue() { return Field; }
void TestProperties::setFieldValue(int Value) { Field = Value; }
class DLL_API TestIndexedProperties
{
foo_t p;
public:
TestIndexedProperties();
// Should lead to a read/write indexer with return type uint
foo_t& operator[](int i);
// Should lead to a read-only indexer with return type uint
foo_t operator[](const char* name);
};
TestIndexedProperties::TestIndexedProperties() : p(1) {}
foo_t& TestIndexedProperties::operator[](int i) { return p; }
foo_t TestIndexedProperties::operator[](const char* name) { return p; }
enum struct MyEnum { A, B, C };
class DLL_API TestArraysPointers

Loading…
Cancel
Save