Merge branch 'master' into develop
# Conflicts: # Tests/CSVTests/CSVTests.swift # Tests/CSVTests/ReadmeTests.swift
This commit is contained in:
commit
13c29f98ed
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'CSV.swift'
|
||||
s.version = '1.1.1'
|
||||
s.version = '1.1.2'
|
||||
s.license = 'MIT'
|
||||
s.summary = 'CSV reading library written in Swift.'
|
||||
s.homepage = 'https://github.com/yaslab/CSV.swift'
|
||||
|
|
|
@ -132,9 +132,9 @@ internal class BinaryReader {
|
|||
return try buffer.withMemoryRebound(to: UInt16.self, capacity: 1) {
|
||||
switch endian {
|
||||
case .big:
|
||||
return CFSwapInt16BigToHost($0[0])
|
||||
return UInt16(bigEndian: $0[0])
|
||||
case .little:
|
||||
return CFSwapInt16LittleToHost($0[0])
|
||||
return UInt16(littleEndian: $0[0])
|
||||
default:
|
||||
throw CSVError.stringEndianMismatch
|
||||
}
|
||||
|
@ -153,9 +153,9 @@ internal class BinaryReader {
|
|||
return try buffer.withMemoryRebound(to: UInt32.self, capacity: 1) {
|
||||
switch endian {
|
||||
case .big:
|
||||
return CFSwapInt32BigToHost($0[0])
|
||||
return UInt32(bigEndian: $0[0])
|
||||
case .little:
|
||||
return CFSwapInt32LittleToHost($0[0])
|
||||
return UInt32(littleEndian: $0[0])
|
||||
default:
|
||||
throw CSVError.stringEndianMismatch
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.1.0</string>
|
||||
<string>1.1.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
|
|
@ -11,6 +11,26 @@ import XCTest
|
|||
|
||||
class CSVTests: XCTestCase {
|
||||
|
||||
static let allTests = [
|
||||
("testOneLine", testOneLine),
|
||||
("testTwoLines", testTwoLines),
|
||||
("testLastLineIsEmpty", testLastLineIsEmpty),
|
||||
("testLastLineIsWhiteSpace", testLastLineIsWhiteSpace),
|
||||
("testMiddleLineIsEmpty", testMiddleLineIsEmpty),
|
||||
("testCommaInQuotationMarks", testCommaInQuotationMarks),
|
||||
("testEscapedQuotationMark1", testEscapedQuotationMark1),
|
||||
("testEscapedQuotationMark2", testEscapedQuotationMark2),
|
||||
("testEmptyField", testEmptyField),
|
||||
("testDoubleQuoteBeforeLineBreak", testDoubleQuoteBeforeLineBreak),
|
||||
("testCSVState1", testCSVState1),
|
||||
("testSubscriptInt", testSubscriptInt),
|
||||
("testSubscriptString1", testSubscriptString1),
|
||||
("testSubscriptString2", testSubscriptString2),
|
||||
("testToArray", testToArray),
|
||||
("testToDictionary1", testToDictionary1),
|
||||
("testToDictionary2", testToDictionary2)
|
||||
]
|
||||
|
||||
func testOneLine() {
|
||||
let csv = "\"abc\",1,2"
|
||||
var i = 0
|
||||
|
|
|
@ -11,6 +11,21 @@ import XCTest
|
|||
|
||||
class LineBreakTests: XCTestCase {
|
||||
|
||||
static let allTests = [
|
||||
("testLF", testLF),
|
||||
("testCRLF", testCRLF),
|
||||
("testLastCR", testLastCR),
|
||||
("testLastCRLF", testLastCRLF),
|
||||
("testLastLF", testLastLF),
|
||||
("testLFInQuotationMarks", testLFInQuotationMarks),
|
||||
("testLineBreakLF", testLineBreakLF),
|
||||
("testLineBreakCR", testLineBreakCR),
|
||||
("testLineBreakCRLF", testLineBreakCRLF),
|
||||
("testLineBreakLFLF", testLineBreakLFLF),
|
||||
("testLineBreakCRCR", testLineBreakCRCR),
|
||||
("testLineBreakCRLFCRLF", testLineBreakCRLFCRLF)
|
||||
]
|
||||
|
||||
func testLF() {
|
||||
let csv = "abab,cdcd,efef\nzxcv,asdf,qwer"
|
||||
let records = parse(csv: csv)
|
||||
|
|
|
@ -11,6 +11,15 @@ import XCTest
|
|||
|
||||
class ReadmeTests: XCTestCase {
|
||||
|
||||
static let allTests = [
|
||||
("testFromCSVString", testFromCSVString),
|
||||
("testFromFile", testFromFile),
|
||||
("testGettingTheHeaderRow", testGettingTheHeaderRow),
|
||||
("testGetTheFieldValueUsingIndex", testGetTheFieldValueUsingIndex),
|
||||
("testGetTheFieldValueUsingKey", testGetTheFieldValueUsingKey),
|
||||
("testProvideTheCharacterEncoding", testProvideTheCharacterEncoding)
|
||||
]
|
||||
|
||||
func testFromCSVString() {
|
||||
let csv = try! CSV(string: "1,foo\n2,bar")
|
||||
for row in csv {
|
||||
|
|
|
@ -11,6 +11,22 @@ import XCTest
|
|||
|
||||
class TrimFieldsTests: XCTestCase {
|
||||
|
||||
static let allTests = [
|
||||
("testTrimFields1", testTrimFields1),
|
||||
("testTrimFields2", testTrimFields2),
|
||||
("testTrimFields3", testTrimFields3),
|
||||
("testTrimFields4", testTrimFields4),
|
||||
("testTrimFields5", testTrimFields5),
|
||||
("testTrimFields6", testTrimFields6),
|
||||
("testTrimFields7", testTrimFields7),
|
||||
("testTrimFields8", testTrimFields8),
|
||||
("testTrimFields9", testTrimFields9),
|
||||
("testTrimFields10", testTrimFields10),
|
||||
("testTrimFields11", testTrimFields11),
|
||||
("testTrimFields12", testTrimFields12),
|
||||
("testTrimFields13", testTrimFields13),
|
||||
]
|
||||
|
||||
func testTrimFields1() {
|
||||
let csvString = "abc,def,ghi"
|
||||
let config = CSVConfiguration(trimFields: true)
|
||||
|
|
|
@ -6,11 +6,22 @@
|
|||
// Copyright © 2016 yaslab. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
@testable import CSV
|
||||
|
||||
class UnicodeTests: XCTestCase {
|
||||
|
||||
static let allTests = [
|
||||
("testUTF8WithBOM", testUTF8WithBOM),
|
||||
("testUTF16WithNativeEndianBOM", testUTF16WithNativeEndianBOM),
|
||||
("testUTF16WithBigEndianBOM", testUTF16WithBigEndianBOM),
|
||||
("testUTF16WithLittleEndianBOM", testUTF16WithLittleEndianBOM),
|
||||
("testUTF32WithNativeEndianBOM", testUTF32WithNativeEndianBOM),
|
||||
("testUTF32WithBigEndianBOM", testUTF32WithBigEndianBOM),
|
||||
("testUTF32WithLittleEndianBOM", testUTF32WithLittleEndianBOM)
|
||||
]
|
||||
|
||||
func testUTF8WithBOM() {
|
||||
let csvString = "abab,,cdcd,efef\r\nzxcv,asdf,\"qw\"\"er\","
|
||||
let encoding = String.Encoding.utf8
|
||||
|
|
|
@ -7,8 +7,12 @@
|
|||
//
|
||||
|
||||
import XCTest
|
||||
@testable import CSVTestSuite
|
||||
@testable import CSVTests
|
||||
|
||||
XCTMain([
|
||||
testCase(CSVReaderTests.allTests),
|
||||
testCase(CSVTests.allTests),
|
||||
testCase(LineBreakTests.allTests),
|
||||
testCase(ReadmeTests.allTests),
|
||||
testCase(TrimFieldsTests.allTests),
|
||||
testCase(UnicodeTests.allTests)
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue