Skip to content

Commit

Permalink
Fix for Issue #1
Browse files Browse the repository at this point in the history
#1

Corrected bad template for replacement and created test to catch
  • Loading branch information
SwiftStudies committed Mar 21, 2016
1 parent 0a23794 commit c2cf93f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/SmarkDown/SmarkDown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public class SmarkDown {

//Do hard-breaks

text = regexSub(text, pattern: " {2,}\\n", template: "<br\(emptyElementSufix)>")
text = regexSub(text, pattern: " {2,}\\n", template: " <br\(emptyElementSufix)\n")

return text
}
Expand Down
19 changes: 17 additions & 2 deletions Tests/SmarkDown/Test Sets/RegexTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,31 @@ class InternalTests: XCTestCase {
}

func testAutoLinks(){

var failures = [String:(expected:String,actual:String)]()

let inputs = [
"<http://www.google.com/>" : "<a href=\"http://www.google.com/\">http://www.google.com/</a>", //Auto-link
"<http://www.google.com/>" : "<a href=\"http://www.google.com/\">http://www.google.com/</a>", //Auto-link
"<http://www.google.com/> \nNext Line\n" : "<a href=\"http://www.google.com/\">http://www.google.com/</a> <br />\nNext Line",
]

for (input,expected) in inputs {
let result = input.markdown
let expected = "<p>\(expected)</p>\n"

if result != expected {
failures[input] = (expected,result)
}

XCTAssert(result == expected, "Failed for '\(input.exposedWhiteSpace)':\n'\(expected.exposedWhiteSpace)' but got \n'\(result.exposedWhiteSpace)'")
// XCTAssert(result == expected, "Failed for '\(input.exposedWhiteSpace)':\n'\(expected.exposedWhiteSpace)' but got \n'\(result.exposedWhiteSpace)'")
}

var resultsSummary = ""
for (input,results) in failures {
resultsSummary += "Failed for '\(input.exposedWhiteSpace)':\n'\(results.expected.exposedWhiteSpace)' but got \n'\(results.actual.exposedWhiteSpace)'\n"
}

XCTAssert(failures.count == 0, "Failed for \(failures.count) out of \(inputs.count) cases:\n\(resultsSummary)")
}

func testReferenceLinkWithTitle(){
Expand Down

0 comments on commit c2cf93f

Please sign in to comment.