mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
* Tests/base/NSString/test00.m: Add David Chisnall's test from
newapi branch slightly reformatted.
This commit is contained in:
parent
3b63a0d1f4
commit
b36412d20f
2 changed files with 31 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
2018-06-28 Fred Kiefer <fredkiefer@gmx.de>
|
||||
|
||||
* Source/NSString.m: Small cleanup for printf registration.
|
||||
* Tests/base/NSString/test00.m: Add David Chisnall's test from
|
||||
newapi branch slightly reformatted.
|
||||
|
||||
2018-06-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSCharacterSet.h>
|
||||
|
||||
#ifdef GNUSTEP_BASE_LIBRARY
|
||||
@interface NSString (Test)
|
||||
- (NSString*) _unicodeString;
|
||||
@end
|
||||
#endif
|
||||
|
||||
static BOOL rangesEqual(NSRange r1, NSRange r2)
|
||||
{
|
||||
if (&r1 == &r2)
|
||||
|
@ -464,6 +470,7 @@ int main()
|
|||
NSString *sl = [indianShort stringByAppendingString: indianLong];
|
||||
NSString *lsl = [ls stringByAppendingString: indianLong];
|
||||
NSRange res;
|
||||
int i, j;
|
||||
|
||||
res = [indianLong rangeOfString: indianLong options: 0];
|
||||
PASS(0 == res.location, "unicode whole string match")
|
||||
|
@ -476,6 +483,28 @@ int main()
|
|||
res = [indianLong rangeOfString: indianShort options: NSCaseInsensitiveSearch|NSBackwardsSearch];
|
||||
PASS(NSNotFound == res.location, "unicode not found backwards insensitive")
|
||||
|
||||
for (i = 0; i < [indianLong length]; i++)
|
||||
{
|
||||
unichar buf1[5];
|
||||
unichar buf2[5];
|
||||
NSRange r1;
|
||||
NSRange r2;
|
||||
|
||||
PASS([ls characterAtIndex: i] == [indianLong characterAtIndex: i], "Characters match");
|
||||
r1 = [ls rangeOfComposedCharacterSequenceAtIndex: i];
|
||||
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);
|
||||
|
||||
[ls getCharacters: buf1 range: r1];
|
||||
[indianLong getCharacters: buf2 range: r2];
|
||||
for (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];
|
||||
|
|
Loading…
Reference in a new issue