File: writer.t

package info (click to toggle)
libmixin-linewise-perl 0.111-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 303; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 936 bytes parent folder | download | duplicates (3)
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
43
44
45
use strict;
use warnings;
use Test::More 0.88;

use utf8;
use lib 't/lib';
use MLTests;
use Encode qw/encode encode_utf8/;

my $builder = Test::More->builder;
binmode $builder->output,         ":utf8";
binmode $builder->failure_output, ":utf8";
binmode $builder->todo_output,    ":utf8";

{
  package WriterTester;
  use Mixin::Linewise::Writers -writers;

  sub write_handle {
    my ($self, $data, $handle) = @_;
    print {$handle} $data;
  }
}

{
  my $name = "®icardo Sígnes";
  my $raw  = encode_utf8($name);

  my $output = WriterTester->write_string($name);
  is($output, $raw, "wrote a text string and got an octet string (UTF-8)");
}

{
  my $name = "Ĉamomile";
  my $raw  = encode('Latin-3', $name);

  my $output = WriterTester->write_string(
    { binmode => 'encoding(Latin-3)' },
    $name,
  );
  is($output, $raw, "wrote a text string and got an octet string (Latin-3)");
}

done_testing;
# vim: ts=2 sts=2 sw=2 et: