Differences From Artifact [ffc025b2b3]:
- File tests/OFString/OFString.m — part of check-in [1496808b81] at 2009-01-24 15:24:49 on branch trunk — Adjust API to introduction of OFAutoreleasePool. (user: js, size: 2359) [annotate] [blame] [check-ins using]
To Artifact [d1e8e561ed]:
- File
tests/OFString/OFString.m
— part of check-in
[61a6ac873a]
at
2009-02-14 17:08:21
on branch trunk
— Big diff, see details.
* Add OFComparable protocol.
* Add OFInvalidArgument exception - needs that sel_getName vs.
sel_get_name stuff again, therefore reintroduce it.
* Implement proper copy method for OFString and OFArray.
* Add isEqual: and compare: for OFString and OFArray. (user: js, size: 2392) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
21 22 23 24 25 26 27 | #ifndef _WIN32 #define ZD "%zd" #else #define ZD "%u" #endif | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #ifndef _WIN32 #define ZD "%zd" #else #define ZD "%u" #endif #define NUM_TESTS 13 #define SUCCESS \ printf("\r\033[1;%dmTests successful: " ZD "/%d\033[0m", \ (i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS); \ fflush(stdout); #define FAIL \ printf("\r\033[K\033[1;31mTest " ZD "/%d failed!\033[m\n", \ i + 1, NUM_TESTS); \ |
︙ | ︙ | |||
57 58 59 60 61 62 63 | OFAutoreleasePool *pool = [OFAutoreleasePool new]; OFString *s1 = [OFString stringWithCString: "test"]; OFString *s2 = [OFString stringWithCString: ""]; OFString *s3; OFString *s4 = [OFString string]; | | > | | | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | OFAutoreleasePool *pool = [OFAutoreleasePool new]; OFString *s1 = [OFString stringWithCString: "test"]; OFString *s2 = [OFString stringWithCString: ""]; OFString *s3; OFString *s4 = [OFString string]; s3 = [s1 copy]; CHECK([s1 isEqual: s3]) CHECK(![s1 isEqual: [OFObject new]]); [s2 appendCString: "123"]; [s4 setTo: s2]; CHECK(![s2 compare: s4]) CHECK(!strcmp([[s1 append: s2] cString], "test123")) CHECK(strlen([s1 cString]) == [s1 length] && [s1 length] == 7) CHECK(!strcmp([[s1 reverse] cString], "321tset")) CHECK(!strcmp([[s1 upper] cString], "321TSET")) CHECK(!strcmp([[s1 lower] cString], "321tset")) /* Also clears all the memory of the returned C strings */ |
︙ | ︙ |