Skip to content
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

This fixes a bug and adds a feature #111

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Add (failing) test for the newline insertion issue
This adds a test which fails because Splash inserts additional whitespace
at the beginning of code if the code has empty lines before it starts.
  • Loading branch information
terhechte committed Jun 7, 2020
commit 52aaa1ecff7dfa26ba6ff6b065892490baf022e8
58 changes: 58 additions & 0 deletions Tests/SplashTests/Tests/AttributedStringTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#if !os(Linux)

import Foundation
import XCTest
import Splash

final class AttributedStringOutputFormatTests: SplashTestCase {
private var highlighter: SyntaxHighlighter<AttributedStringOutputFormat>!

override func setUp() {
super.setUp()
highlighter = SyntaxHighlighter(format: AttributedStringOutputFormat(theme: Theme.presentation(withFont: .init(size: 15))))
}

func testBasicAttributedStringOutputMatchesInput() {
let input = """
public struct Test: SomeProtocol {
func hello() -> Int { return 7 }
}
"""
let output = highlighter.highlight(input)
XCTAssertEqual(input, output.string)
}

func testNewlinesAttributedStringOutputMatchesInput() {
let input = """

typealias a = b
typealias b = c

print("hello")
"""
let output = highlighter.highlight(input)
XCTAssertEqual(input, output.string)
}

func testInnerNewlinesAttributedStringOutputMatchesInput() {
let input = """
typealias a = b
typealias b = c

print("hello")

print("hello")
print("hello")


print("hello")
"""
let output = highlighter.highlight(input)
XCTAssertEqual(input, output.string)
}

func testAllTestsRunOnLinux() {
}
}

#endif