mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
5039cccf80
There's a longstanding problem in implementing `-isEqualToString:`, where if you don't know how to get fast access to the other NSString's contents, you have to pick between doing it character by character (very slow), or calling [other isEqualToString: self], which risks infinite recursion if the other string does the same. This cuts the gordian knot by adding a new method `isEqualToBytes:encoding:count:`, so you can get the contents out of `self`, and hand it to the other string, confident that it will not need to (nor, in fact be able to) ask you anything that might recurse.
57 lines
1.7 KiB
Objective-C
57 lines
1.7 KiB
Objective-C
//===--- ObjectiveCTests.h ------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
@interface BridgeTester : NSObject {
|
|
NSString *myString;
|
|
NSArray<NSString *> *myArrayOfStrings;
|
|
NSDate *myBeginDate;
|
|
NSDate *myEndDate;
|
|
NSArray<NSString *> *cornucopiaOfStrings;
|
|
NSArray<NSString *> *cornucopiaOfStringsNoCustom;
|
|
NSArray<NSString *> *bridgedStrings;
|
|
}
|
|
|
|
- (instancetype)init NS_DESIGNATED_INITIALIZER;
|
|
- (void)setUpStringTests:(NSArray<NSString *> *)bridgedStrings;
|
|
- (void)testFromString:(NSString *) str;
|
|
- (NSString *)testToString;
|
|
- (void)testFromArrayOfStrings:(NSArray<NSString *> *)arr;
|
|
- (NSArray<NSString *> *)testToArrayOfStrings;
|
|
|
|
- (NSDate *)beginDate;
|
|
- (NSDate *)endDate;
|
|
- (void)useDate:(NSDate *)date;
|
|
|
|
- (void)testIsEqualToString;
|
|
- (void)testIsEqualToString2;
|
|
- (void)testIsEqualToString2NoCustom;
|
|
- (void)testIsEqualToStringAllSwift;
|
|
- (void)testUTF8String;
|
|
- (void)testCStringUsingEncoding;
|
|
- (void)testGetUTF8Contents;
|
|
- (void)testGetASCIIContents;
|
|
- (void)testRangeOfString;
|
|
- (void)testRangeOfStringSpecificWithNeedle:(NSString *)needle
|
|
haystack:(NSString *)haystack
|
|
n:(NSInteger)n;
|
|
- (void)testHash;
|
|
- (void)testCompare;
|
|
- (void)testCompare2;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|