ObjFW  Diff

Differences From Artifact [e3b3ae9aa1]:

To Artifact [e7dc8eb450]:


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
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







-
+
+















-
+
+
















+
-
+











-
+







# define TOO_BIG (SIZE_MAX - 128)
#endif

static OFString *module = @"OFObject";

@interface MyObj: OFObject
{
	id _object;
	id _objectValue;
	Class _classValue;
	bool _boolValue;
	char _charValue;
	short _shortValue;
	int _intValue;
	long _longValue;
	long long _longLongValue;
	unsigned char _unsignedCharValue;
	unsigned short _unsignedShortValue;
	unsigned int _unsignedIntValue;
	unsigned long _unsignedLongValue;
	unsigned long long _unsignedLongLongValue;
	float _floatValue;
	double _doubleValue;
}

@property (retain) id object;
@property (retain) id objectValue;
@property Class classValue;
@property bool boolValue;
@property char charValue;
@property short shortValue;
@property int intValue;
@property long longValue;
@property long long longLongValue;
@property unsigned char unsignedCharValue;
@property unsigned short unsignedShortValue;
@property unsigned int unsignedIntValue;
@property unsigned long unsignedLongValue;
@property unsigned long long unsignedLongLongValue;
@property float floatValue;
@property double doubleValue;
@end

@implementation MyObj
@synthesize objectValue = _objectValue, classValue = _classValue;
@synthesize object = _object, boolValue = _boolValue, charValue = _charValue;
@synthesize boolValue = _boolValue, charValue = _charValue;
@synthesize shortValue = _shortValue, intValue = _intValue;
@synthesize longValue = _longValue, longLongValue = _longLongValue;
@synthesize unsignedCharValue = _unsignedCharValue;
@synthesize unsignedShortValue = _unsignedShortValue;
@synthesize unsignedIntValue = _unsignedIntValue;
@synthesize unsignedLongValue = _unsignedLongValue;
@synthesize unsignedLongLongValue = _unsignedLongLongValue;
@synthesize floatValue = _floatValue, doubleValue = _doubleValue;

- (void)dealloc
{
	[_object release];
	[_objectValue release];

	[super dealloc];
}
@end

@implementation TestsAppDelegate (OFObjectTests)
- (void)objectTests
144
145
146
147
148
149
150
151


152
153



154
155
156
157
158
159
160





161
162
163
164
165
166
167
147
148
149
150
151
152
153

154
155
156

157
158
159
160
161
162
163
164
165

166
167
168
169
170
171
172
173
174
175
176
177







-
+
+

-
+
+
+






-
+
+
+
+
+








	TEST(@"-[description]",
	    [[o description] isEqual:
	    [OFString stringWithFormat: @"<OFObject: %p>", o]] &&
	    [[m description] isEqual:
	    [OFString stringWithFormat: @"<MyObj: %p>", m]])

	[m setObject: @"Hello"];
	[m setObjectValue: @"Hello"];
	[m setClassValue: [m class]];
	TEST(@"-[valueForKey:]",
	    [[m valueForKey: @"object"] isEqual: @"Hello"])
	    [[m valueForKey: @"objectValue"] isEqual: @"Hello"] &&
	    [[m valueForKey: @"classValue"] isEqual: [m class]] &&
	    [[m valueForKey: @"class"] isEqual: [m class]])

	EXPECT_EXCEPTION(@"-[valueForKey:] with undefined key",
	    OFUndefinedKeyException, [m valueForKey: @"undefined"])

	TEST(@"-[setValue:forKey:]",
	    R([m setValue: @"World"
		   forKey: @"object"]) && [[m object] isEqual: @"World"])
		   forKey: @"objectValue"]) &&
	    R([m setValue: [OFObject class]
		   forKey: @"classValue"]) &&
	    [[m objectValue] isEqual: @"World"] &&
	    [[m classValue] isEqual: [OFObject class]])

	EXPECT_EXCEPTION(@"-[setValue:forKey:] with undefined key",
	    OFUndefinedKeyException, [m setValue: @"x"
					  forKey: @"undefined"])

	[m setBoolValue: 1];
	[m setCharValue: 2];