Add another test that makes it easier to debug string errors.

This commit is contained in:
David Chisnall 2018-05-22 17:52:39 +01:00
parent e5fcc2fab9
commit 3f928e32ff

View file

@ -476,6 +476,23 @@ int main()
res = [indianLong rangeOfString: indianShort options: NSCaseInsensitiveSearch|NSBackwardsSearch];
PASS(NSNotFound == res.location, "unicode not found backwards insensitive")
for (int i=0 ; i<[indianLong length] ; i++)
{
PASS([ls characterAtIndex: i] == [indianLong characterAtIndex: i], "Characters match");
NSRange r1 = [ls rangeOfComposedCharacterSequenceAtIndex: i];
NSRange r2 = [indianLong rangeOfComposedCharacterSequenceAtIndex: i];
PASS(r1.location == r2.location, "Composed characters start at the same place");
PASS(r1.length == r2.length, "Composed characters have the same lengths");
assert(r1.length < 5);
unichar buf1[5];
unichar buf2[5];
[ls getCharacters: buf1 range: r1];
[indianLong getCharacters: buf2 range: r2];
for (int j=0 ; j<r1.length ; j++)
{
PASS(buf1[j] == buf2[j], "Characters match when accessed by range");
}
}
res = [ls rangeOfString: indianLong options: 0];
PASS(0 == res.location, "unicode found at start simple")
res = [ls rangeOfString: indianLong options: NSCaseInsensitiveSearch];