File: 03-separator.t

package info (click to toggle)
libtext-recordparser-perl 1.6.5-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 440 kB
  • sloc: perl: 3,351; makefile: 4
file content (34 lines) | stat: -rw-r--r-- 1,007 bytes parent folder | download | duplicates (5)
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
#!perl

#
# test for "field_separator" and "record_separator"
#

use strict;
use File::Spec::Functions;
use FindBin qw( $Bin );
use Test::More tests => 8;
use Text::RecordParser;
use Readonly;

Readonly my $TEST_DATA_DIR => catdir( $Bin, 'data' );

{
    my $p = Text::RecordParser->new;
    is( $p->field_separator, ',', 'Field separator is comma' );
    is( $p->field_separator("\t"), "\t", 'Field separator is tab' );
    is( $p->field_separator('::'), '::', 'Field separator is double colon' );
    is( ref $p->field_separator(qr/\s+/), 'Regexp', 
        'Field separator is a regular expression' );

    is( $p->record_separator, "\n", 'Record separator is newline' );
    is( $p->record_separator("\n\n"), "\n\n", 
        'Record separator is double newline' 
    );
    is( $p->record_separator(':'), ':', 'Record separator is colon' );
}

{
    my $p2 = Text::RecordParser->new(catfile($TEST_DATA_DIR, 'simpsons.tab'));
    is( $p2->field_separator("\t"), "\t", 'Field separator guessed tab' );
}