stdlib/String: add a test that shows that equality comparison of strings

is performed according to the deterministic Unicode collation algorithm,
which allows us to use the hash of the NFD form.

rdar://17498444

Swift SVN r20543
This commit is contained in:
Dmitri Hrybenko
2014-07-25 14:31:07 +00:00
parent 1a28fdc225
commit c44b42c7aa
3 changed files with 31 additions and 6 deletions

View File

@@ -173,7 +173,13 @@ extension String {
}
}
/// Compare two strings, normalizing them to NFD first.
/// Compare two strings using the Unicode collation algorithm in the
/// deterministic comparison mode. (The strings which are equivalent according
/// to their NFD form are considered equal. Strings which are equivalent
/// according to the plain Unicode collation algorithm are additionaly ordered
/// based on their NFD.)
///
/// See Unicode Technical Standard #10.
///
/// The behavior is equivalent to `NSString.compare()` with default options.
///
@@ -181,9 +187,10 @@ extension String {
/// * -1 if `lhs < rhs`,
/// * 0 if `lhs == rhs`,
/// * 1 if `lhs > rhs`.
@asmname("swift_stdlib_compareNSStringNormalizingToNFD")
func _stdlib_compareNSStringNormalizingToNFD(lhs: AnyObject, rhs: AnyObject)
-> Int
@asmname("swift_stdlib_compareNSStringDeterministicUnicodeCollation")
public func _stdlib_compareNSStringDeterministicUnicodeCollation(
lhs: AnyObject, rhs: AnyObject
)-> Int
extension String: Equatable {
}