File: 00-basics.t

package info (click to toggle)
libencoding-fixlatin-xs-perl 1.02-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 320 kB
  • sloc: perl: 166; makefile: 3; sh: 1
file content (64 lines) | stat: -rw-r--r-- 1,323 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!perl -T

use strict;
use warnings;

use Test::More;

use Encoding::FixLatin;
use Encoding::FixLatin::XS;

ok(1, "Successfully loaded Encoding::FixLatin::XS via 'use'");

diag(
    "Testing Encoding::FixLatin::XS $Encoding::FixLatin::XS::VERSION, "
  . "Encoding::FixLatin $Encoding::FixLatin::VERSION, Perl $], $^X"
);

ok(
    UNIVERSAL::can('Encoding::FixLatin::XS','_fix_latin_xs'),
    'expected XS sub is available'
);

# Alias XS sub name to something shorter for test purposes

*fx = \&Encoding::FixLatin::XS::_fix_latin_xs;

is(
    fx("Plain ASCII", 0, 1),
    "Plain ASCII",
    "plain ASCII input is returned unchanged"
);

is(
    fx("Longer plain ASCII with newline\n", 0, 1),
    "Longer plain ASCII with newline\n",
    "longer plain ASCII input with newline is returned unchanged"
);

is(
    fx("Plain ASCII\0with embedded null byte", 0, 1),
    "Plain ASCII\0with embedded null byte",
    "plain ASCII input with embedded null byte returned unchanged"
);

is(
    fx("M\xC4\x81ori", 0, 1),
    "M\x{101}ori",
    "UTF-8 bytes passed through"
);

is(
    fx("Caf\xE9", 0, 1),
    "Caf\x{E9}",
    "latin byte transcoded to UTF-8"
);

is(
    fx("Caf\xE9 Rom\xC4\x81 (\xE2\x82\xAC9.99)", 0, 1),
    "Caf\x{E9} Rom\x{101} (\x{20AC}9.99)",
    "mixed latin and UTF-8 translated to UTF-8"
);

done_testing;