summaryrefslogtreecommitdiff
path: root/objective-c/test/Ice/defaultValue/AllTests.m
blob: fa05cf5bdaf3f99827a292bf25affaad6f8f6202 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#import <objc/Ice.h>
#import <TestCommon.h>
#import <DefaultValueTest.h>

#import <Foundation/Foundation.h>

void
defaultValueAllTests()
{
    tprintf("testing default values... ");

    {
        TestDefaultValueStruct1* v = [TestDefaultValueStruct1 struct1];
        test(!v.boolFalse);
        test(v.boolTrue);
        test(v.b == 254);
        test(v.s == 16000);
        test(v.i == 3);
        test(v.l == 4);
        test(v.f == 5.0);
        test(v.d == 6.0);
        test([v.str isEqualToString:@"foo bar"]);
        test(v.c == TestDefaultValuered);
        test([v.noDefault length] == 0);
    }

    {
        TestDefaultValueStruct2* v = [TestDefaultValueStruct2 struct2];
        test(!v.boolFalse);
        test(v.boolTrue);
        test(v.b == 1);
        test(v.s == 2);
        test(v.i == 3);
        test(v.l == 4);
        test(v.f == 5.0);
        test(v.d == 6.0);
        test([v.str isEqualToString:@"foo bar"]);
        test(v.c == TestDefaultValueblue);
        test([v.noDefault length] == 0);
    }

    {
        TestDefaultValueBase* v = [TestDefaultValueBase base];
        test(!v.boolFalse);
        test(v.boolTrue);
        test(v.b == 1);
        test(v.s == 2);
        test(v.i == 3);
        test(v.l == 4);
        test(v.f == 5.0);
        test(v.d == 6.0);
        test([v.str isEqualToString:@"foo bar"]);
        test([v.noDefault length] == 0);
    }

    {
        TestDefaultValueDerived* v = [TestDefaultValueDerived derived];
        test(!v.boolFalse);
        test(v.boolTrue);
        test(v.b == 1);
        test(v.s == 2);
        test(v.i == 3);
        test(v.l == 4);
        test(v.f == 5.0);
        test(v.d == 6.0);
        test([v.str isEqualToString:@"foo bar"]);
        test([v.noDefault length] == 0);
        test(v.c == TestDefaultValuegreen);
    }

    {
        TestDefaultValueBaseEx* v = [TestDefaultValueBaseEx baseEx];
        test(!v.boolFalse);
        test(v.boolTrue);
        test(v.b == 1);
        test(v.s == 2);
        test(v.i == 3);
        test(v.l == 4);
        test(v.f == 5.0);
        test(v.d == 6.0);
        test([v.str isEqualToString:@"foo bar"]);
        test([v.noDefault length] == 0);
    }

    {
        TestDefaultValueDerivedEx* v = [TestDefaultValueDerivedEx derivedEx];
        test(!v.boolFalse);
        test(v.boolTrue);
        test(v.b == 1);
        test(v.s == 2);
        test(v.i == 3);
        test(v.l == 4);
        test(v.f == 5.0);
        test(v.d == 6.0);
        test([v.str isEqualToString:@"foo bar"]);
        test([v.noDefault length] == 0);
        test(v.c == TestDefaultValuegreen);
    }

    tprintf("ok\n");

    tprintf("testing default constructor... ");

    {
        TestDefaultValueStructNoDefaults* v = [TestDefaultValueStructNoDefaults structNoDefaults];
        test(v.bo == NO);
        test(v.b == 0);
        test(v.s == 0);
        test(v.i == 0);
        test(v.l == 0);
        test(v.f == 0.0);
        test(v.d == 0.0);
        test([v.str isEqual:@""]);
        test(v.c1 == TestDefaultValuered);
        test(v.bs == nil);
        test(v.is == nil);
        test(v.st != nil);
        test(v.dict == nil);

        TestDefaultValueExceptionNoDefaults* e = [TestDefaultValueExceptionNoDefaults exceptionNoDefaults];
        test([e.str isEqual:@""]);
        test(e.c1 == TestDefaultValuered);
        test(e.bs == nil);
        test(e.st != nil);
        test(e.dict == nil);

        TestDefaultValueClassNoDefaults* cl = [TestDefaultValueClassNoDefaults classNoDefaults];
        test([cl.str isEqual:@""]);
        test(cl.c1 == TestDefaultValuered);
        test(cl.bs == nil);
        test(cl.st != nil);
        test(cl.dict == nil);
    }
    tprintf("ok\n");
}