summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono/Errors.cs
blob: 042e4ae0e4d1d871054def1d2fd7ea33b7340c3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;

namespace TestSuite
{

class TestEinaError
{
    public static void basic_test()
    {
        eina.Error.Clear();
        Test.AssertNotRaises<efl.EflException>(eina.Error.RaiseIfOcurred);
        eina.Error.Set(eina.Error.ENOENT);
        Test.AssertRaises<efl.EflException>(eina.Error.RaiseIfOcurred);
    }
}

class TestEolianError
{

    public static void global_eina_error()
    {
        test.Testing obj = new test.TestingConcrete();
        Test.AssertRaises<efl.EflException>(() => obj.raises_eina_error());
    }

    class Child : test.TestingInherit {
    }

    public static void global_eina_error_inherited()
    {
        test.Testing obj = new Child();
        Test.AssertRaises<efl.EflException>(() => obj.raises_eina_error());
    }

    class CustomException : Exception {
        public CustomException(string msg): base(msg) {}
    }

    class Overrider : test.TestingInherit {
        public override void children_raise_error() {
            throw (new CustomException("Children error"));
        }
    }

    public static void exception_raised_from_inherited_virtual()
    {
        test.Testing obj = new Overrider();

        Test.AssertRaises<efl.EflException>(obj.call_children_raise_error);
    }

    // return eina_error
    public static void eina_error_return()
    {
        test.Testing obj = new test.TestingConcrete();
        eina.Error expected = 42;
        obj.error_ret_set(expected);
        eina.Error error = obj.returns_error();

        Test.AssertEquals(expected, error);

        expected = 0;
        obj.error_ret_set(expected);
        error = obj.returns_error();

        Test.AssertEquals(expected, error);
    }

    class ReturnOverride : test.TestingInherit {
        eina.Error code;
        public override void error_ret_set(eina.Error err) {
            code = 2 * err;
        }
        public override eina.Error returns_error()
        {
            return code;
        }
    }

    public static void eina_error_return_from_inherited_virtual()
    {
        test.Testing obj = new ReturnOverride();
        eina.Error expected = 42;
        obj.error_ret_set(expected);
        eina.Error error = obj.returns_error();

        Test.AssertEquals(new eina.Error(expected * 2), error);

        expected = 0;
        obj.error_ret_set(expected);
        error = obj.returns_error();

        Test.AssertEquals(new eina.Error(expected * 2), error);
    }

    // events
    // virtual callbacks
}
}