Overview
Comment: | Add -[length] to OFString. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0fcb47fb5966e6fda7d3bd4805ca847d |
User & Date: | js on 2009-10-03 21:18:04 |
Other Links: | manifest | tags |
Context
2009-10-03
| ||
21:24 | Fix OFXMLParser so it passes indexes relative to Unicode characters. check-in: a81bd93b41 user: js tags: trunk | |
21:18 | Add -[length] to OFString. check-in: 0fcb47fb59 user: js tags: trunk | |
21:12 | Fix setting of is_utf8. check-in: f01153154d user: js tags: trunk | |
Changes
Modified src/OFString.h from [4beff4fcbf] to [628673bcd3].
︙ | ︙ | |||
187 188 189 190 191 192 193 194 195 196 197 198 199 200 | - initWithString: (OFString*)str; /** * \return The OFString as a UTF-8 encoded C string */ - (const char*)cString; /** * \return The length of the string which cString would return */ - (size_t)cStringLength; /** * Compares the OFString to another object. | > > > > > | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | - initWithString: (OFString*)str; /** * \return The OFString as a UTF-8 encoded C string */ - (const char*)cString; /** * \return The length of the string in Unicode characters */ - (size_t)length; /** * \return The length of the string which cString would return */ - (size_t)cStringLength; /** * Compares the OFString to another object. |
︙ | ︙ |
Modified src/OFString.m from [5b6856fe26] to [cf1e219842].
︙ | ︙ | |||
499 500 501 502 503 504 505 506 507 508 509 510 511 512 | return self; } - (const char*)cString { return string; } - (size_t)cStringLength { return length; } - (BOOL)isEqual: (id)obj | > > > > > > > | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | return self; } - (const char*)cString { return string; } - (size_t)length { /* FIXME: Maybe cache this in an ivar? */ return of_string_position_to_index(string, length); } - (size_t)cStringLength { return length; } - (BOOL)isEqual: (id)obj |
︙ | ︙ |
Modified tests/string.m from [34e88502ac] to [43cc839036].
︙ | ︙ | |||
42 43 44 45 46 47 48 | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *s[3]; OFArray *a; int i; EntityHandler *h; | | | | > | | | > > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFString *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]] && ![s[0] isEqual: [[[OFObject alloc] init] autorelease]]) TEST(@"-[compare:]", [s[0] compare: s[2]] == 0 && [s[0] compare: @""] != 0) TEST(@"-[hash] is the same if -[isEqual:] is YES", [s[0] hash] == [s[2] hash]) TEST(@"-[appendString:] and -[appendCString:]", [s[1] appendCString: "1𝄞"] && [s[1] appendString: @"3"] && [[s[0] appendString: s[1]] isEqual: @"täs€1𝄞3"]) TEST(@"-[length]", [s[0] length] == 7) TEST(@"-[cStringLength]", [s[0] cStringLength] == 13) TEST(@"-[hash]", [s[0] hash] == 0x8AC1EEF6) TEST(@"-[reverse]", [[s[0] reverse] isEqual: @"3𝄞1€sät"]) s[0] = [OFMutableString stringWithString: @"321tset"]; TEST(@"-[upper]", [[s[0] upper] isEqual: @"321TSET"]) TEST(@"-[lower]", [[s[0] lower] isEqual: @"321tset"]) TEST(@"+[stringWithCString:length:]", (s[0] = [OFMutableString stringWithCString: "foobar" length: 3]) && [s[0] isEqual: @"foo"]) |
︙ | ︙ |