ObjFW  Diff

Differences From Artifact [f63bfb7b62]:

To Artifact [1cd99d50a7]:


11
12
13
14
15
16
17


18
19
20
21
22
23





24












25
26
27
28
29
30
31
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#import "ObjFW.h"
#import "ObjFWTest.h"

@interface OFMessagePackTests: OTTestCase
@end






@implementation OFMessagePackTests












- (void)testMessagePackRepresentationForNumber
{
	OTAssertEqualObjects([[OFNumber numberWithChar: -30]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xE2" count: 1]);

	OTAssertEqualObjects([[OFNumber numberWithChar: -33]







>
>






>
>
>
>
>

>
>
>
>
>
>
>
>
>
>
>
>







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
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <string.h>

#import "ObjFW.h"
#import "ObjFWTest.h"

@interface OFMessagePackTests: OTTestCase
@end

const char *smallDictionaryRepresentation =
    "\xDE\x00\x10\x00\x01\x01\x02\x02\x03\x03\x04\x04\x05\x05\x06\x06"
    "\x07\x07\x08\x08\x09\x09\x0A\x0A\x0B\x0B\x0C\x0C\x0D\x0D\x0E\x0E"
    "\x0F\x0F\x10";

@implementation OFMessagePackTests
- (void)testMessagePackRepresentationForNull
{
	OTAssertEqualObjects([[OFNull null] messagePackRepresentation],
	    [OFData dataWithItems: "\xC0" count: 1]);
}

- (void)testObjectByParsingMessagePackForNull
{
	OTAssertEqualObjects([[OFData dataWithItems: "\xC0" count: 1]
	    objectByParsingMessagePack], [OFNull null]);
}

- (void)testMessagePackRepresentationForNumber
{
	OTAssertEqualObjects([[OFNumber numberWithChar: -30]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xE2" count: 1]);

	OTAssertEqualObjects([[OFNumber numberWithChar: -33]
70
71
72
73
74
75
76








77
78
79
80
81
82
83
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xCA\x3F\xA0\x00\x00" count: 5]);

	OTAssertEqualObjects([[OFNumber numberWithDouble: 1.25]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xCB\x3F\xF4\x00\x00\x00\x00\x00\x00"
			    count: 9]);








}

- (void)testObjectByParsingMessagePackForNumber
{
	OTAssertEqualObjects([[OFData dataWithItems: "\xE2" count: 1]
	    objectByParsingMessagePack],
	    [OFNumber numberWithChar: -30]);







>
>
>
>
>
>
>
>







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xCA\x3F\xA0\x00\x00" count: 5]);

	OTAssertEqualObjects([[OFNumber numberWithDouble: 1.25]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xCB\x3F\xF4\x00\x00\x00\x00\x00\x00"
			    count: 9]);

	OTAssertEqualObjects(
	    [[OFNumber numberWithBool: true] messagePackRepresentation],
	    [OFData dataWithItems: "\xC3" count: 1]);

	OTAssertEqualObjects(
	    [[OFNumber numberWithBool: false] messagePackRepresentation],
	    [OFData dataWithItems: "\xC2" count: 1]);
}

- (void)testObjectByParsingMessagePackForNumber
{
	OTAssertEqualObjects([[OFData dataWithItems: "\xE2" count: 1]
	    objectByParsingMessagePack],
	    [OFNumber numberWithChar: -30]);
127
128
129
130
131
132
133
134


























































































































































































































































































































































































































135
			     count: 5] objectByParsingMessagePack],
	    [OFNumber numberWithFloat: 1.25f]);

	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xCB\x3F\xF4\x00\x00\x00\x00\x00\x00"
			     count: 9] objectByParsingMessagePack],
	    [OFNumber numberWithDouble: 1.25]);
}


























































































































































































































































































































































































































@end







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
			     count: 5] objectByParsingMessagePack],
	    [OFNumber numberWithFloat: 1.25f]);

	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xCB\x3F\xF4\x00\x00\x00\x00\x00\x00"
			     count: 9] objectByParsingMessagePack],
	    [OFNumber numberWithDouble: 1.25]);

	OTAssertEqualObjects([[OFData dataWithItems: "\xC3" count: 1]
	    objectByParsingMessagePack],
	    [OFNumber numberWithBool: true]);

	OTAssertEqualObjects([[OFData dataWithItems: "\xC2" count: 1]
	    objectByParsingMessagePack],
	    [OFNumber numberWithBool: false]);
}

