mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 16:50: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
|
* Tests/base/NSString/test00.m: Add David Chisnall's test from
|
||||||
newapi branch slightly reformatted.
|
newapi branch slightly reformatted.
|
||||||
* Source/GSString.m: Remove code that was identical to super class.
|
* 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>
|
2018-06-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -1100,23 +1100,6 @@ tsbytes(uintptr_t s, char *buf)
|
||||||
return 8;
|
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
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3758,23 +3741,6 @@ transmute(GSStr self, NSString *aString)
|
||||||
return size;
|
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
|
@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
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -6189,23 +6146,6 @@ literalIsEqual(NXConstantString *self, id anObject)
|
||||||
return NSUTF8StringEncoding;
|
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
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,30 @@
|
||||||
#import <Foundation/NSAutoreleasePool.h>
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
#import <Foundation/NSCharacterSet.h>
|
#import <Foundation/NSCharacterSet.h>
|
||||||
|
|
||||||
#ifdef GNUSTEP_BASE_LIBRARY
|
|
||||||
@interface NSString (Test)
|
@interface NSString (Test)
|
||||||
- (NSString*) _unicodeString;
|
- (NSString*) _unicodeString;
|
||||||
@end
|
@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)
|
static BOOL rangesEqual(NSRange r1, NSRange r2)
|
||||||
{
|
{
|
||||||
|
@ -38,18 +57,9 @@ static void strCompare (char *s0, char *s1, NSComparisonResult ci,
|
||||||
us1 = nil;
|
us1 = nil;
|
||||||
|
|
||||||
PASS_RUNS(cs0 = [NSString stringWithCString: s0];
|
PASS_RUNS(cs0 = [NSString stringWithCString: s0];
|
||||||
l = [cs0 length];
|
us0 = [cs0 _unicodeString];
|
||||||
d = [NSMutableData dataWithLength: (l * 2)];
|
|
||||||
b = [d mutableBytes];
|
|
||||||
[cs0 getCharacters: b];
|
|
||||||
us0 = [NSString stringWithCharacters: b length: l];
|
|
||||||
|
|
||||||
cs1 = [NSString stringWithCString: s1];
|
cs1 = [NSString stringWithCString: s1];
|
||||||
l = [cs1 length];
|
us1 = [cs1 _unicodeString];,
|
||||||
d = [NSMutableData dataWithLength: (l * 2)];
|
|
||||||
b = [d mutableBytes];
|
|
||||||
[cs1 getCharacters: b];
|
|
||||||
us1 = [NSString stringWithCharacters: b length: l];,
|
|
||||||
"create strings for compare is ok");
|
"create strings for compare is ok");
|
||||||
opts = NSCaseInsensitiveSearch;
|
opts = NSCaseInsensitiveSearch;
|
||||||
type = "case insensitive comparison for";
|
type = "case insensitive comparison for";
|
||||||
|
@ -178,33 +188,11 @@ static void strRange(char *s0, char *s1, unsigned int opts,
|
||||||
us0 = nil;
|
us0 = nil;
|
||||||
us1 = 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];
|
PASS_RUNS(cs0 = [NSString stringWithCString: s0];
|
||||||
us0 = [cs0 _unicodeString];
|
us0 = [cs0 _unicodeString];
|
||||||
cs1 = [NSString stringWithCString: s1];
|
cs1 = [NSString stringWithCString: s1];
|
||||||
us1 = [cs1 _unicodeString];,
|
us1 = [cs1 _unicodeString];,
|
||||||
"create strings for range is ok");
|
"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];
|
res = [cs0 rangeOfString: cs1 options: opts range: range];
|
||||||
PASS(rangesEqual(res,want), "CCString range for '%s' and '%s' is ok",s0,s1);
|
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;
|
us0 = nil;
|
||||||
us1 = nil;
|
us1 = nil;
|
||||||
PASS_RUNS(cs0 = [NSString stringWithCString: s];
|
PASS_RUNS(cs0 = [NSString stringWithCString: s];
|
||||||
l = [cs0 length];
|
us0 = [cs0 _unicodeString];
|
||||||
d = [NSMutableData dataWithLength: (l * 2)];
|
|
||||||
b = [d mutableBytes];
|
|
||||||
[cs0 getCharacters: b];
|
|
||||||
us0 = [NSString stringWithCharacters: b length: l];
|
|
||||||
|
|
||||||
cs1 = [NSMutableString stringWithCString: s];
|
cs1 = [NSMutableString stringWithCString: s];
|
||||||
l = [cs1 length];
|
us1 = [cs1 _unicodeString];,
|
||||||
d = [NSMutableData dataWithLength: (l * 2)];
|
|
||||||
b = [d mutableBytes];
|
|
||||||
[cs1 getCharacters: b];
|
|
||||||
us1 = [NSMutableString stringWithCharacters: b length: l];,
|
|
||||||
"create strings for range");
|
"create strings for range");
|
||||||
|
|
||||||
res = [cs0 rangeOfCharacterFromSet: c options: o range: range];
|
res = [cs0 rangeOfCharacterFromSet: c options: o range: range];
|
||||||
|
|
Loading…
Reference in a new issue