File: 18_unicode.t

package info (click to toggle)
libwx-perl 1%3A0.9932-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 4,416 kB
  • sloc: cpp: 11,044; perl: 8,596; ansic: 711; makefile: 49
file content (61 lines) | stat: -rwxr-xr-x 1,586 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
#!/usr/bin/perl -w

use strict;
use Wx;
use lib './t';
use Tests_Helper qw(in_frame);
use Test::More 'tests' => 12;
use utf8;
use Encode qw(is_utf8);

my $ascii   = 'Abcde';
my $ascii2  = 'XXX';
my $utf8    = 'Àbcdë';
my $unicode = "\x{1234}";

in_frame(
    sub {
        my $self = shift;

        my $label = Wx::StaticText->new( $self, -1, $ascii );
        is( $label->GetLabel, $ascii );

        $label->SetLabel( $ascii2 );
        is( $label->GetLabel, $ascii2 );

        SKIP: {
            skip "Only meaningful in ANSI mode", 4
                if Wx::wxUNICODE;

            # it would be better to use the latin1 label, but it might
            # not round trip if the GUI locale is not latin1
            $label->SetLabel( $ascii );

            Wx::SetAlwaysUTF8( 1 );
            is( $label->GetLabel, $ascii );
            ok( is_utf8( $label->GetLabel ) );

            Wx::SetAlwaysUTF8( 0 );
            is( $label->GetLabel, $ascii );
            ok( !is_utf8( $label->GetLabel ) );
        };

        SKIP: {
            skip "Unicode support needed for the tests", 6
                unless Wx::wxUNICODE;
            skip "wrongly asserts under 2.5.x", 6
                if Wx::wxVERSION < 2.006;

            $label->SetLabel( $utf8 );
            is( $label->GetLabel, $utf8 );

            ok( is_utf8( $utf8 ) );
            ok( is_utf8( $label->GetLabel ) );

            $label->SetLabel( $unicode );
            is( $label->GetLabel, $unicode );

            ok( is_utf8( $unicode ) );
            ok( is_utf8( $label->GetLabel ) );
        }
    } );