Skip to content

Tests: escape the path separator for Windows #786

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions Tests/SourceKittenFrameworkTests/SourceKitObjectTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import Foundation
import SourceKittenFramework
import XCTest

class SourceKitObjectTests: XCTestCase {

func testExample() {
let path = #file
let path =
URL(fileURLWithPath: #file)
.withUnsafeFileSystemRepresentation { String(cString: $0!) }
let object: SourceKitObject = [
"key.request": UID("source.request.editor.open"),
"key.name": path,
Expand All @@ -13,8 +16,8 @@ class SourceKitObjectTests: XCTestCase {
let expected = """
{
key.request: source.request.editor.open,
key.name: \"\(#file)\",
key.sourcefile: \"\(#file)\"
key.name: \"\((#file).replacingOccurrences(of: "\\", with: "\\\\"))\",
key.sourcefile: \"\((#file).replacingOccurrences(of: "\\", with: "\\\\"))\"
}
"""
XCTAssertEqual(object.description, expected)
Expand Down