@@ -28,25 +28,25 @@ #ifndef INFINITY # define INFINITY __builtin_inf() #endif static OFString *module = nil; -static OFString *whitespace[] = { +static OFString *const whitespace[] = { @" \r \t\n\t \tasd \t \t\t\r\n", @" \t\t \t\t \t \t" }; -static OFUnichar ucstr[] = { +static const OFUnichar unicharString[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0x1F03A, 0 }; -static OFUnichar sucstr[] = { +static const OFUnichar swappedUnicharString[] = { 0xFFFE0000, 0x66000000, 0xF6000000, 0xF6000000, 0x62000000, 0xE4000000, 0x72000000, 0x3AF00100, 0 }; -static uint16_t utf16str[] = { +static const uint16_t UTF16String[] = { 0xFEFF, 'f', 0xF6, 0xF6, 'b', 0xE4, 'r', 0xD83C, 0xDC3A, 0 }; -static uint16_t sutf16str[] = { +static const uint16_t swappedUTF16String[] = { 0xFFFE, 0x6600, 0xF600, 0xF600, 0x6200, 0xE400, 0x7200, 0x3CD8, 0x3ADC, 0 }; @interface SimpleString: OFString @@ -211,34 +211,35 @@ @implementation TestsAppDelegate (OFStringTests) - (void)stringTestsWithClass: (Class)stringClass mutableClass: (Class)mutableStringClass { void *pool = objc_autoreleasePoolPush(); - OFMutableString *s[3]; - OFString *is; - OFArray *a; + OFMutableString *mutableString1, *mutableString2, *mutableString3; + OFString *string; + OFArray *array; size_t i; - const OFUnichar *ua; - const uint16_t *u16a; - OFCharacterSet *cs; - EntityHandler *h; + const OFUnichar *characters; + const uint16_t *UTF16Characters; + OFCharacterSet *characterSet; + EntityHandler *entityHandler; #ifdef OF_HAVE_BLOCKS __block int j; __block bool ok; #endif #define C(s) ((OFString *)[stringClass stringWithString: s]) - s[0] = [mutableStringClass stringWithString: @"täs€"]; - s[1] = [mutableStringClass 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]] == OFOrderedSame && - [s[0] compare: @""] != OFOrderedSame && + mutableString1 = [mutableStringClass stringWithString: @"täs€"]; + mutableString2 = [mutableStringClass string]; + mutableString3 = [[mutableString1 copy] autorelease]; + + TEST(@"-[isEqual:]", [mutableString1 isEqual: mutableString3] && + ![mutableString1 isEqual: [[[OFObject alloc] init] autorelease]]) + + TEST(@"-[compare:]", + [mutableString1 compare: mutableString3] == OFOrderedSame && + [mutableString1 compare: @""] != OFOrderedSame && [C(@"") compare: @"a"] == OFOrderedAscending && [C(@"a") compare: @"b"] == OFOrderedAscending && [C(@"cd") compare: @"bc"] == OFOrderedDescending && [C(@"ä") compare: @"ö"] == OFOrderedAscending && [C(@"€") compare: @"ß"] == OFOrderedDescending && @@ -263,107 +264,114 @@ [stringClass stringWithUTF8String: "AbD"]] == [C(@"abc") compare: @"abd"]) #endif TEST(@"-[hash] is the same if -[isEqual:] is true", - s[0].hash == s[2].hash) + mutableString1.hash == mutableString3.hash) - TEST(@"-[description]", [s[0].description isEqual: s[0]]) + TEST(@"-[description]", + [mutableString1.description isEqual: mutableString1]) TEST(@"-[appendString:] and -[appendUTF8String:]", - R([s[1] appendUTF8String: "1𝄞"]) && R([s[1] appendString: @"3"]) && - R([s[0] appendString: s[1]]) && [s[0] isEqual: @"täs€1𝄞3"]) + R([mutableString2 appendUTF8String: "1𝄞"]) && + R([mutableString2 appendString: @"3"]) && + R([mutableString1 appendString: mutableString2]) && + [mutableString1 isEqual: @"täs€1𝄞3"]) TEST(@"-[appendCharacters:length:]", - R([s[1] appendCharacters: ucstr + 6 length: 2]) && - [s[1] isEqual: @"1𝄞3r🀺"]) + R([mutableString2 appendCharacters: unicharString + 6 length: 2]) && + [mutableString2 isEqual: @"1𝄞3r🀺"]) - TEST(@"-[length]", s[0].length == 7) - TEST(@"-[UTF8StringLength]", s[0].UTF8StringLength == 13) - TEST(@"-[hash]", s[0].hash == 0x705583C0) + TEST(@"-[length]", mutableString1.length == 7) + TEST(@"-[UTF8StringLength]", mutableString1.UTF8StringLength == 13) + TEST(@"-[hash]", mutableString1.hash == 0x705583C0) TEST(@"-[characterAtIndex:]", - [s[0] characterAtIndex: 0] == 't' && - [s[0] characterAtIndex: 1] == 0xE4 && - [s[0] characterAtIndex: 3] == 0x20AC && - [s[0] characterAtIndex: 5] == 0x1D11E) + [mutableString1 characterAtIndex: 0] == 't' && + [mutableString1 characterAtIndex: 1] == 0xE4 && + [mutableString1 characterAtIndex: 3] == 0x20AC && + [mutableString1 characterAtIndex: 5] == 0x1D11E) EXPECT_EXCEPTION(@"Detect out of range in -[characterAtIndex:]", - OFOutOfRangeException, [s[0] characterAtIndex: 7]) + OFOutOfRangeException, [mutableString1 characterAtIndex: 7]) - TEST(@"-[reverse]", R([s[0] reverse]) && [s[0] isEqual: @"3𝄞1€sät"]) + TEST(@"-[reverse]", + R([mutableString1 reverse]) && [mutableString1 isEqual: @"3𝄞1€sät"]) - s[1] = [mutableStringClass stringWithString: @"abc"]; + mutableString2 = [mutableStringClass stringWithString: @"abc"]; #ifdef OF_HAVE_UNICODE_TABLES - TEST(@"-[uppercase]", R([s[0] uppercase]) && - [s[0] isEqual: @"3𝄞1€SÄT"] && - R([s[1] uppercase]) && [s[1] isEqual: @"ABC"]) + TEST(@"-[uppercase]", R([mutableString1 uppercase]) && + [mutableString1 isEqual: @"3𝄞1€SÄT"] && + R([mutableString2 uppercase]) && [mutableString2 isEqual: @"ABC"]) - TEST(@"-[lowercase]", R([s[0] lowercase]) && - [s[0] isEqual: @"3𝄞1€sät"] && - R([s[1] lowercase]) && [s[1] isEqual: @"abc"]) + TEST(@"-[lowercase]", R([mutableString1 lowercase]) && + [mutableString1 isEqual: @"3𝄞1€sät"] && + R([mutableString2 lowercase]) && [mutableString2 isEqual: @"abc"]) TEST(@"-[uppercaseString]", - [[s[0] uppercaseString] isEqual: @"3𝄞1€SÄT"]) + [[mutableString1 uppercaseString] isEqual: @"3𝄞1€SÄT"]) - TEST(@"-[lowercaseString]", R([s[0] uppercase]) && - [[s[0] lowercaseString] isEqual: @"3𝄞1€sät"]) + TEST(@"-[lowercaseString]", R([mutableString1 uppercase]) && + [[mutableString1 lowercaseString] isEqual: @"3𝄞1€sät"]) TEST(@"-[capitalizedString]", [C(@"džbla tdžst TDŽST").capitalizedString isEqual: @"Džbla Tdžst Tdžst"]) #else - TEST(@"-[uppercase]", R([s[0] uppercase]) && - [s[0] isEqual: @"3𝄞1€SäT"] && - R([s[1] uppercase]) && [s[1] isEqual: @"ABC"]) - - TEST(@"-[lowercase]", R([s[0] lowercase]) && - [s[0] isEqual: @"3𝄞1€sät"] && - R([s[1] lowercase]) && [s[1] isEqual: @"abc"]) - - TEST(@"-[uppercaseString]", [s[0].uppercaseString isEqual: @"3𝄞1€SäT"]) - - TEST(@"-[lowercaseString]", R([s[0] uppercase]) && - [s[0].lowercaseString isEqual: @"3𝄞1€sät"]) + TEST(@"-[uppercase]", R([mutableString1 uppercase]) && + [mutableString1 isEqual: @"3𝄞1€SäT"] && + R([mutableString2 uppercase]) && [mutableString2 isEqual: @"ABC"]) + + TEST(@"-[lowercase]", R([mutableString1 lowercase]) && + [mutableString1 isEqual: @"3𝄞1€sät"] && + R([mutableString2 lowercase]) && [mutableString2 isEqual: @"abc"]) + + TEST(@"-[uppercaseString]", + [mutableString1.uppercaseString isEqual: @"3𝄞1€SäT"]) + + TEST(@"-[lowercaseString]", + R([mutableString1 uppercase]) && + [mutableString1.lowercaseString isEqual: @"3𝄞1€sät"]) TEST(@"-[capitalizedString]", [C(@"džbla tdžst TDŽST").capitalizedString isEqual: @"džbla Tdžst TDŽst"]) #endif TEST(@"+[stringWithUTF8String:length:]", - (s[0] = [mutableStringClass stringWithUTF8String: "\xEF\xBB\xBF" - "foobar" - length: 6]) && - [s[0] isEqual: @"foo"]) + (mutableString1 = [mutableStringClass + stringWithUTF8String: "\xEF\xBB\xBF" "foobar" + length: 6]) && + [mutableString1 isEqual: @"foo"]) TEST(@"+[stringWithUTF16String:]", - (is = [stringClass stringWithUTF16String: utf16str]) && - [is isEqual: @"fööbär🀺"] && - (is = [stringClass stringWithUTF16String: sutf16str]) && - [is isEqual: @"fööbär🀺"]) + (string = [stringClass stringWithUTF16String: UTF16String]) && + [string isEqual: @"fööbär🀺"] && + (string = [stringClass stringWithUTF16String: + swappedUTF16String]) && [string isEqual: @"fööbär🀺"]) TEST(@"+[stringWithUTF32String:]", - (is = [stringClass stringWithUTF32String: ucstr]) && - [is isEqual: @"fööbär🀺"] && - (is = [stringClass stringWithUTF32String: sucstr]) && - [is isEqual: @"fööbär🀺"]) + (string = [stringClass stringWithUTF32String: unicharString]) && + [string isEqual: @"fööbär🀺"] && + (string = [stringClass stringWithUTF32String: + swappedUnicharString]) && [string isEqual: @"fööbär🀺"]) #ifdef OF_HAVE_FILES - TEST(@"+[stringWithContentsOfFile:encoding]", (is = [stringClass + TEST(@"+[stringWithContentsOfFile:encoding]", (string = [stringClass stringWithContentsOfFile: @"testfile.txt" encoding: OFStringEncodingISO8859_1]) && - [is isEqual: @"testäöü"]) + [string isEqual: @"testäöü"]) - TEST(@"+[stringWithContentsOfURL:encoding]", (is = [stringClass + TEST(@"+[stringWithContentsOfURL:encoding]", (string = [stringClass stringWithContentsOfURL: [OFURL fileURLWithPath: @"testfile.txt"] encoding: OFStringEncodingISO8859_1]) && - [is isEqual: @"testäöü"]) + [string isEqual: @"testäöü"]) #endif TEST(@"-[appendUTFString:length:]", - R([s[0] appendUTF8String: "\xEF\xBB\xBF" "barqux" length: 6]) && - [s[0] isEqual: @"foobar"]) + R([mutableString1 appendUTF8String: "\xEF\xBB\xBF" "barqux" + length: 6]) && + [mutableString1 isEqual: @"foobar"]) EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #1", OFInvalidEncodingException, [stringClass stringWithUTF8String: "\xE0\x80"]) EXPECT_EXCEPTION(@"Detection of invalid UTF-8 encoding #2", @@ -473,17 +481,18 @@ !strcmp([C(@"T€st strîng ░▒▓") lossyCStringWithEncoding: OFStringEncodingCodepage437], "T?st str\x8Cng \xB0\xB1\xB2")) #endif TEST(@"+[stringWithFormat:]", - [(s[0] = [mutableStringClass stringWithFormat: @"%@:%d", @"test", - 123]) + [(mutableString1 = [mutableStringClass stringWithFormat: @"%@:%d", + @"test", + 123]) isEqual: @"test:123"]) TEST(@"-[appendFormat:]", - R(([s[0] appendFormat: @"%02X", 15])) && - [s[0] isEqual: @"test:1230F"]) + R(([mutableString1 appendFormat: @"%02X", 15])) && + [mutableString1 isEqual: @"test:1230F"]) TEST(@"-[rangeOfString:]", [C(@"𝄞öö") rangeOfString: @"öö"].location == 1 && [C(@"𝄞öö") rangeOfString: @"ö"].location == 1 && [C(@"𝄞öö") rangeOfString: @"𝄞"].location == 0 && @@ -500,29 +509,29 @@ EXPECT_EXCEPTION( @"Detect out of range in -[rangeOfString:options:range:]", OFOutOfRangeException, [C(@"𝄞öö") rangeOfString: @"ö" options: 0 range: OFRangeMake(3, 1)]) - cs = [OFCharacterSet characterSetWithCharactersInString: @"cđ"]; + characterSet = + [OFCharacterSet characterSetWithCharactersInString: @"cđ"]; TEST(@"-[indexOfCharacterFromSet:]", - [C(@"abcđabcđe") indexOfCharacterFromSet: cs] == 2 && - [C(@"abcđabcđë") - indexOfCharacterFromSet: cs - options: OFStringSearchBackwards] == 7 && - [C(@"abcđabcđë") - indexOfCharacterFromSet: cs - options: 0 - range: OFRangeMake(4, 4)] == 6 && - [C(@"abcđabcđëf") - indexOfCharacterFromSet: cs - options: 0 - range: OFRangeMake(8, 2)] == OFNotFound) + [C(@"abcđabcđe") indexOfCharacterFromSet: characterSet] == 2 && + [C(@"abcđabcđë") + indexOfCharacterFromSet: characterSet + options: OFStringSearchBackwards] == 7 && + [C(@"abcđabcđë") indexOfCharacterFromSet: characterSet + options: 0 + range: OFRangeMake(4, 4)] == 6 && + [C(@"abcđabcđëf") + indexOfCharacterFromSet: characterSet + options: 0 + range: OFRangeMake(8, 2)] == OFNotFound) EXPECT_EXCEPTION( @"Detect out of range in -[indexOfCharacterFromSet:options:range:]", OFOutOfRangeException, - [C(@"𝄞öö") indexOfCharacterFromSet: cs + [C(@"𝄞öö") indexOfCharacterFromSet: characterSet options: 0 range: OFRangeMake(3, 1)]) TEST(@"-[substringWithRange:]", [[C(@"𝄞öö") substringWithRange: OFRangeMake(1, 1)] isEqual: @"ö"] && @@ -563,28 +572,30 @@ TEST(@"-[isAbsolutePath]", C(@"/foo").absolutePath && C(@"/foo/bar").absolutePath && !C(@"foo/bar").absolutePath && !C(@"foo").absolutePath) # endif - s[0] = [mutableStringClass stringWithString: @"foo"]; -# if defined(OF_WINDOWS) || defined(OF_MSDOS) - [s[0] appendString: @"\\"]; -# else - [s[0] appendString: @"/"]; -# endif - [s[0] appendString: @"bar"]; - s[1] = [mutableStringClass stringWithString: s[0]]; -# if defined(OF_WINDOWS) || defined(OF_MSDOS) - [s[1] appendString: @"\\"]; -# else - [s[1] appendString: @"/"]; -# endif - is = [stringClass stringWithString: s[1]]; - [s[1] appendString: @"baz"]; - TEST(@"-[stringByAppendingPathComponent:]", - [[s[0] stringByAppendingPathComponent: @"baz"] isEqual: s[1]] && - [[is stringByAppendingPathComponent: @"baz"] isEqual: s[1]]) + mutableString1 = [mutableStringClass stringWithString: @"foo"]; +# if defined(OF_WINDOWS) || defined(OF_MSDOS) + [mutableString1 appendString: @"\\"]; +# else + [mutableString1 appendString: @"/"]; +# endif + [mutableString1 appendString: @"bar"]; + mutableString2 = [mutableStringClass stringWithString: mutableString1]; +# if defined(OF_WINDOWS) || defined(OF_MSDOS) + [mutableString2 appendString: @"\\"]; +# else + [mutableString2 appendString: @"/"]; +# endif + string = [stringClass stringWithString: mutableString2]; + [mutableString2 appendString: @"baz"]; + TEST(@"-[stringByAppendingPathComponent:]", + [[mutableString1 stringByAppendingPathComponent: @"baz"] + isEqual: mutableString2] && + [[string stringByAppendingPathComponent: @"baz"] + isEqual: mutableString2]) #endif TEST(@"-[hasPrefix:]", [C(@"foobar") hasPrefix: @"foo"] && ![C(@"foobar") hasPrefix: @"foobar0"]) @@ -591,61 +602,62 @@ TEST(@"-[hasSuffix:]", [C(@"foobar") hasSuffix: @"bar"] && ![C(@"foobar") hasSuffix: @"foobar0"]) i = 0; TEST(@"-[componentsSeparatedByString:]", - (a = [C(@"fooXXbarXXXXbazXXXX") + (array = [C(@"fooXXbarXXXXbazXXXX") componentsSeparatedByString: @"XX"]) && - [[a objectAtIndex: i++] isEqual: @"foo"] && - [[a objectAtIndex: i++] isEqual: @"bar"] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @"baz"] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @""] && - a.count == i && - (a = [C(@"foo") componentsSeparatedByString: @""]) && - [[a objectAtIndex: 0] isEqual: @"foo"] && - a.count == 1) + [[array objectAtIndex: i++] isEqual: @"foo"] && + [[array objectAtIndex: i++] isEqual: @"bar"] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @"baz"] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @""] && + array.count == i && + (array = [C(@"foo") componentsSeparatedByString: @""]) && + [[array objectAtIndex: 0] isEqual: @"foo"] && + array.count == 1) i = 0; TEST(@"-[componentsSeparatedByString:options:]", - (a = [C(@"fooXXbarXXXXbazXXXX") + (array = [C(@"fooXXbarXXXXbazXXXX") componentsSeparatedByString: @"XX" options: OFStringSkipEmptyComponents]) && - [[a objectAtIndex: i++] isEqual: @"foo"] && - [[a objectAtIndex: i++] isEqual: @"bar"] && - [[a objectAtIndex: i++] isEqual: @"baz"] && - a.count == i) + [[array objectAtIndex: i++] isEqual: @"foo"] && + [[array objectAtIndex: i++] isEqual: @"bar"] && + [[array objectAtIndex: i++] isEqual: @"baz"] && + array.count == i) - cs = [OFCharacterSet characterSetWithCharactersInString: @"XYZ"]; + characterSet = + [OFCharacterSet characterSetWithCharactersInString: @"XYZ"]; i = 0; TEST(@"-[componentsSeparatedByCharactersInSet:]", - (a = [C(@"fooXYbarXYZXbazXYXZx") - componentsSeparatedByCharactersInSet: cs]) && - [[a objectAtIndex: i++] isEqual: @"foo"] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @"bar"] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @"baz"] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @""] && - [[a objectAtIndex: i++] isEqual: @"x"] && - a.count == i) + (array = [C(@"fooXYbarXYZXbazXYXZx") + componentsSeparatedByCharactersInSet: characterSet]) && + [[array objectAtIndex: i++] isEqual: @"foo"] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @"bar"] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @"baz"] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @""] && + [[array objectAtIndex: i++] isEqual: @"x"] && + array.count == i) i = 0; TEST(@"-[componentsSeparatedByCharactersInSet:options:]", - (a = [C(@"fooXYbarXYZXbazXYXZ") - componentsSeparatedByCharactersInSet: cs + (array = [C(@"fooXYbarXYZXbazXYXZ") + componentsSeparatedByCharactersInSet: characterSet options: OFStringSkipEmptyComponents]) && - [[a objectAtIndex: i++] isEqual: @"foo"] && - [[a objectAtIndex: i++] isEqual: @"bar"] && - [[a objectAtIndex: i++] isEqual: @"baz"] && - a.count == i) + [[array objectAtIndex: i++] isEqual: @"foo"] && + [[array objectAtIndex: i++] isEqual: @"bar"] && + [[array objectAtIndex: i++] isEqual: @"baz"] && + array.count == i) #ifdef OF_HAVE_FILES # if defined(OF_WINDOWS) TEST(@"+[pathWithComponents:]", [[stringClass pathWithComponents: [OFArray arrayWithObjects: @@ -746,151 +758,151 @@ # endif # if defined(OF_WINDOWS) TEST(@"-[pathComponents]", /* c:/tmp */ - (a = C(@"c:/tmp").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"c:/"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"c:/tmp").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"c:/"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* c:\tmp\ */ - (a = C(@"c:\\tmp\\").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"c:\\"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"c:\\tmp\\").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"c:\\"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* c:\ */ - (a = C(@"c:\\").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"c:\\"] && + (array = C(@"c:\\").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"c:\\"] && /* c:/ */ - (a = C(@"c:/").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"c:/"] && + (array = C(@"c:/").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"c:/"] && /* c: */ - (a = C(@"c:").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"c:"] && + (array = C(@"c:").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"c:"] && /* foo\bar */ - (a = C(@"foo\\bar").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && + (array = C(@"foo\\bar").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && /* foo\bar/baz/ */ - (a = C(@"foo\\bar/baz/").pathComponents) && a.count == 3 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && - [[a objectAtIndex: 2] isEqual: @"baz"] && + (array = C(@"foo\\bar/baz/").pathComponents) && array.count == 3 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && + [[array objectAtIndex: 2] isEqual: @"baz"] && /* foo\/ */ - (a = C(@"foo\\/").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"foo"] && + (array = C(@"foo\\/").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"foo"] && /* \\foo\bar */ - (a = C(@"\\\\foo\\bar").pathComponents) && a.count == 3 && - [[a objectAtIndex: 0] isEqual: @"\\\\"] && - [[a objectAtIndex: 1] isEqual: @"foo"] && - [[a objectAtIndex: 2] isEqual: @"bar"] && + (array = C(@"\\\\foo\\bar").pathComponents) && array.count == 3 && + [[array objectAtIndex: 0] isEqual: @"\\\\"] && + [[array objectAtIndex: 1] isEqual: @"foo"] && + [[array objectAtIndex: 2] isEqual: @"bar"] && C(@"").pathComponents.count == 0) # elif defined(OF_MSDOS) TEST(@"-[pathComponents]", /* c:/tmp */ - (a = C(@"c:/tmp").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"c:/"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"c:/tmp").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"c:/"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* c:\tmp\ */ - (a = C(@"c:\\tmp\\").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"c:\\"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"c:\\tmp\\").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"c:\\"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* c:\ */ - (a = C(@"c:\\").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"c:\\"] && + (array = C(@"c:\\").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"c:\\"] && /* c:/ */ - (a = C(@"c:/").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"c:/"] && + (array = C(@"c:/").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"c:/"] && /* c: */ - (a = C(@"c:").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"c:"] && + (array = C(@"c:").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"c:"] && /* foo\bar */ - (a = C(@"foo\\bar").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && + (array = C(@"foo\\bar").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && /* foo\bar/baz/ */ - (a = C(@"foo\\bar/baz/").pathComponents) && a.count == 3 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && - [[a objectAtIndex: 2] isEqual: @"baz"] && + (array = C(@"foo\\bar/baz/").pathComponents) && array.count == 3 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && + [[array objectAtIndex: 2] isEqual: @"baz"] && /* foo\/ */ - (a = C(@"foo\\/").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"foo"] && + (array = C(@"foo\\/").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"foo"] && C(@"").pathComponents.count == 0) # elif defined(OF_AMIGAOS) TEST(@"-[pathComponents]", /* dh0:tmp */ - (a = C(@"dh0:tmp").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"dh0:"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"dh0:tmp").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"dh0:"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* dh0:tmp/ */ - (a = C(@"dh0:tmp/").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"dh0:"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"dh0:tmp/").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"dh0:"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* dh0: */ - (a = C(@"dh0:/").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"dh0:"] && - [[a objectAtIndex: 1] isEqual: @"/"] && + (array = C(@"dh0:/").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"dh0:"] && + [[array objectAtIndex: 1] isEqual: @"/"] && /* foo/bar */ - (a = C(@"foo/bar").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && + (array = C(@"foo/bar").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && /* foo/bar/baz/ */ - (a = C(@"foo/bar/baz/").pathComponents) && a.count == 3 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && - [[a objectAtIndex: 2] isEqual: @"baz"] && + (array = C(@"foo/bar/baz/").pathComponents) && array.count == 3 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && + [[array objectAtIndex: 2] isEqual: @"baz"] && /* foo// */ - (a = C(@"foo//").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"/"] && + (array = C(@"foo//").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"/"] && C(@"").pathComponents.count == 0) # elif defined(OF_NINTENDO_3DS) || defined(OF_WII) TEST(@"-[pathComponents]", /* sdmc:/tmp */ - (a = C(@"sdmc:/tmp").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"sdmc:"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"sdmc:/tmp").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"sdmc:"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* sdmc:/ */ - (a = C(@"sdmc:/").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"sdmc:"] && + (array = C(@"sdmc:/").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"sdmc:"] && /* foo/bar */ - (a = C(@"foo/bar").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && + (array = C(@"foo/bar").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && /* foo/bar/baz/ */ - (a = C(@"foo/bar/baz/").pathComponents) && a.count == 3 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && - [[a objectAtIndex: 2] isEqual: @"baz"] && + (array = C(@"foo/bar/baz/").pathComponents) && array.count == 3 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && + [[array objectAtIndex: 2] isEqual: @"baz"] && /* foo// */ - (a = C(@"foo//").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"foo"] && + (array = C(@"foo//").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"foo"] && C(@"").pathComponents.count == 0) # else TEST(@"-[pathComponents]", /* /tmp */ - (a = C(@"/tmp").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"/"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"/tmp").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"/"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* /tmp/ */ - (a = C(@"/tmp/").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"/"] && - [[a objectAtIndex: 1] isEqual: @"tmp"] && + (array = C(@"/tmp/").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"/"] && + [[array objectAtIndex: 1] isEqual: @"tmp"] && /* / */ - (a = C(@"/").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"/"] && + (array = C(@"/").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"/"] && /* foo/bar */ - (a = C(@"foo/bar").pathComponents) && a.count == 2 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && + (array = C(@"foo/bar").pathComponents) && array.count == 2 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && /* foo/bar/baz/ */ - (a = C(@"foo/bar/baz/").pathComponents) && a.count == 3 && - [[a objectAtIndex: 0] isEqual: @"foo"] && - [[a objectAtIndex: 1] isEqual: @"bar"] && - [[a objectAtIndex: 2] isEqual: @"baz"] && + (array = C(@"foo/bar/baz/").pathComponents) && array.count == 3 && + [[array objectAtIndex: 0] isEqual: @"foo"] && + [[array objectAtIndex: 1] isEqual: @"bar"] && + [[array objectAtIndex: 2] isEqual: @"baz"] && /* foo// */ - (a = C(@"foo//").pathComponents) && a.count == 1 && - [[a objectAtIndex: 0] isEqual: @"foo"] && + (array = C(@"foo//").pathComponents) && array.count == 1 && + [[array objectAtIndex: 0] isEqual: @"foo"] && C(@"").pathComponents.count == 0) # endif # if defined(OF_WINDOWS) TEST(@"-[lastPathComponent]", @@ -1183,31 +1195,35 @@ OFOutOfRangeException, [C(@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF") unsignedLongLongValueWithBase: 16]) - TEST(@"-[characters]", (ua = C(@"fööbär🀺").characters) && - !memcmp(ua, ucstr + 1, sizeof(ucstr) - 8)) + TEST(@"-[characters]", (characters = C(@"fööbär🀺").characters) && + !memcmp(characters, unicharString + 1, sizeof(unicharString) - 8)) #ifdef OF_BIG_ENDIAN # define SWAPPED_BYTE_ORDER OFByteOrderLittleEndian #else # define SWAPPED_BYTE_ORDER OFByteOrderBigEndian #endif - TEST(@"-[UTF16String]", (u16a = C(@"fööbär🀺").UTF16String) && - !memcmp(u16a, utf16str + 1, OFUTF16StringLength(utf16str) * 2) && - (u16a = [C(@"fööbär🀺") + TEST(@"-[UTF16String]", (UTF16Characters = C(@"fööbär🀺").UTF16String) && + !memcmp(UTF16Characters, UTF16String + 1, + OFUTF16StringLength(UTF16String) * 2) && + (UTF16Characters = [C(@"fööbär🀺") UTF16StringWithByteOrder: SWAPPED_BYTE_ORDER]) && - !memcmp(u16a, sutf16str + 1, OFUTF16StringLength(sutf16str) * 2)) + !memcmp(UTF16Characters, swappedUTF16String + 1, + OFUTF16StringLength(swappedUTF16String) * 2)) TEST(@"-[UTF16StringLength]", C(@"fööbär🀺").UTF16StringLength == 8) - TEST(@"-[UTF32String]", (ua = C(@"fööbär🀺").UTF32String) && - !memcmp(ua, ucstr + 1, OFUTF32StringLength(ucstr) * 4) && - (ua = [C(@"fööbär🀺") UTF32StringWithByteOrder: + TEST(@"-[UTF32String]", (characters = C(@"fööbär🀺").UTF32String) && + !memcmp(characters, unicharString + 1, + OFUTF32StringLength(unicharString) * 4) && + (characters = [C(@"fööbär🀺") UTF32StringWithByteOrder: SWAPPED_BYTE_ORDER]) && - !memcmp(ua, sucstr + 1, OFUTF32StringLength(sucstr) * 4)) + !memcmp(characters, swappedUnicharString + 1, + OFUTF32StringLength(swappedUnicharString) * 4)) #undef SWAPPED_BYTE_ORDER TEST(@"-[stringByMD5Hashing]", [C(@"asdfoobar").stringByMD5Hashing isEqual: @"184dce2ec49b5422c7cfd8728864db4c"]) @@ -1233,118 +1249,138 @@ TEST(@"-[stringBySHA512Hashing]", [C(@"asdfoobar").stringBySHA512Hashing isEqual: @"0464c427da158b02161bb44a3090bbfc594611ef6a53603640454b56" @"412a9247c3579a329e53a5dc74676b106755e3394f9454a2d4227324" @"2615d32f80437d61"]) - cs = [OFCharacterSet characterSetWithCharactersInString: @"abfo'_~$🍏"]; + characterSet = + [OFCharacterSet characterSetWithCharactersInString: @"abfo'_~$🍏"]; TEST(@"-[stringByURLEncodingWithAllowedCharacters:]", [[C(@"foo\"ba'_~$]🍏🍌") stringByURLEncodingWithAllowedCharacters: - cs] isEqual: @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C"]) + characterSet] isEqual: @"foo%22ba'_~$%5D🍏%F0%9F%8D%8C"]) TEST(@"-[stringByURLDecoding]", [C(@"foo%20bar%22+%24%F0%9F%8D%8C").stringByURLDecoding isEqual: @"foo bar\"+$🍌"]) TEST(@"-[insertString:atIndex:]", - (s[0] = [mutableStringClass stringWithString: @"𝄞öööbä€"]) && - R([s[0] insertString: @"äöü" atIndex: 3]) && - [s[0] isEqual: @"𝄞ööäöüöbä€"]) + (mutableString1 = [mutableStringClass + stringWithString: @"𝄞öööbä€"]) && + R([mutableString1 insertString: @"äöü" atIndex: 3]) && + [mutableString1 isEqual: @"𝄞ööäöüöbä€"]) EXPECT_EXCEPTION(@"Detect invalid format in -[stringByURLDecoding] " @"#1", OFInvalidFormatException, [C(@"foo%xbar") stringByURLDecoding]) EXPECT_EXCEPTION(@"Detect invalid encoding in -[stringByURLDecoding] " @"#2", OFInvalidEncodingException, [C(@"foo%FFbar") stringByURLDecoding]) TEST(@"-[setCharacter:atIndex:]", - (s[0] = [mutableStringClass stringWithString: @"abäde"]) && - R([s[0] setCharacter: 0xF6 atIndex: 2]) && - [s[0] isEqual: @"aböde"] && - R([s[0] setCharacter: 'c' atIndex: 2]) && - [s[0] isEqual: @"abcde"] && - R([s[0] setCharacter: 0x20AC atIndex: 3]) && - [s[0] isEqual: @"abc€e"] && - R([s[0] setCharacter: 'x' atIndex: 1]) && [s[0] isEqual: @"axc€e"]) + (mutableString1 = [mutableStringClass + stringWithString: @"abäde"]) && + R([mutableString1 setCharacter: 0xF6 atIndex: 2]) && + [mutableString1 isEqual: @"aböde"] && + R([mutableString1 setCharacter: 'c' atIndex: 2]) && + [mutableString1 isEqual: @"abcde"] && + R([mutableString1 setCharacter: 0x20AC atIndex: 3]) && + [mutableString1 isEqual: @"abc€e"] && + R([mutableString1 setCharacter: 'x' atIndex: 1]) && + [mutableString1 isEqual: @"axc€e"]) TEST(@"-[deleteCharactersInRange:]", - (s[0] = [mutableStringClass stringWithString: @"𝄞öööbä€"]) && - R([s[0] deleteCharactersInRange: OFRangeMake(1, 3)]) && - [s[0] isEqual: @"𝄞bä€"] && - R([s[0] deleteCharactersInRange: OFRangeMake(0, 4)]) && - [s[0] isEqual: @""]) + (mutableString1 = [mutableStringClass + stringWithString: @"𝄞öööbä€"]) && + R([mutableString1 deleteCharactersInRange: OFRangeMake(1, 3)]) && + [mutableString1 isEqual: @"𝄞bä€"] && + R([mutableString1 deleteCharactersInRange: OFRangeMake(0, 4)]) && + [mutableString1 isEqual: @""]) TEST(@"-[replaceCharactersInRange:withString:]", - (s[0] = [mutableStringClass stringWithString: @"𝄞öööbä€"]) && - R([s[0] replaceCharactersInRange: OFRangeMake(1, 3) - withString: @"äöüß"]) && - [s[0] isEqual: @"𝄞äöüßbä€"] && - R([s[0] replaceCharactersInRange: OFRangeMake(4, 2) - withString: @"b"]) && - [s[0] isEqual: @"𝄞äöübä€"] && - R([s[0] replaceCharactersInRange: OFRangeMake(0, 7) - withString: @""]) && - [s[0] isEqual: @""]) + (mutableString1 = [mutableStringClass + stringWithString: @"𝄞öööbä€"]) && + R([mutableString1 replaceCharactersInRange: OFRangeMake(1, 3) + withString: @"äöüß"]) && + [mutableString1 isEqual: @"𝄞äöüßbä€"] && + R([mutableString1 replaceCharactersInRange: OFRangeMake(4, 2) + withString: @"b"]) && + [mutableString1 isEqual: @"𝄞äöübä€"] && + R([mutableString1 replaceCharactersInRange: OFRangeMake(0, 7) + withString: @""]) && + [mutableString1 isEqual: @""]) EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #1", OFOutOfRangeException, { - s[0] = [mutableStringClass stringWithString: @"𝄞öö"]; - [s[0] deleteCharactersInRange: OFRangeMake(2, 2)]; + mutableString1 = [mutableStringClass stringWithString: @"𝄞öö"]; + [mutableString1 deleteCharactersInRange: OFRangeMake(2, 2)]; }) EXPECT_EXCEPTION(@"Detect OoR in -[deleteCharactersInRange:] #2", OFOutOfRangeException, - [s[0] deleteCharactersInRange: OFRangeMake(4, 0)]) + [mutableString1 deleteCharactersInRange: OFRangeMake(4, 0)]) EXPECT_EXCEPTION(@"Detect OoR in " @"-[replaceCharactersInRange:withString:] #1", OFOutOfRangeException, - [s[0] replaceCharactersInRange: OFRangeMake(2, 2) withString: @""]) + [mutableString1 replaceCharactersInRange: OFRangeMake(2, 2) + withString: @""]) EXPECT_EXCEPTION(@"Detect OoR in " @"-[replaceCharactersInRange:withString:] #2", OFOutOfRangeException, - [s[0] replaceCharactersInRange: OFRangeMake(4, 0) withString: @""]) + [mutableString1 replaceCharactersInRange: OFRangeMake(4, 0) + withString: @""]) TEST(@"-[replaceOccurrencesOfString:withString:]", - (s[0] = [mutableStringClass stringWithString: + (mutableString1 = [mutableStringClass stringWithString: @"asd fo asd fofo asd"]) && - R([s[0] replaceOccurrencesOfString: @"fo" withString: @"foo"]) && - [s[0] isEqual: @"asd foo asd foofoo asd"] && - (s[0] = [mutableStringClass stringWithString: @"XX"]) && - R([s[0] replaceOccurrencesOfString: @"X" withString: @"XX"]) && - [s[0] isEqual: @"XXXX"]) + R([mutableString1 replaceOccurrencesOfString: @"fo" + withString: @"foo"]) && + [mutableString1 isEqual: @"asd foo asd foofoo asd"] && + (mutableString1 = [mutableStringClass stringWithString: @"XX"]) && + R([mutableString1 replaceOccurrencesOfString: @"X" + withString: @"XX"]) && + [mutableString1 isEqual: @"XXXX"]) TEST(@"-[replaceOccurrencesOfString:withString:options:range:]", - (s[0] = [mutableStringClass stringWithString: - @"foofoobarfoobarfoo"]) && - R([s[0] replaceOccurrencesOfString: @"oo" - withString: @"óò" - options: 0 - range: OFRangeMake(2, 15)]) && - [s[0] isEqual: @"foofóòbarfóòbarfoo"]) + (mutableString1 = [mutableStringClass stringWithString: + @"foofoobarfoobarfoo"]) && R([mutableString1 + replaceOccurrencesOfString: @"oo" + withString: @"óò" + options: 0 + range: OFRangeMake(2, 15)]) && + [mutableString1 isEqual: @"foofóòbarfóòbarfoo"]) TEST(@"-[deleteLeadingWhitespaces]", - (s[0] = [mutableStringClass stringWithString: whitespace[0]]) && - R([s[0] deleteLeadingWhitespaces]) && - [s[0] isEqual: @"asd \t \t\t\r\n"] && - (s[0] = [mutableStringClass stringWithString: whitespace[1]]) && - R([s[0] deleteLeadingWhitespaces]) && [s[0] isEqual: @""]) + (mutableString1 = [mutableStringClass + stringWithString: whitespace[0]]) && + R([mutableString1 deleteLeadingWhitespaces]) && + [mutableString1 isEqual: @"asd \t \t\t\r\n"] && + (mutableString1 = [mutableStringClass + stringWithString: whitespace[1]]) && + R([mutableString1 deleteLeadingWhitespaces]) && + [mutableString1 isEqual: @""]) TEST(@"-[deleteTrailingWhitespaces]", - (s[0] = [mutableStringClass stringWithString: whitespace[0]]) && - R([s[0] deleteTrailingWhitespaces]) && - [s[0] isEqual: @" \r \t\n\t \tasd"] && - (s[0] = [mutableStringClass stringWithString: whitespace[1]]) && - R([s[0] deleteTrailingWhitespaces]) && [s[0] isEqual: @""]) + (mutableString1 = [mutableStringClass + stringWithString: whitespace[0]]) && + R([mutableString1 deleteTrailingWhitespaces]) && + [mutableString1 isEqual: @" \r \t\n\t \tasd"] && + (mutableString1 = [mutableStringClass + stringWithString: whitespace[1]]) && + R([mutableString1 deleteTrailingWhitespaces]) && + [mutableString1 isEqual: @""]) TEST(@"-[deleteEnclosingWhitespaces]", - (s[0] = [mutableStringClass stringWithString: whitespace[0]]) && - R([s[0] deleteEnclosingWhitespaces]) && [s[0] isEqual: @"asd"] && - (s[0] = [mutableStringClass stringWithString: whitespace[1]]) && - R([s[0] deleteEnclosingWhitespaces]) && [s[0] isEqual: @""]) + (mutableString1 = [mutableStringClass + stringWithString: whitespace[0]]) && + R([mutableString1 deleteEnclosingWhitespaces]) && + [mutableString1 isEqual: @"asd"] && + (mutableString1 = [mutableStringClass + stringWithString: whitespace[1]]) && + R([mutableString1 deleteEnclosingWhitespaces]) && + [mutableString1 isEqual: @""]) #ifdef OF_HAVE_UNICODE_TABLES TEST(@"-[decomposedStringWithCanonicalMapping]", [C(@"H\xC3\xA4llj\xC3\xB6").decomposedStringWithCanonicalMapping isEqual: @"H\x61\xCC\x88llj\x6F\xCC\x88"]); @@ -1353,15 +1389,15 @@ [C(@"H\xC3\xA4llj\xC3\xB6").decomposedStringWithCompatibilityMapping isEqual: @"H\x61\xCC\x88llj\x6F\xCC\x88"]); #endif TEST(@"-[stringByXMLEscaping]", - (is = C(@" &world'\"!&").stringByXMLEscaping) && - [is isEqual: @"<hello> &world'"!&"]) + (string = C(@" &world'\"!&").stringByXMLEscaping) && + [string isEqual: @"<hello> &world'"!&"]) TEST(@"-[stringByXMLUnescaping]", - [is.stringByXMLUnescaping isEqual: @" &world'\"!&"] && + [string.stringByXMLUnescaping isEqual: @" &world'\"!&"] && [C(@"y").stringByXMLUnescaping isEqual: @"y"] && [C(@"ä").stringByXMLUnescaping isEqual: @"ä"] && [C(@"€").stringByXMLUnescaping isEqual: @"€"] && [C(@"𝄞").stringByXMLUnescaping isEqual: @"𝄞"]) @@ -1379,18 +1415,18 @@ EXPECT_EXCEPTION(@"Detect invalid entities in -[stringByXMLUnescaping] " @"#5", OFInvalidFormatException, [C(@"&#xg;") stringByXMLUnescaping]) TEST(@"-[stringByXMLUnescapingWithDelegate:]", - (h = [[[EntityHandler alloc] init] autorelease]) && - [[C(@"x&foo;y") stringByXMLUnescapingWithDelegate: h] + (entityHandler = [[[EntityHandler alloc] init] autorelease]) && + [[C(@"x&foo;y") stringByXMLUnescapingWithDelegate: entityHandler] isEqual: @"xbary"]) #ifdef OF_HAVE_BLOCKS TEST(@"-[stringByXMLUnescapingWithBlock:]", [[C(@"x&foo;y") stringByXMLUnescapingWithBlock: - ^ OFString *(OFString *str, OFString *entity) { + ^ OFString *(OFString *str, OFString *entity) { if ([entity isEqual: @"foo"]) return @"bar"; return nil; }] isEqual: @"xbary"])