Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move away from resource helper. #131

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.0
// swift-tools-version:5.5

import PackageDescription

Expand All @@ -21,7 +21,10 @@ let package = Package(
.testTarget(
name: "SwiftCSVTests",
dependencies: ["SwiftCSV"],
path: "SwiftCSVTests"),
path: "SwiftCSVTests",
resources: [
.copy("TestData")
]),
],
swiftLanguageVersions: [.v5, .v4_2]
)
5 changes: 4 additions & 1 deletion SwiftCSVTests/PerformanceTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class PerformanceTest: XCTestCase {
var csv: CSV<Named>!

override func setUpWithError() throws {
let csvURL = ResourceHelper.url(forResource: "large", withExtension: "csv")!
guard let csvURL = Bundle.module.url(forResource: "TestData/large", withExtension: "csv") else {
XCTAssertNotNil(nil, "Could not get URL for Large.csv from Test Bundle")
return
}
csv = try CSV<Named>(url: csvURL)
}

Expand Down
5 changes: 4 additions & 1 deletion SwiftCSVTests/QuotedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class QuotedTests: XCTestCase {
}

func testEmbeddedQuotes() throws {
let csvURL = ResourceHelper.url(forResource: "wonderland", withExtension: "csv")!
guard let csvURL = Bundle.module.url(forResource: "TestData/wonderland", withExtension: "csv") else {
XCTAssertNotNil(nil, "Could not get URL for Wonderland.csv from Test Bundle")
return
}
csv = try CSV(url: csvURL)

/*
Expand Down
16 changes: 0 additions & 16 deletions SwiftCSVTests/ResourceHelper.swift

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 19 additions & 4 deletions SwiftCSVTests/URLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class URLTests: XCTestCase {
var csv: CSV<Named>!

func testEmptyFields() throws {
let csvURL = ResourceHelper.url(forResource: "empty_fields", withExtension: "csv")!
guard let csvURL = Bundle.module.url(forResource: "TestData/empty_fields", withExtension: "csv") else {
XCTAssertNotNil(nil, "Could not get URL for empty_fields.csv from Test Bundle")
return
}
csv = try CSV<Named>(url: csvURL)
let expected = [
["id": "1", "name": "John", "age": "23"],
Expand All @@ -29,7 +32,11 @@ class URLTests: XCTestCase {
}

func testQuotes() throws {
let csvURL = ResourceHelper.url(forResource: "quotes", withExtension: "csv")!
guard let csvURL = Bundle.module.url(forResource: "TestData/quotes", withExtension: "csv") else {
XCTAssertNotNil(nil, "Could not get URL for quotes.csv from Test Bundle")
return
}

csv = try CSV<Named>(url: csvURL)
let expected = [
["id": "4", "name, first": "Alex", "name, last": "Smith"],
Expand Down Expand Up @@ -62,7 +69,11 @@ class URLTests: XCTestCase {
}

func testUTF8() throws {
let csvURL = ResourceHelper.url(forResource: "utf8_with_bom", withExtension: "csv")!
guard let csvURL = Bundle.module.url(forResource: "TestData/utf8_with_bom", withExtension: "csv") else {
XCTAssertNotNil(nil, "Could not get URL for utf8_with_bom.csv from Test Bundle")
return
}

csv = try CSV(url: csvURL)

XCTAssertFalse(csv.header.first!.hasPrefix("\u{FEFF}"))
Expand All @@ -81,7 +92,11 @@ class URLTests: XCTestCase {
}

func testUTF8Delimited() throws {
let csvURL = ResourceHelper.url(forResource: "utf8_with_bom", withExtension: "csv")!
guard let csvURL = Bundle.module.url(forResource: "TestData/utf8_with_bom", withExtension: "csv") else {
XCTAssertNotNil(nil, "Could not get URL for utf8_with_bom.csv from Test Bundle")
return
}

csv = try CSV(url: csvURL, delimiter: .comma)

XCTAssertFalse(csv.header.first!.hasPrefix("\u{FEFF}"))
Expand Down
Loading