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
|
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFList.h"
#import "OFNumber.h"
#import "OFDate.h"
#import "OFURL.h"
#import "OFAutoreleasePool.h"
#import "OFXMLElement.h"
#import "TestsAppDelegate.h"
static OFString *module = @"OFSerialization";
@implementation TestsAppDelegate (SerializationTests)
- (void)serializationTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFMutableDictionary *d = [OFMutableDictionary dictionary];
OFMutableArray *a = [OFMutableArray array];
OFList *l = [OFList list];
OFString *s;
[a addObject: @"Qu\"xbar\ntest"];
[a addObject: [OFNumber numberWithInt: 1234]];
[a addObject: [OFMutableString stringWithString: @"asd"]];
[a addObject: [OFDate dateWithTimeIntervalSince1970: 1234
microseconds: 5678]];
|
>
>
|
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
|
#import "OFString.h"
#import "OFArray.h"
#import "OFDictionary.h"
#import "OFList.h"
#import "OFNumber.h"
#import "OFDate.h"
#import "OFURL.h"
#import "OFDataArray.h"
#import "OFAutoreleasePool.h"
#import "OFXMLElement.h"
#import "TestsAppDelegate.h"
static OFString *module = @"OFSerialization";
@implementation TestsAppDelegate (SerializationTests)
- (void)serializationTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFMutableDictionary *d = [OFMutableDictionary dictionary];
OFMutableArray *a = [OFMutableArray array];
OFList *l = [OFList list];
OFDataArray *da = [OFDataArray dataArray];
OFString *s;
[a addObject: @"Qu\"xbar\ntest"];
[a addObject: [OFNumber numberWithInt: 1234]];
[a addObject: [OFMutableString stringWithString: @"asd"]];
[a addObject: [OFDate dateWithTimeIntervalSince1970: 1234
microseconds: 5678]];
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
[l appendObject: [OFURL URLWithString: @"https://webkeks.org/"]];
[l appendObject:
[OFXMLElement elementWithXMLString: @"<x><y/><![CDATA[<]]></x>"]];
[d setObject: @"list"
forKey: l];
TEST(@"-[stringBySerializing]",
(s = [d stringBySerializing]) && [s isEqual:
[OFString stringWithContentsOfFile: @"serialization.xml"]])
TEST(@"-[objectByDeserializing]",
[[s objectByDeserializing] isEqual: d])
[pool drain];
}
@end
|
>
>
>
>
>
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
[l appendObject: [OFURL URLWithString: @"https://webkeks.org/"]];
[l appendObject:
[OFXMLElement elementWithXMLString: @"<x><y/><![CDATA[<]]></x>"]];
[d setObject: @"list"
forKey: l];
[da addNItems: 39
fromCArray: "0123456789:;<ABCDEFGHJIKLMNOPQRSTUVWXYZ"];
[d setObject: @"data"
forKey: da];
TEST(@"-[stringBySerializing]",
(s = [d stringBySerializing]) && [s isEqual:
[OFString stringWithContentsOfFile: @"serialization.xml"]])
TEST(@"-[objectByDeserializing]",
[[s objectByDeserializing] isEqual: d])
[pool drain];
}
@end
|