aboutsummaryrefslogtreecommitdiff
path: root/t/records.t
blob: 6801614d64b9b04b2b2a7b2deef2a7e5bb5c5a5a (plain) (blame)
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
#!perl -T

use strict;
use warnings;
use utf8;

use Test::More tests => 1;

use List::Breakdown 'breakdown';

our $VERSION = '0.11';

my @records = (
    "NEW CUSTOMER John O''Connor\r 2017-01-01",
    "RETURNING CUSTOMER\tXah Lee 2016-01-01",
    'CHECK ACCOUNT Pierre d\'Alun 2016-12-01',
    'RETURNING CUSTOMER Aaron Carter 2016-05-01',
);

my %buckets = (
    bad_whitespace     => qr/ [\r\t] /msx,
    apostrophes        => qr/ ' /msx,
    double_apostrophes => qr/ '' /msx,
    not_ascii          => qr/ [^[:ascii:]] /msx,
);

my %results = breakdown \%buckets, @records;

my %expected = (
    apostrophes => [
        "NEW CUSTOMER John O''Connor\r 2017-01-01",
        'CHECK ACCOUNT Pierre d\'Alun 2016-12-01',
    ],
    bad_whitespace => [
        "NEW CUSTOMER John O''Connor\r 2017-01-01",
        "RETURNING CUSTOMER\tXah Lee 2016-01-01",
    ],
    double_apostrophes => ["NEW CUSTOMER John O''Connor\r 2017-01-01"],
    not_ascii          => [],
);

is_deeply( \%results, \%expected, 'records' );