File: 02csv.t

package info (click to toggle)
libspreadsheet-wright-perl 0.105-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 244 kB
  • sloc: perl: 846; makefile: 15
file content (29 lines) | stat: -rw-r--r-- 607 bytes parent folder | download | duplicates (4)
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
use Test::More tests => 1;
use Spreadsheet::Wright;

my $FN = 'temp.csv';

SKIP: {
	open FILE, '>', $FN
		or skip "cannot write to temporary file.", 1;
	close FILE;

	my $h = Spreadsheet::Wright->new(file => $FN, csv_options=>{eol=>"\n"});
	$h->addrow('Name', 'Discovery');
	$h->addrows(
		['Archimedes', 'Water displacement'],
		['Albert Einstein', 'General relativity'],
		);
	$h->close;

	my $contents = do { open my($fh), $FN; local $/ = <$fh>; };

	is($contents, <<'DATA', 'CSV output works');
Name,Discovery
Archimedes,"Water displacement"
"Albert Einstein","General relativity"
DATA

	unlink $FN;
}