summaryrefslogtreecommitdiff
path: root/t/qrcode.t
diff options
context:
space:
mode:
Diffstat (limited to 't/qrcode.t')
-rw-r--r--t/qrcode.t50
1 files changed, 17 insertions, 33 deletions
diff --git a/t/qrcode.t b/t/qrcode.t
index f82c5ff..14e8bd7 100644
--- a/t/qrcode.t
+++ b/t/qrcode.t
@@ -3,43 +3,27 @@ use strict;
use warnings;
use Test2::Bundle::Extended;
use Data::QRCode;
-use Data::QRCode::Input;
-my $input = Data::QRCode::Input->new;
-$input->error_correction_level(Data::QRCode::Input::ECLEVEL_M);
-$input->append(Data::QRCode::Input::MODE_8,'some words');
+my $qr = Data::QRCode->new({
+ input_data => 'some words',
+});
-my $qr = Data::QRCode->new($input);
-
-is(
- $qr->version,
- 1,
- 'version should be set',
-);
-
-is(
- $qr->width,
- 21,
- 'width should be set',
+my $text_matrix = $qr->map(
+ sub{
+ my ($data) = @_;
+ !$data->{color} ? ' ' :
+ $data->{in_data} ? 'D' :
+ $data->{in_format} ? 'F' :
+ $data->{in_version} ? 'V' :
+ $data->{in_timing} ? 'T' :
+ $data->{in_alignment} ? 'A' :
+ $data->{in_finder} ? 'R' :
+ '*';
+ },
);
-my $text;
-for my $y (0..$qr->width-1) {
- for my $x (0..$qr->width-1) {
- my $data = $qr->data_at($x,$y);
- $text .= (
- !$data->{color} ? ' ' :
- $data->{in_data} ? 'D' :
- $data->{in_format} ? 'F' :
- $data->{in_version} ? 'V' :
- $data->{in_timing} ? 'T' :
- $data->{in_alignment} ? 'A' :
- $data->{in_finder} ? 'R' :
- '*'
- );
- }
- $text .= "\n";
-}
+my $text = join "\n", map { join '',@{$_} } @{$text_matrix};
+$text .= "\n";
is($text,<<'QRCODE','data should be as expected');
RRRRRRR F DDD RRRRRRR