root/Encode-Punycode/trunk/t/01_punycode.t

Revision 639 (checked in by miyagawa, 18 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 use strict;
2 use Test::More 'no_plan';
3
4 use Encode::Punycode;
5 use Encode;
6
7 my @input = read_sample('t/sample.txt');
8 for (@input) {
9     my($utf8, $punycode) = @$_;
10     is encode('Punycode', $utf8), $punycode;
11     is decode('Punycode', $punycode), $utf8;
12 }
13
14 sub read_sample {
15     open my $fh, shift;
16     local $/ = '';
17     my @input;
18     while (my $block = <$fh>) {
19         next if $block !~ /Punycode:/;
20         my @unicode = $block =~ /u\+([0-9a-f]{4})/gi;
21         my $punycode = ($block =~ /Punycode: (.+?)\n$/s)[0];
22         push @input, [ join('', map chr(hex($_)), @unicode), $punycode ];
23     }
24     return @input;
25 }
26
27
Note: See TracBrowser for help on using the browser.