Skip to content

Commit

Permalink
Added Test to check for BOM in headers when CSV instance is created d…
Browse files Browse the repository at this point in the history
…irectly from a string
  • Loading branch information
Diggory committed Aug 17, 2023
1 parent 39f7c48 commit 9c4920a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions SwiftCSVTests/URLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,26 @@ class URLTests: XCTestCase {
XCTAssertEqual(expected[index], row)
}
}

func testBOMInHeadersWhenInitialisingFromString() throws {
var csv: CSV<Named>?
let csvString: String = """
Part Number,Description,Unit Price,Qty
12345,Heizölrückstoßabdämpfung,"€ 100,00",2"
"""
let csvStringWithBOM = "\u{FEFF}" + csvString

// Make a CSV object
do {
// Create from string
csv = try CSV<Named>(string: csvStringWithBOM)
} catch {
XCTFail("Could not convert string literal to CSV instance")
}

// Check that headers match
let correctMatchingHeader = ["Part Number", "Description", "Unit Price", "Qty"]
XCTAssertEqual(csv!.header, correctMatchingHeader)
}

}

0 comments on commit 9c4920a

Please sign in to comment.