1*0Sstevel@tonic-gate#!../perl 2*0Sstevel@tonic-gateour $POWER; 3*0Sstevel@tonic-gateBEGIN { 4*0Sstevel@tonic-gate if ($ENV{'PERL_CORE'}){ 5*0Sstevel@tonic-gate chdir 't'; 6*0Sstevel@tonic-gate unshift @INC, '../lib'; 7*0Sstevel@tonic-gate } 8*0Sstevel@tonic-gate require Config; import Config; 9*0Sstevel@tonic-gate if ($Config{'extensions'} !~ /\bEncode\b/) { 10*0Sstevel@tonic-gate print "1..0 # Skip: Encode was not built\n"; 11*0Sstevel@tonic-gate exit 0; 12*0Sstevel@tonic-gate } 13*0Sstevel@tonic-gate $POWER = 12; # up to 1 MB. You may adjust the figure here 14*0Sstevel@tonic-gate} 15*0Sstevel@tonic-gate 16*0Sstevel@tonic-gateuse strict; 17*0Sstevel@tonic-gateuse Encode; 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gatemy $seed = ""; 20*0Sstevel@tonic-gatefor my $i (0x00..0xff){ 21*0Sstevel@tonic-gate my $c = chr($i); 22*0Sstevel@tonic-gate $seed .= ($c =~ /^\p{IsPrint}/o) ? $c : " "; 23*0Sstevel@tonic-gate} 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gateuse Test::More tests => $POWER*2; 26*0Sstevel@tonic-gatemy $octs = $seed; 27*0Sstevel@tonic-gateuse bytes (); 28*0Sstevel@tonic-gatefor my $i (1..$POWER){ 29*0Sstevel@tonic-gate $octs .= $octs; 30*0Sstevel@tonic-gate my $len = bytes::length($octs); 31*0Sstevel@tonic-gate my $utf8 = Encode::decode('latin1', $octs); 32*0Sstevel@tonic-gate ok(1, "decode $len bytes"); 33*0Sstevel@tonic-gate is($octs, 34*0Sstevel@tonic-gate Encode::encode('latin1', $utf8), 35*0Sstevel@tonic-gate "encode $len bytes"); 36*0Sstevel@tonic-gate} 37*0Sstevel@tonic-gate__END__ 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate 40