static void
generateStringAndData(OFString **string, OFMutableData **data, size_t length,
    const char *dataPrefix, size_t dataPrefixLength)
{
	*data = [OFMutableData dataWithCapacity: length + dataPrefixLength];
	[*data addItems: dataPrefix count: dataPrefixLength];
	[*data increaseCountBy: length];
	memset([*data mutableItemAtIndex: dataPrefixLength], 'x', length);

	*string = [OFString
	    stringWithUTF8String: [*data itemAtIndex: dataPrefixLength]
			  length: length];
}

- (void)testMessagePackRepresentationForString
{
	OFString *string;
	OFMutableData *data;

	OTAssertEqualObjects(@"x".messagePackRepresentation,
	    [OFData dataWithItems: "\xA1x" count: 2]);

	generateStringAndData(&string, &data, 32, "\xD9\x20", 2);
	OTAssertEqualObjects(string.messagePackRepresentation, data);

	generateStringAndData(&string, &data, 256, "\xDA\x01\x00", 3);
	OTAssertEqualObjects(string.messagePackRepresentation, data);

	generateStringAndData(&string, &data, 65536, "\xDB\x00\x01\x00\x00", 5);
	OTAssertEqualObjects(string.messagePackRepresentation, data);
}

- (void)testObjectByParsingMessagePackForString
{
	OFString *string;
	OFMutableData *data;

	OTAssertEqualObjects([[OFData dataWithItems: "\xA1x" count: 2]
	    objectByParsingMessagePack], @"x");

	generateStringAndData(&string, &data, 32, "\xD9\x20", 2);
	OTAssertEqualObjects(data.objectByParsingMessagePack, string);

	generateStringAndData(&string, &data, 256, "\xDA\x01\x00", 3);
	OTAssertEqualObjects(data.objectByParsingMessagePack, string);

	generateStringAndData(&string, &data, 65536, "\xDB\x00\x01\x00\x00", 5);
	OTAssertEqualObjects(data.objectByParsingMessagePack, string);
}

- (void)testMessagePackRepresentationForData
{
	OFMutableData *data;

	OTAssertEqualObjects(
	    [[OFData dataWithItems: "x" count: 1] messagePackRepresentation],
	    [OFData dataWithItems: "\xC4\x01x" count: 3]);

	data = [OFMutableData data];
	[data addItems: "\xC5\x01\x00" count: 3];
	[data increaseCountBy: 256];
	memset([data mutableItemAtIndex: 3], 'x', 256);
	OTAssertEqualObjects([[data subdataWithRange: OFMakeRange(3, 256)]
	    messagePackRepresentation], data);

	data = [OFMutableData data];
	[data addItems: "\xC6\x00\x01\x00\x00" count: 5];
	[data increaseCountBy: 65536];
	memset([data mutableItemAtIndex: 5], 'x', 65536);
	OTAssertEqualObjects([[data subdataWithRange: OFMakeRange(5, 65536)]
	    messagePackRepresentation], data);
}

- (void)testObjectByParsingMessagePackForData
{
	OFMutableData *data;

	OTAssertEqualObjects([[OFData dataWithItems: "\xC4\x01x" count: 3]
	    objectByParsingMessagePack],
	    [OFData dataWithItems: "x" count: 1]);

	data = [OFMutableData data];
	[data addItems: "\xC5\x01\x00" count: 3];
	[data increaseCountBy: 256];
	memset([data mutableItemAtIndex: 3], 'x', 256);
	OTAssertEqualObjects(data.objectByParsingMessagePack,
	    [data subdataWithRange: OFMakeRange(3, 256)]);

	data = [OFMutableData data];
	[data addItems: "\xC6\x00\x01\x00\x00" count: 5];
	[data increaseCountBy: 65536];
	memset([data mutableItemAtIndex: 5], 'x', 65536);
	OTAssertEqualObjects(data.objectByParsingMessagePack,
	    [data subdataWithRange: OFMakeRange(5, 65536)]);
}

