ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-Scalar/t/01_utf8.t
Revision: 1.1
Committed: Thu Sep 27 18:32:25 2001 UTC (24 years, 11 months ago) by root
Content type: application/x-troff
Branch: MAIN
CVS Tags: rel-1_1, rel-1_11, rel-1_04, rel-1_12, HEAD
Log Message:
*** empty log message ***

File Contents

# Content
1 BEGIN { $| = 1; print "1..21\n"; }
2
3 use Convert::Scalar ':utf8';
4
5 no bytes;
6
7 $y = "\xff\x90\x44";
8
9 utf8_encode $y;
10
11 print length($y)==5 ? "" : "not ", "ok 1\n";
12 print utf8_length($y)==3 ? "" : "not ", "ok 2\n";
13
14 utf8_upgrade $y;
15 print utf8_length($y)==5 ? "" : "not ", "ok 3\n";
16 print length($y)==5 ? "" : "not ", "ok 4\n";
17
18 print utf8_downgrade($y) ? "" : "not ", "ok 5\n";
19 print utf8_length($y)==3 ? "" : "not ", "ok 6\n";
20 print length($y)==5 ? "" : "not ", "ok 7\n";
21
22 $y = "\x{257}";
23 print !utf8_downgrade($y, 1) ? "" : "not ", "ok 8\n";
24 print !eval {
25 utf8_downgrade($y, 0);
26 1;
27 } ? "" : "not ", "ok 9\n";
28
29 $b = "1234\xc0";
30 {
31 use utf8;
32 $u = "\x{1234}";
33 }
34
35 print utf8($b) ? "not " : "", "ok 10\n";
36 print utf8($u) ? "" : "not ", "ok 11\n";
37 print utf8($b) ? "not " : "", "ok 12\n";
38 print utf8($u) ? "" : "not ", "ok 13\n";
39 utf8 $b,1;
40 utf8_off $u;
41 print utf8($b) ? "" : "not ", "ok 14\n";
42 print utf8($u) ? "not " : "", "ok 15\n";
43
44 if ($] < 5.007) {
45 print "ok 16\n";
46 print "ok 17\n";
47 } else {
48 print utf8_valid $b ? "not " : "", "ok 16\n";
49 print utf8_valid $u ? "" : "not ", "ok 17\n";
50 }
51
52 print utf8_on($u) eq $u ? "" : "not ", "ok 18\n";
53 print utf8($u) ? "" : "not ", "ok 19\n";
54 print utf8_off($u) eq $u ? "" : "not ", "ok 20\n";
55 print utf8($u) ? "not " : "", "ok 21\n";
56