mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-10 16:20:42 +00:00
* Source/GSString.m: Move the method _unicodeString from here...
* Tests/base/NSString/test00.m: ...to here.
This commit is contained in:
parent
760d6ad990
commit
ab60bab84a
3 changed files with 27 additions and 106 deletions
|
@ -4,6 +4,8 @@
|
|||
* Tests/base/NSString/test00.m: Add David Chisnall's test from
|
||||
newapi branch slightly reformatted.
|
||||
* Source/GSString.m: Remove code that was identical to super class.
|
||||
* Source/GSString.m: Move the method _unicodeString from here...
|
||||
* Tests/base/NSString/test00.m: ...to here.
|
||||
|
||||
2018-06-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -1100,23 +1100,6 @@ tsbytes(uintptr_t s, char *buf)
|
|||
return 8;
|
||||
}
|
||||
|
||||
/* This method is provided to enable regression tests to ensure they are
|
||||
* using an object whose internal representation is wide (unicode) text,
|
||||
* so that all the comparison operations between 8bit and 16bit strings
|
||||
* can be tested.
|
||||
*/
|
||||
- (NSString*) _unicodeString
|
||||
{
|
||||
GSUInlineString *o;
|
||||
unsigned i = [self length];
|
||||
|
||||
o = [newUInline(i, [self zone]) autorelease];
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = [self characterAtIndex: i];
|
||||
}
|
||||
return o;
|
||||
}
|
||||
@end
|
||||
|
||||
/**
|
||||
|
@ -3758,23 +3741,6 @@ transmute(GSStr self, NSString *aString)
|
|||
return size;
|
||||
}
|
||||
|
||||
/* This method is provided to enable regression tests to ensure they are
|
||||
* using an object whose internal representation is wide (unicode) text,
|
||||
* so that all the comparison operations between 8bit and 16bit strings
|
||||
* can be tested.
|
||||
*/
|
||||
- (NSString*) _unicodeString
|
||||
{
|
||||
GSUInlineString *o;
|
||||
unsigned i = [self length];
|
||||
|
||||
o = [newUInline(i, [self zone]) autorelease];
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = [self characterAtIndex: i];
|
||||
}
|
||||
return o;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
@ -4487,15 +4453,6 @@ agree, create a new GSUInlineString otherwise.
|
|||
}
|
||||
}
|
||||
|
||||
/* This method is provided to enable regression tests to ensure they are
|
||||
* using an object whose internal representation is wide (unicode) text,
|
||||
* so that all the comparison operations between 8bit and 16bit strings
|
||||
* can be tested.
|
||||
*/
|
||||
- (NSString*) _unicodeString
|
||||
{
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
@ -6189,23 +6146,6 @@ literalIsEqual(NXConstantString *self, id anObject)
|
|||
return NSUTF8StringEncoding;
|
||||
}
|
||||
|
||||
/* This method is provided to enable regression tests to ensure they are
|
||||
* using an object whose internal representation is wide (unicode) text,
|
||||
* so that all the comparison operations between 8bit and 16bit strings
|
||||
* can be tested.
|
||||
*/
|
||||
- (NSString*) _unicodeString
|
||||
{
|
||||
GSUInlineString *o;
|
||||
unsigned i = [self length];
|
||||
|
||||
o = [newUInline(i, [self zone]) autorelease];
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = [self characterAtIndex: i];
|
||||
}
|
||||
return o;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -4,11 +4,30 @@
|
|||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSCharacterSet.h>
|
||||
|
||||
#ifdef GNUSTEP_BASE_LIBRARY
|
||||
|
||||
@interface NSString (Test)
|
||||
- (NSString*) _unicodeString;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@implementation NSString (Test)
|
||||
|
||||
/* This method is provided to enable regression tests to ensure they are
|
||||
* using an object whose internal representation is wide (unicode) text,
|
||||
* so that all the comparison operations between 8bit and 16bit strings
|
||||
* can be tested.
|
||||
*/
|
||||
- (NSString*) _unicodeString
|
||||
{
|
||||
int l = [self length];
|
||||
NSMutableData *d = [NSMutableData dataWithLength: (l * 2)];
|
||||
unichar *b = [d mutableBytes];
|
||||
|
||||
[self getCharacters: b];
|
||||
return [NSString stringWithCharacters: b length: l];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
static BOOL rangesEqual(NSRange r1, NSRange r2)
|
||||
{
|
||||
|
@ -38,18 +57,9 @@ static void strCompare (char *s0, char *s1, NSComparisonResult ci,
|
|||
us1 = nil;
|
||||
|
||||
PASS_RUNS(cs0 = [NSString stringWithCString: s0];
|
||||
l = [cs0 length];
|
||||
d = [NSMutableData dataWithLength: (l * 2)];
|
||||
b = [d mutableBytes];
|
||||
[cs0 getCharacters: b];
|
||||
us0 = [NSString stringWithCharacters: b length: l];
|
||||
|
||||
us0 = [cs0 _unicodeString];
|
||||
cs1 = [NSString stringWithCString: s1];
|
||||
l = [cs1 length];
|
||||
d = [NSMutableData dataWithLength: (l * 2)];
|
||||
b = [d mutableBytes];
|
||||
[cs1 getCharacters: b];
|
||||
us1 = [NSString stringWithCharacters: b length: l];,
|
||||
us1 = [cs1 _unicodeString];,
|
||||
"create strings for compare is ok");
|
||||
opts = NSCaseInsensitiveSearch;
|
||||
type = "case insensitive comparison for";
|
||||
|
@ -178,33 +188,11 @@ static void strRange(char *s0, char *s1, unsigned int opts,
|
|||
us0 = nil;
|
||||
us1 = nil;
|
||||
|
||||
#ifdef GNUSTEP_BASE_LIBRARY
|
||||
/* The _unicodeString method is a private/hidden method the strings in the
|
||||
* base library provide to return an autorelease copy of themselves which
|
||||
* is guaranteed to use a 16bit internal character representation and be a
|
||||
* subclass of GSUnicodeString.
|
||||
*/
|
||||
PASS_RUNS(cs0 = [NSString stringWithCString: s0];
|
||||
us0 = [cs0 _unicodeString];
|
||||
cs1 = [NSString stringWithCString: s1];
|
||||
us1 = [cs1 _unicodeString];,
|
||||
"create strings for range is ok");
|
||||
#else
|
||||
PASS_RUNS(cs0 = [NSString stringWithCString: s0];
|
||||
l = [cs0 length];
|
||||
d = [NSMutableData dataWithLength: (l * 2)];
|
||||
b = [d mutableBytes];
|
||||
[cs0 getCharacters: b];
|
||||
us0 = [NSString stringWithCharacters: b length: l];
|
||||
|
||||
cs1 = [NSString stringWithCString: s1];
|
||||
l = [cs1 length];
|
||||
d = [NSMutableData dataWithLength: (l * 2)];
|
||||
b = [d mutableBytes];
|
||||
[cs1 getCharacters: b];
|
||||
us1 = [NSString stringWithCharacters: b length: l];,
|
||||
"create strings for range is ok");
|
||||
#endif
|
||||
|
||||
res = [cs0 rangeOfString: cs1 options: opts range: range];
|
||||
PASS(rangesEqual(res,want), "CCString range for '%s' and '%s' is ok",s0,s1);
|
||||
|
@ -232,18 +220,9 @@ static void strRangeFromSet(char *s, NSCharacterSet *c, unsigned int o, NSRange
|
|||
us0 = nil;
|
||||
us1 = nil;
|
||||
PASS_RUNS(cs0 = [NSString stringWithCString: s];
|
||||
l = [cs0 length];
|
||||
d = [NSMutableData dataWithLength: (l * 2)];
|
||||
b = [d mutableBytes];
|
||||
[cs0 getCharacters: b];
|
||||
us0 = [NSString stringWithCharacters: b length: l];
|
||||
|
||||
us0 = [cs0 _unicodeString];
|
||||
cs1 = [NSMutableString stringWithCString: s];
|
||||
l = [cs1 length];
|
||||
d = [NSMutableData dataWithLength: (l * 2)];
|
||||
b = [d mutableBytes];
|
||||
[cs1 getCharacters: b];
|
||||
us1 = [NSMutableString stringWithCharacters: b length: l];,
|
||||
us1 = [cs1 _unicodeString];,
|
||||
"create strings for range");
|
||||
|
||||
res = [cs0 rangeOfCharacterFromSet: c options: o range: range];
|
||||
|
|
Loading…
Reference in a new issue