1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

encoding.csv: re-encapsulate fields in Writer/Reader (fix #15558) (#15570)

This commit is contained in:
ChAoS_UnItY
2022-08-28 16:13:43 +08:00
committed by GitHub
parent 797bdd5e98
commit 258ff73efd
3 changed files with 26 additions and 10 deletions

View File

@ -9,3 +9,13 @@ fn test_encoding_csv_writer() {
assert csv_writer.str() == 'name,email,phone,other\njoe,joe@blow.com,0400000000,test\nsam,sam@likesham.com,0433000000,"needs, quoting"\n'
}
fn test_encoding_csv_writer_delimiter() {
mut csv_writer := csv.new_writer(delimiter: ` `)
csv_writer.write(['name', 'email', 'phone', 'other']) or {}
csv_writer.write(['joe', 'joe@blow.com', '0400000000', 'test']) or {}
csv_writer.write(['sam', 'sam@likesham.com', '0433000000', 'needs, quoting']) or {}
assert csv_writer.str() == 'name email phone other\njoe joe@blow.com 0400000000 test\nsam sam@likesham.com 0433000000 "needs, quoting"\n'
}