File Coverage

t/file-dsv.t
Criterion Covered Total %
statement 35 35 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 41 41 100.0


line stmt bran cond sub pod time code
1 1     1   28827 use strict;
  1         2  
  1         48  
2 1     1   4 use warnings;
  1         1  
  1         23  
3 1     1   10 use v5.12;
  1         3  
  1         32  
4              
5 1     1   326 use Test::More tests => 8;
  1         11222  
  1         6  
6              
7 1     1   462 use Sweet::Dir;
  1         2  
  1         27  
8 1     1   303 use Sweet::File::DSV;
  1         2  
  1         2055  
9              
10 1         120316 my $test_dir = Sweet::Dir->new( path => 't' );
11              
12 1         25 my $file1 = Sweet::File::DSV->new(
13                 name => 'file1.dat',
14                 dir => $test_dir,
15                 separator => '|',
16             );
17              
18 1         3 my @file1_fields = ('FIELD_A', 'FIELD_B');
19 1         2 my @file1_rows = ('foo|bar', '2|3');
20 1         3 my @file1_cells = (['foo', 'bar'], ['2', '3']);
21              
22 1         19 is $file1->header, 'FIELD_A|FIELD_B', 'header';
23              
24 1         248 my @got_rows = $file1->rows;
25 1         3 is_deeply \@got_rows, \@file1_rows, 'rows';
26              
27 1         383 is $file1->num_rows,scalar(@file1_rows);
28              
29 1         179 my @got_fields = $file1->fields;
30 1         3 is_deeply \@got_fields, \@file1_fields, 'fields';
31              
32 1         355 is $file1->field(0), $file1_fields[0], 'field(0)';
33 1         183 is $file1->field(1), $file1_fields[1], 'field(1)';
34              
35 1         155 my @got_cells1 = $file1->split_row->(0);
36 1         6 my @got_cells2 = $file1->split_row->(1);
37              
38 1         6 is_deeply \@got_cells1, $file1_cells[0], 'split_row 1';
39 1         447 is_deeply \@got_cells2, $file1_cells[1], 'split_row 2';
40              
41