- (void)testMessagePackRepresentationForArray
{
	OFMutableArray *array = [OFMutableArray arrayWithCapacity: 65536];
	OFNumber *number = [OFNumber numberWithUnsignedInt: 1];
	OFMutableData *data;

	OTAssertEqualObjects([[OFArray array] messagePackRepresentation],
	    [OFData dataWithItems: "\x90" count: 1]);

	OTAssertEqualObjects(
	    [[OFArray arrayWithObject: number] messagePackRepresentation],
	    [OFData dataWithItems: "\x91\x01" count: 2]);

	data = [OFMutableData dataWithCapacity: 19];
	[data addItems: "\xDC\x00\x10" count: 3];
	[data increaseCountBy: 16];
	memset([data mutableItemAtIndex: 3], '\x01', 16);
	for (size_t i = 0; i < 16; i++)
		[array addObject: number];
	OTAssertEqualObjects(array.messagePackRepresentation, data);

	data = [OFMutableData dataWithCapacity: 65541];
	[data addItems: "\xDD\x00\x01\x00\x00" count: 5];
	[data increaseCountBy: 65536];
	memset([data mutableItemAtIndex: 5], '\x01', 65536);
	for (size_t i = 16; i < 65536; i++)
		[array addObject: number];
	OTAssertEqualObjects(array.messagePackRepresentation, data);
}

- (void)testObjectByParsingMessagePackForArray
{
	OFMutableArray *array = [OFMutableArray arrayWithCapacity: 65536];
	OFNumber *number = [OFNumber numberWithUnsignedInt: 1];
	OFMutableData *data;

	OTAssertEqualObjects([[OFData dataWithItems: "\x90" count: 1]
	    objectByParsingMessagePack], [OFArray array]);

	OTAssertEqualObjects([[OFData dataWithItems: "\x91\x01" count: 2]
	    objectByParsingMessagePack],
	    [OFArray arrayWithObject: number]);

	data = [OFMutableData dataWithCapacity: 19];
	[data addItems: "\xDC\x00\x10" count: 3];
	[data increaseCountBy: 16];
	memset([data mutableItemAtIndex: 3], '\x01', 16);
	for (size_t i = 0; i < 16; i++)
		[array addObject: number];
	OTAssertEqualObjects(data.objectByParsingMessagePack, array);

	data = [OFMutableData dataWithCapacity: 65541];
	[data addItems: "\xDD\x00\x01\x00\x00" count: 5];
	[data increaseCountBy: 65536];
	memset([data mutableItemAtIndex: 5], '\x01', 65536);
	for (size_t i = 16; i < 65536; i++)
		[array addObject: number];
	OTAssertEqualObjects(data.objectByParsingMessagePack, array);
}

