Skip to content
Merged
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
49 changes: 49 additions & 0 deletions Tests/MarkdownTests/Parsing/BacktickTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2021 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See https://swift.org/LICENSE.txt for license information
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

@testable import Markdown
import XCTest

class BacktickTests: XCTestCase {
func testNormalBackticks() {
let string = "Hello `test` String"
let document = Document(parsing: string)
let expectedDump = """
Document @1:1-1:20
└─ Paragraph @1:1-1:20
├─ Text @1:1-1:7 "Hello "
├─ InlineCode @1:7-1:13 `test`
└─ Text @1:13-1:20 " String"
"""
XCTAssertEqual(expectedDump, document.debugDescription(options: .printSourceLocations))
}

func testOpenBacktick() {
let single = "`"
let document = Document(parsing: single)
let expectedDump = """
Document @1:1-1:2
└─ Paragraph @1:1-1:2
└─ Text @1:1-1:2 "`"
"""
XCTAssertEqual(expectedDump, document.debugDescription(options: .printSourceLocations))
}

func testOpenBackticks(){
let double = "``"
let document = Document(parsing: double)
let expectedDump = """
Document @1:1-1:3
└─ Paragraph @1:1-1:3
└─ Text @1:1-1:3 "``"
"""
XCTAssertEqual(expectedDump, document.debugDescription(options: .printSourceLocations))
}
}