From: Nick Ing-Simmons Date: Tue, 2 Apr 2002 07:49:41 +0000 (+0000) Subject: Add buffer size growth test. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d5b6c7edbe190a89aa98bae64e09d145a4ebffba;p=p5sagit%2Fp5-mst-13.2.git Add buffer size growth test. p4raw-id: //depot/perlio@15675 --- diff --git a/MANIFEST b/MANIFEST index e6fa325..355c5ed 100644 --- a/MANIFEST +++ b/MANIFEST @@ -248,6 +248,7 @@ ext/Encode/t/Encode.t Encode extension test ext/Encode/t/encoding.t Encode extension test ext/Encode/t/gb2312.euc test data ext/Encode/t/gb2312.ref test data +ext/Encode/t/grow.t Buffer size growth test ext/Encode/t/jisx0208.euc test data ext/Encode/t/jisx0208.ref test data ext/Encode/t/jisx0212.euc test data diff --git a/ext/Encode/MANIFEST b/ext/Encode/MANIFEST index bde0b22..b6ec225 100644 --- a/ext/Encode/MANIFEST +++ b/ext/Encode/MANIFEST @@ -55,6 +55,7 @@ t/TW.t Encode extension test t/encoding.t encoding extension test t/gb2312.euc test data t/gb2312.ref test data +t/grow.t Buffer size growth test t/jisx0208.euc test data t/jisx0208.ref test data t/jisx0212.euc test data diff --git a/ext/Encode/t/grow.t b/ext/Encode/t/grow.t new file mode 100644 index 0000000..e6b35fc --- /dev/null +++ b/ext/Encode/t/grow.t @@ -0,0 +1,39 @@ +#!../perl +our $POWER; +BEGIN { + if ($ENV{'PERL_CORE'}){ + chdir 't'; + unshift @INC, '../lib'; + } + require Config; import Config; + if ($Config{'extensions'} !~ /\bEncode\b/) { + print "1..0 # Skip: Encode was not built\n"; + exit 0; + } + $POWER = 12; # up to 1 MB. You may adjust the figure here +} + +use strict; +use Encode; + +my $seed = ""; +for my $i (0x00..0xff){ + my $c = chr($i); + $seed .= ($c =~ /^\p{IsPrint}/o) ? $c : " "; +} + +use Test::More tests => $POWER*2; +my $octs = $seed; +use bytes (); +for my $i (1..$POWER){ + $octs .= $octs; + my $len = bytes::length($octs); + my $utf8 = Encode::decode('latin1', $octs); + ok(1, "decode $len bytes"); + is($octs, + Encode::encode('latin1', $utf8), + "encode $len bytes"); +} +__END__ + +