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
|
/*
* Copyright (c) 2008 - 2010
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#include "config.h"
#import "OFString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "TestsAppDelegate.h"
static OFString *module = @"OFString";
static OFString* whitespace[] = {
@" \r \t\n\t \tasd \t \t\t\r\n",
@" \t\t \t\t \t \t"
};
@interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate>
@end
@implementation EntityHandler
- (OFString*)string: (OFString*)string
containsUnknownEntityNamed: (OFString*)entity
|
>
>
>
>
|
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
|
/*
* Copyright (c) 2008 - 2010
* Jonathan Schleifer <js@webkeks.org>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE included in
* the packaging of this file.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#import "OFString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"
#import "TestsAppDelegate.h"
static OFString *module = @"OFString";
static OFString* whitespace[] = {
@" \r \t\n\t \tasd \t \t\t\r\n",
@" \t\t \t\t \t \t"
};
static of_unichar_t ucstr[] = { 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0 };
@interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate>
@end
@implementation EntityHandler
- (OFString*)string: (OFString*)string
containsUnknownEntityNamed: (OFString*)entity
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
@implementation TestsAppDelegate (OFStringTests)
- (void)stringTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFMutableString *s[3];
OFArray *a;
int i;
EntityHandler *h;
s[0] = [OFMutableString stringWithString: @"täs€"];
s[1] = [OFMutableString string];
s[2] = [[s[0] copy] autorelease];
TEST(@"-[isEqual:]", [s[0] isEqual: s[2]] &&
|
>
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
@implementation TestsAppDelegate (OFStringTests)
- (void)stringTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFMutableString *s[3];
OFArray *a;
int i;
of_unichar_t *ua;
EntityHandler *h;
s[0] = [OFMutableString stringWithString: @"täs€"];
s[1] = [OFMutableString string];
s[2] = [[s[0] copy] autorelease];
TEST(@"-[isEqual:]", [s[0] isEqual: s[2]] &&
|
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
decimalValueAsInteger])
EXPECT_EXCEPTION(@"Detect out of range in -[hexadecilamValueAsInteger",
OFOutOfRangeException,
[@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
hexadecimalValueAsInteger])
TEST(@"-[md5Hash]", [[@"asdfoobar" md5Hash]
isEqual: @"184dce2ec49b5422c7cfd8728864db4c"])
TEST(@"-[sha1Hash]", [[@"asdfoobar" sha1Hash]
isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"])
|
>
>
>
|
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
decimalValueAsInteger])
EXPECT_EXCEPTION(@"Detect out of range in -[hexadecilamValueAsInteger",
OFOutOfRangeException,
[@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"
hexadecimalValueAsInteger])
TEST(@"-[unicodeString]", (ua = [@"fööbär" unicodeString]) &&
!memcmp(ua, ucstr, 7 * sizeof(of_unichar_t)) && R(free(ua)))
TEST(@"-[md5Hash]", [[@"asdfoobar" md5Hash]
isEqual: @"184dce2ec49b5422c7cfd8728864db4c"])
TEST(@"-[sha1Hash]", [[@"asdfoobar" sha1Hash]
isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"])
|