Differences From Artifact [c38d6eca4f]:
- File
tests/OFStringTests.m
— part of check-in
[7926b47265]
at
2017-05-01 13:07:16
on branch trunk
— Add tests for generic OFString / OFMutableString
These are usually not used, as OFString_UTF8 and OFMutableString_UTF8
are used instead. However, they are used if someone creates their own
subclass of OFString / OFMutableString. As they are rarely used in
production, it is important to run all tests on them. (user: js, size: 33312) [annotate] [blame] [check-ins using]
To Artifact [1397ae7a5c]:
- File
tests/OFStringTests.m
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 33320) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
31 32 33 34 35 36 37 | #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnknownXMLEntityException.h" #import "TestsAppDelegate.h" static OFString *module = nil; | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" #import "OFUnknownXMLEntityException.h" #import "TestsAppDelegate.h" static OFString *module = nil; static OFString *whitespace[] = { @" \r \t\n\t \tasd \t \t\t\r\n", @" \t\t \t\t \t \t" }; static of_unichar_t ucstr[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A, 0 }; static of_unichar_t sucstr[] = { |
︙ | ︙ | |||
77 78 79 80 81 82 83 | [self release]; @throw e; } return self; } | | | | | | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | [self release]; @throw e; } return self; } - initWithString: (OFString *)string { self = [super init]; @try { _string = [string mutableCopy]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding length: (size_t)length { self = [super init]; @try { _string = [[OFMutableString alloc] initWithCString: cString encoding: encoding length: length]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithUTF16String: (const of_char16_t *)UTF16String length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { self = [super init]; @try { _string = [[OFMutableString alloc] initWithUTF16String: UTF16String length: length byteOrder: byteOrder]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithUTF32String: (const of_char32_t *)UTF32String length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { self = [super init]; @try { _string = [[OFMutableString alloc] initWithUTF32String: UTF32String length: length byteOrder: byteOrder]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithFormat: (OFConstantString *)format arguments: (va_list)arguments { self = [super init]; @try { _string = [[OFMutableString alloc] initWithFormat: format arguments: arguments]; |
︙ | ︙ | |||
189 190 191 192 193 194 195 | + (void)initialize { if (self == [SimpleMutableString class]) [self inheritMethodsFromClass: [SimpleString class]]; } - (void)replaceCharactersInRange: (of_range_t)range | | | | | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | + (void)initialize { if (self == [SimpleMutableString class]) [self inheritMethodsFromClass: [SimpleString class]]; } - (void)replaceCharactersInRange: (of_range_t)range withString: (OFString *)string { [_string replaceCharactersInRange: range withString: string]; } @end @interface EntityHandler: OFObject <OFStringXMLUnescapingDelegate> @end @implementation EntityHandler - (OFString *)string: (OFString *)string containsUnknownEntityNamed: (OFString *)entity { if ([entity isEqual: @"foo"]) return @"bar"; return nil; } @end |
︙ | ︙ | |||
929 930 931 932 933 934 935 | (h = [[[EntityHandler alloc] init] autorelease]) && [[C(@"x&foo;y") stringByXMLUnescapingWithDelegate: h] isEqual: @"xbary"]) #ifdef OF_HAVE_BLOCKS TEST(@"-[stringByXMLUnescapingWithBlock:]", [[C(@"x&foo;y") stringByXMLUnescapingWithBlock: | | | 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 | (h = [[[EntityHandler alloc] init] autorelease]) && [[C(@"x&foo;y") stringByXMLUnescapingWithDelegate: h] isEqual: @"xbary"]) #ifdef OF_HAVE_BLOCKS TEST(@"-[stringByXMLUnescapingWithBlock:]", [[C(@"x&foo;y") stringByXMLUnescapingWithBlock: ^ OFString *(OFString *str, OFString *entity) { if ([entity isEqual: @"foo"]) return @"bar"; return nil; }] isEqual: @"xbary"]) j = 0; |
︙ | ︙ |