1*0Sstevel@tonic-gate# 2*0Sstevel@tonic-gate# $Id: Encoder.t,v 1.3 2002/04/16 23:35:00 dankogai Exp $ 3*0Sstevel@tonic-gate# 4*0Sstevel@tonic-gate 5*0Sstevel@tonic-gateBEGIN { 6*0Sstevel@tonic-gate require Config; import Config; 7*0Sstevel@tonic-gate if ($Config{'extensions'} !~ /\bEncode\b/) { 8*0Sstevel@tonic-gate print "1..0 # Skip: Encode was not built\n"; 9*0Sstevel@tonic-gate exit 0; 10*0Sstevel@tonic-gate } 11*0Sstevel@tonic-gate $| = 1; 12*0Sstevel@tonic-gate} 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gateuse strict; 15*0Sstevel@tonic-gate#use Test::More 'no_plan'; 16*0Sstevel@tonic-gateuse Test::More tests => 516; 17*0Sstevel@tonic-gateuse Encode::Encoder qw(encoder); 18*0Sstevel@tonic-gateuse MIME::Base64; 19*0Sstevel@tonic-gatepackage Encode::Base64; 20*0Sstevel@tonic-gateuse base 'Encode::Encoding'; 21*0Sstevel@tonic-gate__PACKAGE__->Define('base64'); 22*0Sstevel@tonic-gateuse MIME::Base64; 23*0Sstevel@tonic-gatesub encode{ 24*0Sstevel@tonic-gate my ($obj, $data) = @_; 25*0Sstevel@tonic-gate return encode_base64($data); 26*0Sstevel@tonic-gate} 27*0Sstevel@tonic-gatesub decode{ 28*0Sstevel@tonic-gate my ($obj, $data) = @_; 29*0Sstevel@tonic-gate return decode_base64($data); 30*0Sstevel@tonic-gate} 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gatepackage main; 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gatemy $e = encoder("foo", "ascii"); 35*0Sstevel@tonic-gateok ($e->data("bar")); 36*0Sstevel@tonic-gateis ($e->data, "bar"); 37*0Sstevel@tonic-gateok ($e->encoding("latin1")); 38*0Sstevel@tonic-gateis ($e->encoding, "iso-8859-1"); 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gatemy $data = ''; 41*0Sstevel@tonic-gatefor my $i (0..255){ 42*0Sstevel@tonic-gate no warnings; 43*0Sstevel@tonic-gate $data .= chr($i); 44*0Sstevel@tonic-gate my $base64 = encode_base64($data); 45*0Sstevel@tonic-gate is(encoder($data)->base64, $base64, "encode"); 46*0Sstevel@tonic-gate is(encoder($base64)->bytes('base64'), $data, "decode"); 47*0Sstevel@tonic-gate} 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate1; 50*0Sstevel@tonic-gate__END__ 51