- (void)testMessagePackRepresentationForDictionary
{
	OFMutableArray *keys = [OFMutableArray arrayWithCapacity: 65536];
	OFMutableArray *objects = [OFMutableArray arrayWithCapacity: 65536];

	OTAssertEqualObjects([[OFDictionary dictionary]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\x80" count: 1]);

	OTAssertEqualObjects([[OFDictionary
	    dictionaryWithObject: [OFNumber numberWithUnsignedInt: 2]
			  forKey: [OFNumber numberWithUnsignedInt: 1]]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\x81\x01\x02" count: 3]);

	for (unsigned int i = 0; i < 16; i++) {
		[keys addObject: [OFNumber numberWithUnsignedInt: i]];
		[objects addObject: [OFNumber numberWithUnsignedInt: i + 1]];
	}
	OTAssertEqualObjects([[OTOrderedDictionary
	    dictionaryWithObjects: objects.objects
			  forKeys: keys.objects
			    count: 16] messagePackRepresentation],
	    [OFData dataWithItems: smallDictionaryRepresentation count: 35]);

	for (unsigned int i = 16; i < 65536; i++) {
		[keys addObject: [OFNumber numberWithUnsignedInt: i]];
		[objects addObject: [OFNumber numberWithUnsignedInt: i + 1]];
	}
	OTAssertEqualObjects([[OTOrderedDictionary
	    dictionaryWithObjects: objects.objects
			  forKeys: keys.objects
			    count: 65536] messagePackRepresentation],
	    [OFData dataWithContentsOfIRI:
	    [OFIRI IRIWithString: @"embedded:big_dictionary.msgpack"]]);
}

- (void)testObjectByParsingMessagePackForDictionary
{
	OFMutableDictionary *dictionary =
	    [OFMutableDictionary dictionaryWithCapacity: 65536];

	OTAssertEqualObjects([[OFData dataWithItems: "\x80" count: 1]
	    objectByParsingMessagePack], [OFDictionary dictionary]);

	OTAssertEqualObjects([[OFData dataWithItems: "\x81\x01\x02" count: 3]
	    objectByParsingMessagePack],
	    [OFDictionary
	    dictionaryWithObject: [OFNumber numberWithUnsignedInt: 2]
			  forKey: [OFNumber numberWithUnsignedInt: 1]]);

	for (unsigned int i = 0; i < 16; i++)
		[dictionary setObject: [OFNumber numberWithUnsignedInt: i + 1]
			       forKey: [OFNumber numberWithUnsignedInt: i]];
	OTAssertEqualObjects(
	    [[OFData dataWithItems: smallDictionaryRepresentation
			     count: 35] objectByParsingMessagePack],
	    dictionary);

	for (unsigned int i = 16; i < 65536; i++)
		[dictionary setObject: [OFNumber numberWithUnsignedInt: i + 1]
			       forKey: [OFNumber numberWithUnsignedInt: i]];
	OTAssertEqualObjects(dictionary,
	    [[OFData dataWithContentsOfIRI:
	    [OFIRI IRIWithString: @"embedded:big_dictionary.msgpack"]]
	    objectByParsingMessagePack]);
}

- (void)testMessagePackRepresentationForExtension
{
	OFMessagePackExtension *extension;
	OFMutableData *data;

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "x" count: 1]];
	OTAssertEqualObjects(extension.messagePackRepresentation,
	    [OFData dataWithItems: "\xD4\x01x" count: 3]);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "xy" count: 2]];
	OTAssertEqualObjects(extension.messagePackRepresentation,
	    [OFData dataWithItems: "\xD5\x01xy" count: 4]);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "abcd" count: 4]];
	OTAssertEqualObjects(extension.messagePackRepresentation,
	    [OFData dataWithItems: "\xD6\x01" "abcd" count: 6]);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "12345678" count: 8]];
	OTAssertEqualObjects(extension.messagePackRepresentation,
	    [OFData dataWithItems: "\xD7\x01" "12345678" count: 10]);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "12345678ABCDEFGH"
					       count: 16]];
	OTAssertEqualObjects(extension.messagePackRepresentation,
	    [OFData dataWithItems: "\xD8\x01" "12345678ABCDEFGH" count: 18]);

	extension = [OFMessagePackExtension extensionWithType: 1
							 data: [OFData data]];
	OTAssertEqualObjects(extension.messagePackRepresentation,
	    [OFData dataWithItems: "\xC7\x00\x01" count: 3]);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "abc" count: 3]];
	OTAssertEqualObjects(extension.messagePackRepresentation,
	    [OFData dataWithItems: "\xC7\x03\x01" "abc" count: 6]);

	data = [OFMutableData dataWithCapacity: 260];
	[data addItems: "\xC8\x01\x00\x01" count: 4];
	[data increaseCountBy: 256];
	memset([data mutableItemAtIndex: 4], 'x', 256);
	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [data subdataWithRange: OFMakeRange(4, 256)]];
	OTAssertEqualObjects(extension.messagePackRepresentation, data);

	data = [OFMutableData dataWithCapacity: 65542];
	[data addItems: "\xC9\x00\x01\x00\x00\x01" count: 6];
	[data increaseCountBy: 65536];
	memset([data mutableItemAtIndex: 6], 'x', 65536);
	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [data subdataWithRange: OFMakeRange(6, 65536)]];
	OTAssertEqualObjects(extension.messagePackRepresentation, data);
}

