forked from swiftlang/swift-build
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSVTests.swift
40 lines (36 loc) · 1.31 KB
/
CSVTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import Foundation
import Testing
import SWBUtil
@SuitefileprivatestructCSVTests{
@Test
func CSVEscaping(){
#expect("test".csvEscaped()=="test")
#expect("has whitespace".csvEscaped()=="\"has whitespace\"")
#expect("has\nnewline".csvEscaped()=="\"has\nnewline\"")
#expect("has,comma".csvEscaped()=="\"has,comma\"")
#expect("has\"quote".csvEscaped()=="\"has\"\"quote\"")
}
@Test
func CSVStream(){
varbuilder=CSVBuilder()
builder.writeRow(["col1","col2","col3"])
builder.writeRow(["v1","v2","v3"])
builder.writeRow(["has whitespace","has,comma","has\"quote"])
#expect(builder.output =="""
col1,col2,col3\r
v1,v2,v3\r
"has whitespace","has,comma","has""quote"\r
""")
}
}