ObjFW  Diff

Differences From Artifact [a3755365c5]:

To Artifact [3302635bae]:


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

#import "config.h"

#include <stdio.h>
#include <string.h>

#import "OFString.h"
#import "OFConstString.h"
#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"

#ifndef _WIN32
#define ZD "%zd"
#else







<







11
12
13
14
15
16
17

18
19
20
21
22
23
24

#import "config.h"

#include <stdio.h>
#include <string.h>

#import "OFString.h"

#import "OFArray.h"
#import "OFAutoreleasePool.h"
#import "OFExceptions.h"

#ifndef _WIN32
#define ZD "%zd"
#else
66
67
68
69
70
71
72
73

74
75
76
77
78
79
80

	s3 = [s1 copy];

	CHECK([s1 isEqual: s3])
	CHECK(![s1 isEqual: [[OFObject alloc] init]])
	CHECK([s1 hash] == [s3 hash])

	[s2 appendCString: "123"];

	[s4 setTo: [s2 cString]];

	CHECK(![s2 compare: s4])
	CHECK(!strcmp([[s1 append: s2] cString], "test123"))
	CHECK([s1 hash] == 0xC44F49A4)
	CHECK(strlen([s1 cString]) == [s1 length] && [s1 length] == 7)
	CHECK(!strcmp([[s1 reverse] cString], "321tset"))







|
>







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

	s3 = [s1 copy];

	CHECK([s1 isEqual: s3])
	CHECK(![s1 isEqual: [[OFObject alloc] init]])
	CHECK([s1 hash] == [s3 hash])

	[s2 appendCString: "12"];
	[s2 append: @"3"];
	[s4 setTo: [s2 cString]];

	CHECK(![s2 compare: s4])
	CHECK(!strcmp([[s1 append: s2] cString], "test123"))
	CHECK([s1 hash] == 0xC44F49A4)
	CHECK(strlen([s1 cString]) == [s1 length] && [s1 length] == 7)
	CHECK(!strcmp([[s1 reverse] cString], "321tset"))
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
	    OFInvalidEncodingException)

	s1 = [OFString stringWithCString: "äöü€𝄞"];
	CHECK(!strcmp([[s1 reverse] cString], "𝄞€üöä"))
	[s1 dealloc];

	/* Format tests */
	s1 = [OFString stringWithFormat: "%s: %d", "test", 123];
	CHECK(!strcmp([s1 cString], "test: 123"))

	[s1 appendWithFormatCString: "%02X", 15];
	CHECK(!strcmp([s1 cString], "test: 1230F"))

	a = [@"fooXXbarXXXXbazXXXX" splitWithDelimiter: "XX"];
	CHECK([[a object: j++] isEqual: @"foo"])
	CHECK([[a object: j++] isEqual: @"bar"])
	CHECK([[a object: j++] isEqual: @""])
	CHECK([[a object: j++] isEqual: @"baz"])
	CHECK([[a object: j++] isEqual: @""])
	CHECK([[a object: j++] isEqual: @""])

	puts("");

	return 0;
}







|


|


|











91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
	    OFInvalidEncodingException)

	s1 = [OFString stringWithCString: "äöü€𝄞"];
	CHECK(!strcmp([[s1 reverse] cString], "𝄞€üöä"))
	[s1 dealloc];

	/* Format tests */
	s1 = [OFString stringWithFormat: @"%s: %d", "test", 123];
	CHECK(!strcmp([s1 cString], "test: 123"))

	[s1 appendWithFormat: @"%02X", 15];
	CHECK(!strcmp([s1 cString], "test: 1230F"))

	a = [@"fooXXbarXXXXbazXXXX" splitWithDelimiter: @"XX"];
	CHECK([[a object: j++] isEqual: @"foo"])
	CHECK([[a object: j++] isEqual: @"bar"])
	CHECK([[a object: j++] isEqual: @""])
	CHECK([[a object: j++] isEqual: @"baz"])
	CHECK([[a object: j++] isEqual: @""])
	CHECK([[a object: j++] isEqual: @""])

	puts("");

	return 0;
}