aboutsummaryrefslogtreecommitdiff
path: root/t/records.t
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-10-05 10:30:33 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-10-05 10:30:52 +1300
commit117d5e17261250378645a10a04843486d722e75d (patch)
tree7eddb44b329a8e1a11e2c9c1b064c5dfff90745d /t/records.t
parentbb177922d963591dd4ba38927ac136cc4496ad87 (diff)
downloadList-Breakdown-117d5e17261250378645a10a04843486d722e75d.tar.gz
Add "records" example and accompanying test
Tweak last paragraph of second example so it flows.
Diffstat (limited to 't/records.t')
-rw-r--r--t/records.t42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/records.t b/t/records.t
new file mode 100644
index 0000000..8af3e1a
--- /dev/null
+++ b/t/records.t
@@ -0,0 +1,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' );