mirror of
https://github.com/nicklockwood/SwiftFormat.git
synced 2026-06-16 10:34:34 +00:00
53 lines
1.2 KiB
Swift
53 lines
1.2 KiB
Swift
//
|
|
// SpaceAroundCommentsTests.swift
|
|
// SwiftFormatTests
|
|
//
|
|
// Created by Nick Lockwood on 8/31/16.
|
|
// Copyright © 2024 Nick Lockwood. All rights reserved.
|
|
//
|
|
|
|
import XCTest
|
|
@testable import SwiftFormat
|
|
|
|
final class SpaceAroundCommentsTests: XCTestCase {
|
|
func testSpaceAroundCommentInParens() {
|
|
let input = """
|
|
(/* foo */)
|
|
"""
|
|
let output = """
|
|
( /* foo */ )
|
|
"""
|
|
testFormatting(for: input, output, rule: .spaceAroundComments,
|
|
exclude: [.redundantParens])
|
|
}
|
|
|
|
func testNoSpaceAroundCommentAtStartAndEndOfFile() {
|
|
let input = """
|
|
/* foo */
|
|
"""
|
|
testFormatting(for: input, rule: .spaceAroundComments)
|
|
}
|
|
|
|
func testNoSpaceAroundCommentBeforeComma() {
|
|
let input = """
|
|
(foo /* foo */ , bar)
|
|
"""
|
|
let output = """
|
|
(foo /* foo */, bar)
|
|
"""
|
|
testFormatting(for: input, output, rule: .spaceAroundComments)
|
|
}
|
|
|
|
func testSpaceAroundSingleLineComment() {
|
|
let input = """
|
|
func foo() {// comment
|
|
}
|
|
"""
|
|
let output = """
|
|
func foo() { // comment
|
|
}
|
|
"""
|
|
testFormatting(for: input, output, rule: .spaceAroundComments)
|
|
}
|
|
}
|