Drop APIs from NSPathUtilities.h on String

rdar://problem/18848175

Swift SVN r30507
This commit is contained in:
David Farler
2015-07-22 22:12:56 +00:00
parent eb8d11b48a
commit 1f2390f1c7
3 changed files with 17 additions and 101 deletions

View File

@@ -97,11 +97,6 @@ NSStringAPIs.test("localizedStringWithFormat(_:...)") {
}
}
NSStringAPIs.test("pathWithComponents(_:)") {
expectEqual("flugelhorn/baritone/bass",
String.pathWithComponents(["flugelhorn", "baritone", "bass"]))
}
NSStringAPIs.test("init(contentsOfFile:encoding:error:)") {
let (existingPath, nonExistentPath) = createNSStringTemporaryFile()
@@ -554,20 +549,6 @@ NSStringAPIs.test("fastestEncoding") {
expectTrue(availableEncodings.contains("abc".fastestEncoding))
}
NSStringAPIs.test("fileSystemRepresentation()") {
if true {
let expectedStr = "abc\0".utf8.map { Int8(bitPattern: $0) }
expectEqual(expectedStr, "abc".fileSystemRepresentation())
}
// On OSX file system representation is Unicode NFD.
// This test might need to be adjusted for other systems.
if true {
let expectedStr = "\u{305f}\u{3099}くてん\0".utf8.map { Int8(bitPattern: $0) }
expectEqual(expectedStr, "だくてん".fileSystemRepresentation())
}
}
NSStringAPIs.test("getBytes(_:maxLength:usedLength:encoding:options:range:remainingRange:)") {
let s = "abc абв def где gh жз zzz"
let startIndex = advance(s.startIndex, 8)
@@ -701,54 +682,6 @@ NSStringAPIs.test("getCString(_:maxLength:encoding:)") {
}
}
NSStringAPIs.test("getFileSystemRepresentation(_:maxLength:)") {
// On OSX file system representation is Unicode NFD.
// This test might need to be adjusted for other systems.
var s = "abc だくてん"
if true {
// The largest buffer that can not accomodate the string plus null terminator.
let bufferLength = 19
var buffer = Array(
count: bufferLength, repeatedValue: CChar(bitPattern: 0xff))
let result = s.getFileSystemRepresentation(&buffer, maxLength: 100)
expectFalse(result)
}
if true {
// The smallest buffer where the result can fit.
let bufferLength = 20
var expectedStr = "abc \u{305f}\u{3099}くてん\0".utf8.map {
CChar(bitPattern: $0)
}
while (expectedStr.count != bufferLength) {
expectedStr.append(CChar(bitPattern: 0xff))
}
var buffer = Array(
count: bufferLength, repeatedValue: CChar(bitPattern: 0xff))
let result = s.getFileSystemRepresentation(
&buffer, maxLength: bufferLength)
expectTrue(result)
expectEqualSequence(expectedStr, buffer)
}
if true {
// Limit buffer size with 'maxLength'.
let bufferLength = 100
var buffer = Array(
count: bufferLength, repeatedValue: CChar(bitPattern: 0xff))
let result = s.getFileSystemRepresentation(&buffer, maxLength: 19)
expectFalse(result)
}
if true {
// String with unpaired surrogates.
let illFormedUTF16 = NonContiguousNSString([ 0xd800 ]) as String
let bufferLength = 100
var buffer = Array(
count: bufferLength, repeatedValue: CChar(bitPattern: 0xff))
let result = illFormedUTF16.getFileSystemRepresentation(
&buffer, maxLength: 100)
expectFalse(result)
}
}
NSStringAPIs.test("getLineStart(_:end:contentsEnd:forRange:)") {
let s = "Глокая куздра\nштеко будланула\nбокра и кудрячит\nбокрёнка."
let r = advance(s.startIndex, 16)..<advance(s.startIndex, 35)
@@ -1327,17 +1260,6 @@ func getHomeDir() -> String {
#endif
}
NSStringAPIs.test("stringByAbbreviatingWithTildeInPath") {
let s = getHomeDir() + "/abcde.txt"
expectEqual("~/abcde.txt", s.stringByAbbreviatingWithTildeInPath)
}
NSStringAPIs.test("stringByAddingPercentEncodingWithAllowedCharacters(_:)") {
expectOptionalEqual("ab%63d %D0%B0%D0%B1%D0%B2%D0%B3",
"abcd абвг".stringByAddingPercentEncodingWithAllowedCharacters(
NSCharacterSet(charactersInString: "abd ")))
}
NSStringAPIs.test("stringByAddingPercentEscapesUsingEncoding(_:)") {
expectEmpty(
"abcd абвг".stringByAddingPercentEscapesUsingEncoding(
@@ -1367,15 +1289,6 @@ NSStringAPIs.test("stringByAppendingPathComponent(_:)") {
expectEqual("/tmp/a.txt", "/tmp".stringByAppendingPathComponent("a.txt"))
}
NSStringAPIs.test("stringByAppendingPathExtension(_:)") {
expectEmpty("".stringByAppendingPathExtension(""))
expectOptionalEqual("a.txt.", "a.txt".stringByAppendingPathExtension(""))
expectEmpty("".stringByAppendingPathExtension("txt"))
expectOptionalEqual("a.txt", "a".stringByAppendingPathExtension("txt"))
expectOptionalEqual("a.txt.old", "a.txt".stringByAppendingPathExtension("old"))
expectOptionalEqual("/tmp/a.txt.old", "/tmp/a.txt".stringByAppendingPathExtension("old"))
}
NSStringAPIs.test("stringByAppendingString(_:)") {
expectEqual("", "".stringByAppendingString(""))
expectEqual("a", "a".stringByAppendingString(""))
@@ -1390,19 +1303,6 @@ NSStringAPIs.test("stringByDeletingLastPathComponent") {
expectEqual("/tmp", "/tmp/a.txt".stringByDeletingLastPathComponent)
}
NSStringAPIs.test("stringByDeletingPathExtension") {
expectEqual("", "".stringByDeletingPathExtension)
expectEqual("/", "/".stringByDeletingPathExtension)
expectEqual("/tmp", "/tmp".stringByDeletingPathExtension)
expectEqual("/tmp/a", "/tmp/a.txt".stringByDeletingPathExtension)
expectEqual("/tmp/a.txt", "/tmp/a.txt.old".stringByDeletingPathExtension)
}
NSStringAPIs.test("stringByExpandingTildeInPath") {
let s = getHomeDir() + "/abcde.txt"
expectEqual(s, "~/abcde.txt".stringByExpandingTildeInPath)
}
NSStringAPIs.test("stringByFoldingWithOptions(_:locale:)") {
expectEqual("abcd", "abCD".stringByFoldingWithOptions(
.CaseInsensitiveSearch, locale: NSLocale(localeIdentifier: "en")))