ObjFW  Check-in [db5cdde5db]

Overview
Comment:Add a test for -[OFString enumerateLinesUsingBlock:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: db5cdde5db082d2048f622ee6e68486b20fbb54c2adab835a360d989cd120078
User & Date: js on 2011-10-28 18:02:46
Other Links: manifest | tags
Context
2011-10-28
18:32
Release the OFApplication delegate in the atexit handler. check-in: fc200bb14a user: js tags: trunk
18:02
Add a test for -[OFString enumerateLinesUsingBlock:]. check-in: db5cdde5db user: js tags: trunk
18:02
Fix a missing import. check-in: 3626a9162c user: js tags: trunk
Changes

Modified tests/OFStringTests.m from [8f7079d7f6] to [3eba69945b].

71
72
73
74
75
76
77



78
79
80
81
82
83
84
{
	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]] &&
	    ![s[0] isEqual: [[[OFObject alloc] init] autorelease]])







>
>
>







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMutableString *s[3];
	OFArray *a;
	int i;
	of_unichar_t *ua;
	EntityHandler *h;
#ifdef OF_HAVE_BLOCKS
	__block BOOL ok;
#endif

	s[0] = [OFMutableString stringWithString: @"täs€"];
	s[1] = [OFMutableString string];
	s[2] = [[s[0] copy] autorelease];

	TEST(@"-[isEqual:]", [s[0] isEqual: s[2]] &&
	    ![s[0] isEqual: [[[OFObject alloc] init] autorelease]])
506
507
508
509
510
511
512


























513
514
515
516
517
	    [[@"x&foo;y" stringByXMLUnescapingWithBlock:
	        ^ OFString* (OFString *str, OFString *entity) {
		    if ([entity isEqual: @"foo"])
			    return @"bar";

		    return nil;
	    }] isEqual: @"xbary"])


























#endif

	[pool drain];
}
@end







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





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
	    [[@"x&foo;y" stringByXMLUnescapingWithBlock:
	        ^ OFString* (OFString *str, OFString *entity) {
		    if ([entity isEqual: @"foo"])
			    return @"bar";

		    return nil;
	    }] isEqual: @"xbary"])

	ok = YES;
	[@"foo\nbar\nbaz" enumerateLinesUsingBlock:
	    ^ (OFString *line, BOOL *stop) {
		static int i = 0;

		switch (i) {
		case 0:
			if (![line isEqual: @"foo"])
				ok = NO;
			break;
		case 1:
			if (![line isEqual: @"bar"])
				ok = NO;
			break;
		case 2:
			if (![line isEqual: @"baz"])
				ok = NO;
			break;
		default:
			ok = NO;
		}

		i++;
	}];
	TEST(@"-[enumerateLinesUsingBlock:]", ok)
#endif

	[pool drain];
}
@end