Skip to content

update NSUUID.UUIDString to uuidString to match Darwin version #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Foundation/NSUUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
_cf_uuid_generate_random(buffer)
}

public convenience init?(UUIDString string: String) {
public convenience init?(uuidString string: String) {
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 16)
if _cf_uuid_parse(string, buffer) != 0 {
return nil
Expand All @@ -39,7 +39,7 @@ public class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
_cf_uuid_copy(uuid, buffer)
}

public var UUIDString: String {
public var uuidString: String {
let strPtr = UnsafeMutablePointer<Int8>.allocate(capacity: 37)
_cf_uuid_unparse_upper(buffer, strPtr)
return String(cString: strPtr)
Expand Down Expand Up @@ -97,6 +97,6 @@ public class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
}

public override var description: String {
return UUIDString
return uuidString
}
}
2 changes: 1 addition & 1 deletion TestFoundation/TestNSBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TestNSBundle : XCTestCase {

private func _setupPlayground() -> String? {
// Make sure the directory is uniquely named
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().UUIDString + "/"
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().uuidString + "/"

do {
try FileManager.default().createDirectory(atPath: tempDir, withIntermediateDirectories: false, attributes: nil)
Expand Down
18 changes: 9 additions & 9 deletions TestFoundation/TestNSFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TestNSFileManager : XCTestCase {

func test_createDirectory() {
let fm = FileManager.default()
let path = "/tmp/testdir\(NSUUID().UUIDString)"
let path = "/tmp/testdir\(NSUUID().uuidString)"

ignoreError { try fm.removeItem(atPath: path) }

Expand All @@ -63,7 +63,7 @@ class TestNSFileManager : XCTestCase {

func test_createFile() {
let fm = FileManager.default()
let path = "/tmp/testfile\(NSUUID().UUIDString)"
let path = "/tmp/testfile\(NSUUID().uuidString)"

ignoreError { try fm.removeItem(atPath: path) }

Expand All @@ -83,8 +83,8 @@ class TestNSFileManager : XCTestCase {

func test_moveFile() {
let fm = FileManager.default()
let path = "/tmp/testfile\(NSUUID().UUIDString)"
let path2 = "/tmp/testfile2\(NSUUID().UUIDString)"
let path = "/tmp/testfile\(NSUUID().uuidString)"
let path2 = "/tmp/testfile2\(NSUUID().uuidString)"

func cleanup() {
ignoreError { try fm.removeItem(atPath: path) }
Expand Down Expand Up @@ -115,7 +115,7 @@ class TestNSFileManager : XCTestCase {

func test_fileAttributes() {
let fm = FileManager.default()
let path = "/tmp/test_fileAttributes\(NSUUID().UUIDString)"
let path = "/tmp/test_fileAttributes\(NSUUID().uuidString)"

ignoreError { try fm.removeItem(atPath: path) }

Expand Down Expand Up @@ -162,7 +162,7 @@ class TestNSFileManager : XCTestCase {
}

func test_setFileAttributes() {
let path = "/tmp/test_setFileAttributes\(NSUUID().UUIDString)"
let path = "/tmp/test_setFileAttributes\(NSUUID().uuidString)"
let fm = FileManager.default()

ignoreError { try fm.removeItem(atPath: path) }
Expand All @@ -189,7 +189,7 @@ class TestNSFileManager : XCTestCase {

func test_pathEnumerator() {
let fm = FileManager.default()
let testDirName = "testdir\(NSUUID().UUIDString)"
let testDirName = "testdir\(NSUUID().uuidString)"
let basePath = "/tmp/\(testDirName)"
let itemPath = "/tmp/\(testDirName)/item"
let basePath2 = "/tmp/\(testDirName)/path2"
Expand Down Expand Up @@ -222,7 +222,7 @@ class TestNSFileManager : XCTestCase {

func test_directoryEnumerator() {
let fm = FileManager.default()
let testDirName = "testdir\(NSUUID().UUIDString)"
let testDirName = "testdir\(NSUUID().uuidString)"
let path = "/tmp/\(testDirName)"
let itemPath = "/tmp/\(testDirName)/item"

Expand Down Expand Up @@ -328,7 +328,7 @@ class TestNSFileManager : XCTestCase {

func test_contentsOfDirectoryAtPath() {
let fm = FileManager.default()
let testDirName = "testdir\(NSUUID().UUIDString)"
let testDirName = "testdir\(NSUUID().uuidString)"
let path = "/tmp/\(testDirName)"
let itemPath1 = "/tmp/\(testDirName)/item"
let itemPath2 = "/tmp/\(testDirName)/item2"
Expand Down
2 changes: 1 addition & 1 deletion TestFoundation/TestNSJSONSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ extension TestNSJSONSerialization {
}

private func createTestFile(_ path: String,_contents: Data) -> String? {
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().UUIDString + "/"
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().uuidString + "/"
do {
try FileManager.default().createDirectory(atPath: tempDir, withIntermediateDirectories: false, attributes: nil)
if FileManager.default().createFile(atPath: tempDir + "/" + path, contents: _contents,
Expand Down
4 changes: 2 additions & 2 deletions TestFoundation/TestNSKeyedUnarchiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TestNSKeyedUnarchiver : XCTestCase {
}

func test_unarchive_complex() {
let uuid = NSUUID(UUIDString: "71DC068E-3420-45FF-919E-3A267D55EC22")!
let uuid = NSUUID(uuidString: "71DC068E-3420-45FF-919E-3A267D55EC22")!
let url = URL(string: "index.xml", relativeTo: URL(string: "https://www.swift.org"))!
let array = NSArray(array: [ NSNull(), NSString(string: "hello"), NSNumber(value: 34545), ["key" : "val"].bridge() ])
let dict : Dictionary<String, NSObject> = [
Expand Down Expand Up @@ -106,7 +106,7 @@ class TestNSKeyedUnarchiver : XCTestCase {
}

func test_unarchive_uuid() {
let uuid = NSUUID(UUIDString: "0AD863BA-7584-40CF-8896-BD87B3280C34")
let uuid = NSUUID(uuidString: "0AD863BA-7584-40CF-8896-BD87B3280C34")
test_unarchive_from_file("NSKeyedUnarchiver-UUIDTest", uuid!)
}
}
2 changes: 1 addition & 1 deletion TestFoundation/TestNSStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class TestNSStream : XCTestCase {
}

private func createTestFile(_ path: String, _contents: Data) -> String? {
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().UUIDString + "/"
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().uuidString + "/"
do {
try FileManager.default().createDirectory(atPath: tempDir, withIntermediateDirectories: false, attributes: nil)
if FileManager.default().createFile(atPath: tempDir + "/" + path, contents: _contents,
Expand Down
4 changes: 2 additions & 2 deletions TestFoundation/TestNSString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class TestNSString : XCTestCase {
}

do {
let path = tmpPath(NSUUID().UUIDString)
let path = tmpPath(NSUUID().uuidString)
var outName: NSString?
var matches: [NSString] = []
let count = path.completePathIntoString(&outName, caseSensitive: false, matchesIntoArray: &matches, filterTypes: nil)
Expand Down Expand Up @@ -802,7 +802,7 @@ class TestNSString : XCTestCase {
}

do {
let userName = NSUUID().UUIDString
let userName = NSUUID().uuidString
let path = NSString(string: "~\(userName)/")
let result = path.stringByExpandingTildeInPath
// next assert fails in VirtualBox because home directory for unknown user resolved to /var/run/vboxadd
Expand Down
18 changes: 9 additions & 9 deletions TestFoundation/TestNSUUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ class TestNSUUID : XCTestCase {
return [
("test_Equality", test_Equality),
("test_InvalidUUID", test_InvalidUUID),
("test_UUIDString", test_UUIDString),
("test_uuidString", test_uuidString),
("test_description", test_description),
// Disabled until NSKeyedArchiver and NSKeyedUnarchiver are implemented
// ("test_NSCoding", test_NSCoding),
]
}

func test_Equality() {
let uuidA = NSUUID(UUIDString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")
let uuidB = NSUUID(UUIDString: "e621e1f8-c36c-495a-93fc-0c247a3e6e5f")
let uuidA = NSUUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")
let uuidB = NSUUID(uuidString: "e621e1f8-c36c-495a-93fc-0c247a3e6e5f")
let uuidC = NSUUID(UUIDBytes: [0xe6,0x21,0xe1,0xf8,0xc3,0x6c,0x49,0x5a,0x93,0xfc,0x0c,0x24,0x7a,0x3e,0x6e,0x5f])
let uuidD = NSUUID()

Expand All @@ -42,20 +42,20 @@ class TestNSUUID : XCTestCase {
}

func test_InvalidUUID() {
let uuid = NSUUID(UUIDString: "Invalid UUID")
XCTAssertNil(uuid, "The convenience initializer `init?(UUIDString string:)` must return nil for an invalid UUID string.")
let uuid = NSUUID(uuidString: "Invalid UUID")
XCTAssertNil(uuid, "The convenience initializer `init?(uuidString string:)` must return nil for an invalid UUID string.")
}

// `UUIDString` should return an uppercase string
// `uuidString` should return an uppercase string
// See: https://bugs.swift.org/browse/SR-865
func test_UUIDString() {
func test_uuidString() {
let uuid = NSUUID(UUIDBytes: [0xe6,0x21,0xe1,0xf8,0xc3,0x6c,0x49,0x5a,0x93,0xfc,0x0c,0x24,0x7a,0x3e,0x6e,0x5f])
XCTAssertEqual(uuid.UUIDString, "E621E1F8-C36C-495A-93FC-0C247A3E6E5F", "The UUIDString representation must be uppercase.")
XCTAssertEqual(uuid.uuidString, "E621E1F8-C36C-495A-93FC-0C247A3E6E5F", "The uuidString representation must be uppercase.")
}

func test_description() {
let uuid = NSUUID()
XCTAssertEqual(uuid.description, uuid.UUIDString, "The description must be the same as the UUIDString.")
XCTAssertEqual(uuid.description, uuid.uuidString, "The description must be the same as the uuidString.")
}

func test_NSCoding() {
Expand Down