- (void)testObjectByParsingMessagePackForExtension
{
	OFMessagePackExtension *extension;
	OFMutableData *data;

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "x" count: 1]];
	OTAssertEqualObjects([[OFData dataWithItems: "\xD4\x01x" count: 3]
	    objectByParsingMessagePack], extension);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "xy" count: 2]];
	OTAssertEqualObjects([[OFData dataWithItems: "\xD5\x01xy" count: 4]
	    objectByParsingMessagePack], extension);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "abcd" count: 4]];
	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xD6\x01" "abcd"
			     count: 6] objectByParsingMessagePack],
	    extension);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "12345678" count: 8]];
	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xD7\x01" "12345678"
			     count: 10] objectByParsingMessagePack],
	    extension);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "12345678ABCDEFGH"
					       count: 16]];
	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xD8\x01" "12345678ABCDEFGH"
			     count: 18] objectByParsingMessagePack],
	    extension);

	extension = [OFMessagePackExtension extensionWithType: 1
							 data: [OFData data]];
	OTAssertEqualObjects([[OFData dataWithItems: "\xC7\x00\x01" count: 3]
	    objectByParsingMessagePack], extension);

	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [OFData dataWithItems: "abc" count: 3]];
	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xC7\x03\x01" "abc"
			     count: 6] objectByParsingMessagePack],
	    extension);

	data = [OFMutableData dataWithCapacity: 260];
	[data addItems: "\xC8\x01\x00\x01" count: 4];
	[data increaseCountBy: 256];
	memset([data mutableItemAtIndex: 4], 'x', 256);
	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [data subdataWithRange: OFMakeRange(4, 256)]];
	OTAssertEqualObjects(data.objectByParsingMessagePack, extension);

	data = [OFMutableData dataWithCapacity: 65542];
	[data addItems: "\xC9\x00\x01\x00\x00\x01" count: 6];
	[data increaseCountBy: 65536];
	memset([data mutableItemAtIndex: 6], 'x', 65536);
	extension = [OFMessagePackExtension
	    extensionWithType: 1
			 data: [data subdataWithRange: OFMakeRange(6, 65536)]];
	OTAssertEqualObjects(data.objectByParsingMessagePack, extension);
}

- (void)testMessagePackRepresentationForDate
{
	OTAssertEqualObjects([[OFDate dateWithTimeIntervalSince1970: 1]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xD6\xFF\x00\x00\x00\x01" count: 6]);

	OTAssertEqualObjects([[OFDate dateWithTimeIntervalSince1970: 1.25]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xD7\xFF\x3B\x9A\xCA\x00\x00\x00\x00\x01"
			    count: 10]);

	OTAssertEqualObjects(
	    [[OFDate dateWithTimeIntervalSince1970: 0x400000000 + 0.25]
	    messagePackRepresentation],
	    [OFData dataWithItems: "\xC7\x0C\xFF\x0E\xE6\xB2\x80\x00\x00\x00"
				   "\x04\x00\x00\x00\x00"
			    count: 15]);
}

- (void)testObjectByParsingMessagePackForDate
{
	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xD6\xFF\x00\x00\x00\x01"
			     count: 6] objectByParsingMessagePack],
	    [OFDate dateWithTimeIntervalSince1970: 1]);

	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xD7\xFF\x3B\x9A\xCA\x00\x00\x00\x00\x01"
			     count: 10] objectByParsingMessagePack],
	    [OFDate dateWithTimeIntervalSince1970: 1.25]);

	OTAssertEqualObjects(
	    [[OFData dataWithItems: "\xC7\x0C\xFF\x0E\xE6\xB2\x80\x00\x00\x00"
				    "\x04\x00\x00\x00\x00"
			     count: 15] objectByParsingMessagePack],
	    [OFDate dateWithTimeIntervalSince1970: 0x400000000 + 0.25]);
}
@end