summaryrefslogtreecommitdiff
path: root/ext/MIME/Base64/t
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-02-17 23:10:22 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-02-17 23:10:22 +0000
commit0a362e9d28eb95760d6605a4ce6ad3a83060c87d (patch)
tree0cb7d57cd746275390626a9bafdc19698fcbadf6 /ext/MIME/Base64/t
parentfa46452ec9ba26e5de44bed7a267bfa0c4ce7a24 (diff)
downloadperl-0a362e9d28eb95760d6605a4ce6ad3a83060c87d.tar.gz
Upgrade to MIME::Base64 3.00.
Fix t/warn.t so it works in the core. Reintegrate change #22309 in it. Bump $VERSION to 3.00_01. p4raw-link: @22309 on //depot/perl: 1b96abaf83c640ae3fca4becfa82d376954d73cc p4raw-id: //depot/perl@22325
Diffstat (limited to 'ext/MIME/Base64/t')
-rw-r--r--ext/MIME/Base64/t/bad-sv.t42
-rw-r--r--ext/MIME/Base64/t/base64.t12
-rw-r--r--ext/MIME/Base64/t/warn.t74
3 files changed, 116 insertions, 12 deletions
diff --git a/ext/MIME/Base64/t/bad-sv.t b/ext/MIME/Base64/t/bad-sv.t
new file mode 100644
index 0000000000..3505b80ce1
--- /dev/null
+++ b/ext/MIME/Base64/t/bad-sv.t
@@ -0,0 +1,42 @@
+#!perl -w
+
+BEGIN {
+ eval {
+ require Perl::API;
+ };
+ if ($@) {
+ print "1..0 # skipped: Perl::API needed for this test\n";
+ print $@;
+ exit;
+ }
+}
+
+use strict;
+use Test qw(plan ok);
+use Perl::API qw(SvCUR SvCUR_set SvLEN);
+use MIME::Base64 qw(encode_base64 decode_base64);
+use MIME::QuotedPrint qw(encode_qp decode_qp);
+
+plan tests => 6;
+
+my $a = "abc";
+
+ok(SvCUR($a), 3);
+ok(SvLEN($a), 4);
+
+# Make sure that encode_base64 does not look beyond SvCUR().
+# This was fixed in v2.21. Valgrind would also show some
+# illegal reads on this.
+
+SvCUR_set($a, 1);
+ok(encode_base64($a), "YQ==\n");
+
+SvCUR_set($a, 4);
+ok(encode_base64($a), "YWJjAA==\n");
+
+ok(encode_qp($a), "abc=00");
+
+$a = "ab\n";
+
+SvCUR_set($a, 2);
+ok(encode_qp($a), "ab");
diff --git a/ext/MIME/Base64/t/base64.t b/ext/MIME/Base64/t/base64.t
index b398131981..d446ec25bf 100644
--- a/ext/MIME/Base64/t/base64.t
+++ b/ext/MIME/Base64/t/base64.t
@@ -336,18 +336,6 @@ sub encodeTest
print "not ";
}
- if (ord('A') != 193) { # perl versions broken on EBCDIC
- # Try the old Perl versions too
- if ($encoded ne MIME::Base64::old_encode_base64($plain, '')) {
- print "old_encode_base64 give different result.\n";
- print "not ";
- }
- if ($plain ne MIME::Base64::old_decode_base64($encoded)) {
- print "old_decode_base64 give different result.\n";
- print "not ";
- }
- }
-
print "ok $testno\n";
$testno++;
}
diff --git a/ext/MIME/Base64/t/warn.t b/ext/MIME/Base64/t/warn.t
new file mode 100644
index 0000000000..3a1e651d82
--- /dev/null
+++ b/ext/MIME/Base64/t/warn.t
@@ -0,0 +1,74 @@
+#!perl -w
+
+BEGIN {
+ if ($ENV{'PERL_CORE'}){
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ }
+}
+
+BEGIN {
+ eval {
+ require warnings;
+ };
+ if ($@) {
+ print "1..0\n";
+ print $@;
+ exit;
+ }
+}
+
+use strict;
+use MIME::Base64 qw(decode_base64);
+
+print "1..1\n";
+
+use warnings;
+
+my @warn;
+$SIG{__WARN__} = sub { push(@warn, @_) };
+
+warn;
+my $a;
+$a = decode_base64("aa");
+$a = decode_base64("a===");
+warn;
+$a = do {
+ no warnings;
+ decode_base64("aa");
+};
+$a = do {
+ no warnings;
+ decode_base64("a===");
+};
+warn;
+$a = do {
+ local $^W;
+ decode_base64("aa");
+};
+$a = do {
+ local $^W;
+ decode_base64("a===");
+};
+warn;
+
+if ($^O eq 'MSWin32') {
+ for (@warn) {
+ s|\\|/|g;
+ }
+}
+
+for (@warn) {
+ print "# $_";
+}
+
+print "not " unless join("", @warn) eq <<"EOT"; print "ok 1\n";
+Warning: something's wrong at $0 line 31.
+Premature end of base64 data at $0 line 33.
+Premature padding of base64 data at $0 line 34.
+Warning: something's wrong at $0 line 35.
+Premature end of base64 data at $0 line 38.
+Premature padding of base64 data at $0 line 42.
+Warning: something's wrong at $0 line 44.
+Warning: something's wrong at $0 line 53.
+EOT