diff --git a/tests/Basic/Basic.Tests.cs b/tests/Basic/Basic.Tests.cs index e9fd6e1d..cdec7817 100644 --- a/tests/Basic/Basic.Tests.cs +++ b/tests/Basic/Basic.Tests.cs @@ -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] diff --git a/tests/Basic/Basic.h b/tests/Basic/Basic.h index 3a60dcfd..574dd5a7 100644 --- a/tests/Basic/Basic.h +++ b/tests/Basic/Basic.h @@ -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) {} 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