-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathcsv-builder.rs
More file actions
58 lines (46 loc) · 1.06 KB
/
csv-builder.rs
File metadata and controls
58 lines (46 loc) · 1.06 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use csv_builder::*;
#[test]
fn no_escaping() {
let mut builder = CsvRecordBuilder::new();
builder.add("ant");
builder.add("bat");
builder.add("cat");
let list = builder.build();
// Note that builder has been consumed so we cannot use it
assert_eq!("ant,bat,cat", &list);
}
#[test]
#[ignore]
fn quote() {
let mut builder = CsvRecordBuilder::new();
builder.add("ant");
builder.add("ba\"t");
builder.add("cat");
let list = builder.build();
assert_eq!(r#"ant,"ba""t",cat"#, &list);
}
#[test]
#[ignore]
fn new_line() {
let mut builder = CsvRecordBuilder::new();
builder.add("ant");
builder.add("ba\nt");
let list = builder.build();
assert_eq!("ant,\"ba\nt\"", &list);
}
#[test]
#[ignore]
fn comma() {
let mut builder = CsvRecordBuilder::new();
builder.add("ant");
builder.add("ba,t");
let list = builder.build();
assert_eq!("ant,\"ba,t\"", &list);
}
#[test]
#[ignore]
fn empty() {
let builder = CsvRecordBuilder::new();
let list = builder.build();
assert!(list.is_empty());
}