Moved all test data to Date.swift file
This commit is contained in:
parent
daab639846
commit
3880dd7138
|
@ -0,0 +1,59 @@
|
||||||
|
let orderedData: OrderedKeyedCollection = [
|
||||||
|
"first name": ["Caleb", "Benjamin", "Doc", "Grace", "Anne", "TinTin"],
|
||||||
|
"last_name": ["Kleveter", "Franklin", "Holliday", "Hopper", "Shirley", nil],
|
||||||
|
"age": ["18", "269", "174", "119", "141", "16"],
|
||||||
|
"gender": ["M", "M", "M", "F", "F", "M"],
|
||||||
|
"tagLine": [
|
||||||
|
"😜", "A penny saved is a penny earned", "Bang", nil,
|
||||||
|
"God's in His heaven,\nall's right with the world", "Great snakes!"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
let orderedChunks: [OrderedKeyedCollection<String, Array<String?>>] = [
|
||||||
|
["first name": ["Caleb"], "last_name": ["Kleveter"], "age": ["18"], "gender": ["M"], "tagLine": ["😜"]],
|
||||||
|
[
|
||||||
|
"first name": ["Benjamin"], "last_name": ["Franklin"], "age": ["269"], "gender": ["M"],
|
||||||
|
"tagLine": ["A penny saved is a penny earned"]
|
||||||
|
],
|
||||||
|
["first name": ["Doc"], "last_name": ["Holliday"], "age": ["174"], "gender": ["M"], "tagLine": ["Bang"]],
|
||||||
|
["first name": ["Grace"], "last_name": ["Hopper"], "age": ["119"], "gender": ["F"], "tagLine": [nil]],
|
||||||
|
[
|
||||||
|
"first name": ["Anne"], "last_name": ["Shirley"], "age": ["141"], "gender": ["F"],
|
||||||
|
"tagLine": ["God's in His heaven,\nall's right with the world"]
|
||||||
|
],
|
||||||
|
["first name": ["TinTin"], "last_name": [nil], "age": ["16"], "gender": ["M"], "tagLine": ["Great snakes!"]]
|
||||||
|
]
|
||||||
|
|
||||||
|
let chunks: [String] = [
|
||||||
|
"first name,last_name,age",
|
||||||
|
",gender,tagLine\nCaleb,Kleveter,18,M,",
|
||||||
|
"😜\r\nBenjamin,Franklin,269,M,A penny saved is a ",
|
||||||
|
"penny earned\n\"",
|
||||||
|
#"Doc","Holliday","174","M",Bang\#r\#n"#,
|
||||||
|
"Grace,Hopper,119,F,",
|
||||||
|
#"\#nAnne,Shirley,141,F,"God's in His heaven,\#n"#,
|
||||||
|
#"all's right with the world""#,
|
||||||
|
"\nTinTin,,16,M,Great snakes!"
|
||||||
|
]
|
||||||
|
|
||||||
|
let data = """
|
||||||
|
first name,last_name,age,gender,tagLine
|
||||||
|
Caleb,Kleveter,18,M,😜\r
|
||||||
|
Benjamin,Franklin,269,M,A penny saved is a penny earned
|
||||||
|
"Doc","Holliday","174","M",Bang\r
|
||||||
|
Grace,Hopper,119,F,
|
||||||
|
Anne,Shirley,141,F,"God's in His heaven,
|
||||||
|
all's right with the world"
|
||||||
|
TinTin,,16,M,Great snakes!
|
||||||
|
"""
|
||||||
|
|
||||||
|
let expected = """
|
||||||
|
"first name","last_name","age","gender","tagLine"
|
||||||
|
"Caleb","Kleveter","18","M","😜"
|
||||||
|
"Benjamin","Franklin","269","M","A penny saved is a penny earned"
|
||||||
|
"Doc","Holliday","174","M","Bang"
|
||||||
|
"Grace","Hopper","119","F",""
|
||||||
|
"Anne","Shirley","141","F","God's in His heaven,
|
||||||
|
all's right with the world"
|
||||||
|
"TinTin","","16","M","Great snakes!"
|
||||||
|
"""
|
|
@ -123,26 +123,3 @@ fileprivate struct Person: Codable, Equatable {
|
||||||
case tagLine
|
case tagLine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let data = """
|
|
||||||
first name,last_name,age,gender,tagLine
|
|
||||||
Caleb,Kleveter,18,M,😜\r
|
|
||||||
Benjamin,Franklin,269,M,A penny saved is a penny earned
|
|
||||||
"Doc","Holliday","174","M",Bang\r
|
|
||||||
Grace,Hopper,119,F,
|
|
||||||
Anne,Shirley,141,F,"God's in His heaven,
|
|
||||||
all's right with the world"
|
|
||||||
TinTin,,16,M,Great snakes!
|
|
||||||
"""
|
|
||||||
|
|
||||||
fileprivate let chunks: [String] = [
|
|
||||||
"first name,last_name,age",
|
|
||||||
",gender,tagLine\nCaleb,Kleveter,18,M,",
|
|
||||||
"😜\r\nBenjamin,Franklin,269,M,A penny saved is a ",
|
|
||||||
"penny earned\n\"",
|
|
||||||
#"Doc","Holliday","174","M",Bang\#r\#n"#,
|
|
||||||
"Grace,Hopper,119,F,",
|
|
||||||
#"\#nAnne,Shirley,141,F,"God's in His heaven,\#n"#,
|
|
||||||
#"all's right with the world""#,
|
|
||||||
"\nTinTin,,16,M,Great snakes!"
|
|
||||||
]
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ final class EncoderTests: XCTestCase {
|
||||||
|
|
||||||
func testSyncEncode() throws {
|
func testSyncEncode() throws {
|
||||||
let encoder = CSVEncoder().sync
|
let encoder = CSVEncoder().sync
|
||||||
let data = try encoder.encode(people)
|
let encoded = try encoder.encode(people)
|
||||||
let string = String(decoding: data, as: UTF8.self)
|
let string = String(decoding: encoded, as: UTF8.self)
|
||||||
|
|
||||||
XCTAssertEqual(string, expected)
|
XCTAssertEqual(string, expected)
|
||||||
}
|
}
|
||||||
|
@ -93,14 +93,3 @@ fileprivate let people = [
|
||||||
),
|
),
|
||||||
Person(firstName: "TinTin", lastName: nil, age: 16, gender: .male, tagLine: "Great snakes!")
|
Person(firstName: "TinTin", lastName: nil, age: 16, gender: .male, tagLine: "Great snakes!")
|
||||||
]
|
]
|
||||||
|
|
||||||
fileprivate let expected = """
|
|
||||||
"first name","last_name","age","gender","tagLine"
|
|
||||||
"Caleb","Kleveter","18","M","😜"
|
|
||||||
"Benjamin","Franklin","269","M","A penny saved is a penny earned"
|
|
||||||
"Doc","Holliday","174","M","Bang"
|
|
||||||
"Grace","Hopper","119","F",""
|
|
||||||
"Anne","Shirley","141","F","God's in His heaven,
|
|
||||||
all's right with the world"
|
|
||||||
"TinTin","","16","M","Great snakes!"
|
|
||||||
"""
|
|
||||||
|
|
|
@ -110,26 +110,3 @@ final class ParserTests: XCTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let data = """
|
|
||||||
first name,last_name,age,gender,tagLine
|
|
||||||
Caleb,Kleveter,18,M,😜\r
|
|
||||||
Benjamin,Franklin,269,M,A penny saved is a penny earned
|
|
||||||
"Doc","Holliday","174","M",Bang\r
|
|
||||||
Grace,Hopper,119,F,
|
|
||||||
Anne,Shirley,141,F,"God's in His heaven,
|
|
||||||
all's right with the world"
|
|
||||||
TinTin,,16,M,Great snakes!
|
|
||||||
"""
|
|
||||||
|
|
||||||
fileprivate let chunks: [String] = [
|
|
||||||
"first name,last_name,age",
|
|
||||||
",gender,tagLine\nCaleb,Kleveter,18,M,",
|
|
||||||
"😜\r\nBenjamin,Franklin,269,M,A penny saved is a ",
|
|
||||||
"penny earned\n\"",
|
|
||||||
#"Doc","Holliday","174","M",Bang\#r\#n"#,
|
|
||||||
"Grace,Hopper,119,F,",
|
|
||||||
#"\#nAnne,Shirley,141,F,"God's in His heaven,\#n"#,
|
|
||||||
#"all's right with the world""#,
|
|
||||||
"\nTinTin,,16,M,Great snakes!"
|
|
||||||
]
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ final class SerializerTests: XCTestCase {
|
||||||
// 6.679
|
// 6.679
|
||||||
measure {
|
measure {
|
||||||
for _ in 0..<100_000 {
|
for _ in 0..<100_000 {
|
||||||
_ = serializer.serialize(data)
|
_ = serializer.serialize(orderedData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,75 +38,12 @@ final class SerializerTests: XCTestCase {
|
||||||
// 5.896
|
// 5.896
|
||||||
measure {
|
measure {
|
||||||
for _ in 0..<100_000 {
|
for _ in 0..<100_000 {
|
||||||
chunks.forEach { chunk in serializer.serialize(chunk) }
|
orderedChunks.forEach { chunk in serializer.serialize(chunk) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate let orderedData: OrderedKeyedCollection = [
|
|
||||||
"first name": ["Caleb", "Benjamin", "Doc", "Grace", "Anne", "TinTin"],
|
|
||||||
"last_name": ["Kleveter", "Franklin", "Holliday", "Hopper", "Shirley", nil],
|
|
||||||
"age": ["18", "269", "174", "119", "141", "16"],
|
|
||||||
"gender": ["M", "M", "M", "F", "F", "M"],
|
|
||||||
"tagLine": [
|
|
||||||
"😜", "A penny saved is a penny earned", "Bang", nil,
|
|
||||||
"God's in His heaven,\nall's right with the world", "Great snakes!"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
fileprivate let data = [
|
|
||||||
"first name": ["Caleb", "Benjamin", "Doc", "Grace", "Anne", "TinTin"],
|
|
||||||
"last_name": ["Kleveter", "Franklin", "Holliday", "Hopper", "Shirley", nil],
|
|
||||||
"age": ["18", "269", "174", "119", "141", "16"],
|
|
||||||
"gender": ["M", "M", "M", "F", "F", "M"],
|
|
||||||
"tagLine": [
|
|
||||||
"😜", "A penny saved is a penny earned", "Bang", nil,
|
|
||||||
"God's in His heaven,\nall's right with the world", "Great snakes!"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
fileprivate let orderedChunks: [OrderedKeyedCollection<String, Array<String?>>] = [
|
|
||||||
["first name": ["Caleb"], "last_name": ["Kleveter"], "age": ["18"], "gender": ["M"], "tagLine": ["😜"]],
|
|
||||||
[
|
|
||||||
"first name": ["Benjamin"], "last_name": ["Franklin"], "age": ["269"], "gender": ["M"],
|
|
||||||
"tagLine": ["A penny saved is a penny earned"]
|
|
||||||
],
|
|
||||||
["first name": ["Doc"], "last_name": ["Holliday"], "age": ["174"], "gender": ["M"], "tagLine": ["Bang"]],
|
|
||||||
["first name": ["Grace"], "last_name": ["Hopper"], "age": ["119"], "gender": ["F"], "tagLine": [nil]],
|
|
||||||
[
|
|
||||||
"first name": ["Anne"], "last_name": ["Shirley"], "age": ["141"], "gender": ["F"],
|
|
||||||
"tagLine": ["God's in His heaven,\nall's right with the world"]
|
|
||||||
],
|
|
||||||
["first name": ["TinTin"], "last_name": [nil], "age": ["16"], "gender": ["M"], "tagLine": ["Great snakes!"]]
|
|
||||||
]
|
|
||||||
|
|
||||||
fileprivate let chunks = [
|
|
||||||
["first name": ["Caleb"], "last_name": ["Kleveter"], "age": ["18"], "gender": ["M"], "tagLine": ["😜"]],
|
|
||||||
[
|
|
||||||
"first name": ["Benjamin"], "last_name": ["Franklin"], "age": ["269"], "gender": ["M"],
|
|
||||||
"tagLine": ["A penny saved is a penny earned"]
|
|
||||||
],
|
|
||||||
["first name": ["Doc"], "last_name": ["Holliday"], "age": ["174"], "gender": ["M"], "tagLine": ["Bang"]],
|
|
||||||
["first name": ["Grace"], "last_name": ["Hopper"], "age": ["119"], "gender": ["F"], "tagLine": [nil]],
|
|
||||||
[
|
|
||||||
"first name": ["Anne"], "last_name": ["Shirley"], "age": ["141"], "gender": ["F"],
|
|
||||||
"tagLine": ["God's in His heaven,\nall's right with the world"]
|
|
||||||
],
|
|
||||||
["first name": ["TinTin"], "last_name": [nil], "age": ["16"], "gender": ["M"], "tagLine": ["Great snakes!"]]
|
|
||||||
]
|
|
||||||
|
|
||||||
fileprivate let expected = """
|
|
||||||
"first name","last_name","age","gender","tagLine"
|
|
||||||
"Caleb","Kleveter","18","M","😜"
|
|
||||||
"Benjamin","Franklin","269","M","A penny saved is a penny earned"
|
|
||||||
"Doc","Holliday","174","M","Bang"
|
|
||||||
"Grace","Hopper","119","F",""
|
|
||||||
"Anne","Shirley","141","F","God's in His heaven,
|
|
||||||
all's right with the world"
|
|
||||||
"TinTin","","16","M","Great snakes!"
|
|
||||||
"""
|
|
||||||
|
|
||||||
internal struct OrderedKeyedCollection<K, V>: KeyedCollection, ExpressibleByDictionaryLiteral where K: Hashable {
|
internal struct OrderedKeyedCollection<K, V>: KeyedCollection, ExpressibleByDictionaryLiteral where K: Hashable {
|
||||||
typealias Index = Int
|
typealias Index = Int
|
||||||
typealias Element = (key: Key, value: Value)
|
typealias Element = (key: Key, value: Value)
|
||||||
|
|
Loading…
Reference in New Issue