aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/csharp/li_std_wstring_runme.cs
blob: 501ab84968fb9d04e225aa1b5ba1b3efa104c6cc (plain)
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
using System;
using li_std_wstringNamespace;

public class runme
{
    static private void check_equal(char a, char b)
    {
      if (a != b)
        throw new Exception("failed " + a + " " + b);
    }

    static private void check_equal(string a, string b)
    {
      if (a != b)
        throw new Exception("failed " + a + " " + b);
    }

    static void Main() 
    {
        char h = 'h';
        check_equal(li_std_wstring.test_wcvalue(h), h);

        string x = "abc";
        check_equal(li_std_wstring.test_ccvalue(x), x);
        check_equal(li_std_wstring.test_cvalue(x), x);

        check_equal(li_std_wstring.test_wchar_overload(x), x);
        check_equal(li_std_wstring.test_wchar_overload(), null);

        li_std_wstring.test_pointer(null);
        li_std_wstring.test_const_pointer(null);

        try {
            li_std_wstring.test_value(null);
            throw new Exception("NULL check failed");
        } catch (ArgumentNullException) {
        }

        try {
              li_std_wstring.test_reference(null);
              throw new Exception("NULL check failed");
        } catch (ArgumentNullException e) {
            if (!e.Message.Contains("type is null"))
                throw new Exception("Missing text " + e);
        }
        try {
            li_std_wstring.test_const_reference(null);
            throw new Exception("NULL check failed");
        } catch (ArgumentNullException e) {
            if (!e.Message.Contains("null wstring"))
                throw new Exception("Missing text " + e);
        }

        x = "hello";
        check_equal(li_std_wstring.test_const_reference(x), x);

        /* TODO
        string s = "abc";
        if (!li_std_wstring.test_equal_abc(s))
            throw new Exception("Not equal " + s);

        try {
            li_std_wstring.test_throw();
        } catch (Exception e) {
            check_equal(e.Message, "throwing test_throw");
        }

        x = "abc\0def";
        check_equal(li_std_wstring.test_value(x), x);
        check_equal(li_std_wstring.test_ccvalue(x), "abc");
        check_equal(li_std_wstring.test_wchar_overload(x), "abc");
        */

    }
}