-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CRLF Line Ending Typesetting (#20)
- Loading branch information
1 parent
cf4ee3b
commit f2f9d93
Showing
2 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import XCTest | ||
@testable import CodeEditTextView | ||
|
||
// swiftlint:disable all | ||
|
||
class TypesetterTests: XCTestCase { | ||
let limitedLineWidthDisplayData = TextLine.DisplayData(maxWidth: 150, lineHeightMultiplier: 1.0, estimatedLineHeight: 20.0) | ||
let unlimitedLineWidthDisplayData = TextLine.DisplayData(maxWidth: .infinity, lineHeightMultiplier: 1.0, estimatedLineHeight: 20.0) | ||
|
||
func test_LineFeedBreak() { | ||
let typesetter = Typesetter() | ||
typesetter.typeset( | ||
NSAttributedString(string: "testline\n"), | ||
displayData: unlimitedLineWidthDisplayData, | ||
breakStrategy: .word, | ||
markedRanges: nil | ||
) | ||
|
||
XCTAssertEqual(typesetter.lineFragments.count, 1, "Typesetter typeset incorrect number of lines.") | ||
|
||
typesetter.typeset( | ||
NSAttributedString(string: "testline\n"), | ||
displayData: unlimitedLineWidthDisplayData, | ||
breakStrategy: .character, | ||
markedRanges: nil | ||
) | ||
|
||
XCTAssertEqual(typesetter.lineFragments.count, 1, "Typesetter typeset incorrect number of lines.") | ||
} | ||
|
||
func test_carriageReturnBreak() { | ||
let typesetter = Typesetter() | ||
typesetter.typeset( | ||
NSAttributedString(string: "testline\r"), | ||
displayData: unlimitedLineWidthDisplayData, | ||
breakStrategy: .word, | ||
markedRanges: nil | ||
) | ||
|
||
XCTAssertEqual(typesetter.lineFragments.count, 1, "Typesetter typeset incorrect number of lines.") | ||
|
||
typesetter.typeset( | ||
NSAttributedString(string: "testline\r"), | ||
displayData: unlimitedLineWidthDisplayData, | ||
breakStrategy: .character, | ||
markedRanges: nil | ||
) | ||
|
||
XCTAssertEqual(typesetter.lineFragments.count, 1, "Typesetter typeset incorrect number of lines.") | ||
} | ||
|
||
func test_carriageReturnLineFeedBreak() { | ||
let typesetter = Typesetter() | ||
typesetter.typeset( | ||
NSAttributedString(string: "testline\r\n"), | ||
displayData: unlimitedLineWidthDisplayData, | ||
breakStrategy: .word, | ||
markedRanges: nil | ||
) | ||
|
||
XCTAssertEqual(typesetter.lineFragments.count, 1, "Typesetter typeset incorrect number of lines.") | ||
|
||
typesetter.typeset( | ||
NSAttributedString(string: "testline\r\n"), | ||
displayData: unlimitedLineWidthDisplayData, | ||
breakStrategy: .character, | ||
markedRanges: nil | ||
) | ||
|
||
XCTAssertEqual(typesetter.lineFragments.count, 1, "Typesetter typeset incorrect number of lines.") | ||
} | ||
} | ||
|
||
// swiftlint:enable all |