Skip to content

Commit

Permalink
feature: added extra test to cover edge case (#70)
Browse files Browse the repository at this point in the history
Kudos to @grantkemp
  • Loading branch information
DivineDominion authored Apr 25, 2019
1 parent c35cd94 commit 48195d6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions SwiftCSVTests/CSVTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ class CSVTests: XCTestCase {
XCTAssertEqual(expected[index], row)
}
}
func testInit_whenThereAreextraCarriageReturns() {
csv = CSV(string: "id,name,age\n1,Alice,18\n2,Bob,19\n3,Charlie\r\n")
let expected = [
["id": "1", "name": "Alice", "age": "18"],
["id": "2", "name": "Bob", "age": "19"],
["id": "3", "name": "Charlie", "age": ""]
]
for (index, row) in csv.namedRows.enumerated() {
XCTAssertEqual(expected[index], row)
}
}

func testInit_whenThereAreCRLFs_makesRows() {
csv = CSV(string: "id,name,age\r\n1,Alice,18\r\n2,Bob,19\r\n3,Charlie,20\r\n")
Expand Down

0 comments on commit 48195d6

Please sign in to comment.