summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Structs.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/efl_mono/Structs.cs')
-rw-r--r--src/tests/efl_mono/Structs.cs269
1 files changed, 234 insertions, 35 deletions
diff --git a/src/tests/efl_mono/Structs.cs b/src/tests/efl_mono/Structs.cs
index dcdea0d757..4a9e7e9018 100644
--- a/src/tests/efl_mono/Structs.cs
+++ b/src/tests/efl_mono/Structs.cs
@@ -165,7 +165,7 @@ class TestStructs
complex.Fslice.Mem = eina.MemoryNative.Alloc(1);
Marshal.WriteByte(complex.Fslice.Mem, 125);
- complex.Fobj = new test.NumberwrapperConcrete();
+ complex.Fobj = new test.Numberwrapper();
complex.Fobj.SetNumber(42);
return complex;
@@ -245,68 +245,267 @@ class TestStructs
checkZeroedStructComplex(complex);
}
+ public static void parameter_initialization()
+ {
+ var simple = new test.StructSimple(0x1, 0x2, (char)0x3, 0x4, 0x5);
+ Test.AssertEquals(0x1, simple.Fbyte);
+ Test.AssertEquals(0x2, simple.Fubyte);
+ Test.AssertEquals(0x3, simple.Fchar);
+ Test.AssertEquals(0x4, simple.Fshort);
+ Test.AssertEquals(0x5, simple.Fushort);
+ Test.AssertEquals(0, simple.Fint);
+ }
+
// As parameters
public static void simple_in()
{
var simple = structSimpleWithValues();
- test.Testing t = new test.TestingConcrete();
+ test.ITesting t = new test.Testing();
bool r = t.StructSimpleIn(simple);
Test.Assert(r, "Function returned false");
}
- // public static void simple_ptr_in()
- // {
- // var simple = structSimpleWithValues();
- // test.Testing t = new test.TestingConcrete();
- // bool r = t.struct_simple_ptr_in(simple);
- // Test.Assert(r, "Function returned false");
- // }
+ public static void simple_ptr_in()
+ {
+ var simple = structSimpleWithValues();
+ int original = simple.Fint;
+ simple.Fmstring = "Struct Ptr In";
+ test.ITesting t = new test.Testing();
+ Test.Assert(t.StructSimplePtrIn(ref simple));
+ Test.AssertEquals(-original, simple.Fint);
+ Test.AssertEquals("nI rtP tcurtS", simple.Fmstring);
+ }
- // public static void simple_ptr_in_own()
- // {
- // var simple = structSimpleWithValues();
- // test.Testing t = new test.TestingConcrete();
- // bool r = t.struct_simple_ptr_in_own(simple);
- // Test.Assert(r, "Function returned false");
- // }
+ public static void simple_ptr_in_own()
+ {
+ var simple = structSimpleWithValues();
+ int original = simple.Fint;
+ simple.Fmstring = "Struct Ptr In Own";
+ test.ITesting t = new test.Testing();
+ test.StructSimple result = t.StructSimplePtrInOwn(ref simple);
+ Test.AssertEquals(-original, result.Fint);
+ Test.AssertEquals("nwO nI rtP tcurtS", result.Fmstring);
+ }
public static void simple_out()
{
var simple = new test.StructSimple();
- test.Testing t = new test.TestingConcrete();
- bool r = t.StructSimpleOut(ref simple);
+ test.ITesting t = new test.Testing();
+ bool r = t.StructSimpleOut(out simple);
Test.Assert(r, "Function returned false");
checkStructSimple(simple);
}
- // public static void simple_ptr_out()
- // {
- // }
+ public static void simple_ptr_out()
+ {
+ test.StructSimple simple;
+ test.ITesting t = new test.Testing();
+ test.StructSimple result = t.StructSimplePtrOut(out simple);
+ Test.AssertEquals(result.Fint, simple.Fint);
+ Test.AssertEquals(result.Fstring, simple.Fstring);
+ }
- // public static void simple_ptr_out_own()
- // {
- // }
+ public static void simple_ptr_out_own()
+ {
+ test.StructSimple simple;
+ test.ITesting t = new test.Testing();
+ test.StructSimple result = t.StructSimplePtrOutOwn(out simple);
+ Test.AssertEquals(result.Fint, simple.Fint);
+ Test.AssertEquals(simple.Fstring, "Ptr Out Own");
+ }
public static void simple_return()
{
- test.Testing t = new test.TestingConcrete();
+ test.ITesting t = new test.Testing();
var simple = t.StructSimpleReturn();
checkStructSimple(simple);
}
- // public static void simple_ptr_return()
- // {
- // }
+ public static void simple_ptr_return()
+ {
+ test.ITesting t = new test.Testing();
+ var simple = t.StructSimplePtrReturn();
+ Test.AssertEquals(simple.Fstring, "Ret Ptr");
+ }
- // public static void simple_ptr_return_own()
- // {
- // }
+ public static void simple_ptr_return_own()
+ {
+ test.ITesting t = new test.Testing();
+ var simple = t.StructSimplePtrReturnOwn();
+ Test.AssertEquals(simple.Fstring, "Ret Ptr Own");
+ }
+
+ public class StructReturner : test.TestingInherit
+ {
+ public test.StructSimple received;
+ public bool called;
+
+ public StructReturner() : base(null)
+ {
+ called = false;
+ received = default(test.StructSimple);
+ }
+
+ public override bool StructSimpleIn(test.StructSimple simple)
+ {
+ called = true;
+ received = simple;
+
+ return true;
+ }
+
+ public override bool StructSimplePtrIn(ref test.StructSimple simple)
+ {
+ called = true;
+ simple.Fstring = "Virtual Struct Ptr In";
+ return true;
+ }
+
+ public override test.StructSimple StructSimplePtrInOwn(ref test.StructSimple simple)
+ {
+ called = true;
+ received = simple;
+ return received;
+ }
+
+ public override bool StructSimpleOut(out test.StructSimple simple) {
+ called = true;
+ simple = new test.StructSimple();
+ simple.Fstring = "Virtual Struct Out";
+ return true;
+ }
+
+ public override test.StructSimple StructSimplePtrOut(out test.StructSimple simple) {
+ called = true;
+ // No way to explicitly define the ownership of the parameter.
+ simple = new test.StructSimple();
+ simple.Fstring = "Virtual Struct Ptr Out";
+ return simple;
+ }
+
+ public override test.StructSimple StructSimplePtrOutOwn(out test.StructSimple simple) {
+ called = true;
+ // No way to explicitly define the ownership of the parameter.
+ simple = new test.StructSimple();
+ simple.Fstring = "Virtual Struct Ptr Out Own";
+ return simple;
+ }
+
+ public override test.StructSimple StructSimpleReturn()
+ {
+ called = true;
+ var simple = new test.StructSimple();
+ simple.Fstring = "Virtual Struct Return";
+ return simple;
+ }
+
+ public override test.StructSimple StructSimplePtrReturn()
+ {
+ called = true;
+ var simple = new test.StructSimple();
+ simple.Fstring = "Virtual Struct Ptr Return";
+ return simple;
+ }
+
+ public override test.StructSimple StructSimplePtrReturnOwn()
+ {
+ called = true;
+ var simple = new test.StructSimple();
+ simple.Fstring = "Virtual Struct Ptr Return Own";
+ return simple;
+ }
+ }
+
+ public static void simple_in_virtual()
+ {
+ StructReturner t = new StructReturner();
+ var simple = structSimpleWithValues();
+ simple.Fstring = "Virtual Struct In";
+
+ t.CallStructSimpleIn(simple);
+ Test.Assert(t.called);
+ Test.AssertEquals(simple.Fstring, t.received.Fstring);
+ }
+
+ public static void simple_ptr_in_virtual()
+ {
+ StructReturner t = new StructReturner();
+ var simple = structSimpleWithValues();
+ string reference = "Virtual Struct Ptr In";
+
+ t.CallStructSimplePtrIn(ref simple);
+ Test.Assert(t.called);
+ Test.AssertEquals(simple.Fstring, reference);
+ }
+
+ public static void simple_ptr_in_own_virtual()
+ {
+ StructReturner t = new StructReturner();
+ var simple = structSimpleWithValues();
+ simple.Fstring = "Virtual Struct Ptr In Own";
+
+ t.CallStructSimplePtrInOwn(ref simple);
+ Test.Assert(t.called);
+ Test.AssertEquals(t.received.Fstring, simple.Fstring);
+ }
+
+ public static void simple_out_virtual()
+ {
+ StructReturner t = new StructReturner();
+ test.StructSimple simple;
+ t.CallStructSimpleOut(out simple);
+ Test.Assert(t.called, "override was not called");
+ Test.AssertEquals("Virtual Struct Out", simple.Fstring);
+ }
+
+ public static void simple_ptr_out_virtual()
+ {
+ StructReturner t = new StructReturner();
+ test.StructSimple simple;
+ t.CallStructSimplePtrOut(out simple);
+ Test.Assert(t.called, "override was not called");
+ Test.AssertEquals("Virtual Struct Ptr Out", simple.Fstring);
+ }
+
+ public static void simple_ptr_out_own_virtual()
+ {
+ StructReturner t = new StructReturner();
+ test.StructSimple simple;
+ t.CallStructSimplePtrOutOwn(out simple);
+ Test.Assert(t.called, "override was not called");
+ Test.AssertEquals("Virtual Struct Ptr Out Own", simple.Fstring);
+ }
+
+ public static void simple_return_virtual()
+ {
+ StructReturner t = new StructReturner();
+ test.StructSimple simple = t.CallStructSimpleReturn();
+ Test.Assert(t.called, "override was not called");
+ Test.AssertEquals("Virtual Struct Return", simple.Fstring);
+ }
+
+ public static void simple_ptr_return_virtual()
+ {
+ StructReturner t = new StructReturner();
+ test.StructSimple simple = t.CallStructSimplePtrReturn();
+ Test.Assert(t.called, "override was not called");
+ Test.AssertEquals("Virtual Struct Ptr Return", simple.Fstring);
+ }
+
+ public static void simple_ptr_return_own_virtual()
+ {
+ StructReturner t = new StructReturner();
+ test.StructSimple simple = t.CallStructSimplePtrReturnOwn();
+ Test.Assert(t.called, "override was not called");
+ Test.AssertEquals("Virtual Struct Ptr Return Own", simple.Fstring);
+ }
+ // Complex Structs
public static void complex_in()
{
var complex = structComplexWithValues();
- test.Testing t = new test.TestingConcrete();
+ test.ITesting t = new test.Testing();
bool r = t.StructComplexIn(complex);
Test.Assert(r, "Function returned false");
}
@@ -322,8 +521,8 @@ class TestStructs
public static void complex_out()
{
var complex = new test.StructComplex();
- test.Testing t = new test.TestingConcrete();
- bool r = t.StructComplexOut(ref complex);
+ test.ITesting t = new test.Testing();
+ bool r = t.StructComplexOut(out complex);
Test.Assert(r, "Function returned false");
checkStructComplex(complex);
}
@@ -338,7 +537,7 @@ class TestStructs
public static void complex_return()
{
- test.Testing t = new test.TestingConcrete();
+ test.ITesting t = new test.Testing();
var complex = t.StructComplexReturn();
checkStructComplex(complex);
}