Skip to content

Commit 6c144ed

Browse files
authored
Add Test for Backtick bug (#16)
SR-15415
1 parent dfb10b7 commit 6c144ed

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2021 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
@testable import Markdown
12+
import XCTest
13+
14+
class BacktickTests: XCTestCase {
15+
func testNormalBackticks() {
16+
let string = "Hello `test` String"
17+
let document = Document(parsing: string)
18+
let expectedDump = """
19+
Document @1:1-1:20
20+
└─ Paragraph @1:1-1:20
21+
├─ Text @1:1-1:7 "Hello "
22+
├─ InlineCode @1:7-1:13 `test`
23+
└─ Text @1:13-1:20 " String"
24+
"""
25+
XCTAssertEqual(expectedDump, document.debugDescription(options: .printSourceLocations))
26+
}
27+
28+
func testOpenBacktick() {
29+
let single = "`"
30+
let document = Document(parsing: single)
31+
let expectedDump = """
32+
Document @1:1-1:2
33+
└─ Paragraph @1:1-1:2
34+
└─ Text @1:1-1:2 "`"
35+
"""
36+
XCTAssertEqual(expectedDump, document.debugDescription(options: .printSourceLocations))
37+
}
38+
39+
func testOpenBackticks(){
40+
let double = "``"
41+
let document = Document(parsing: double)
42+
let expectedDump = """
43+
Document @1:1-1:3
44+
└─ Paragraph @1:1-1:3
45+
└─ Text @1:1-1:3 "``"
46+
"""
47+
XCTAssertEqual(expectedDump, document.debugDescription(options: .printSourceLocations))
48+
}
49+
}

0 commit comments

Comments
 (0)