Upgrade to MIME::Base64 3.00.
[p5sagit/p5-mst-13.2.git] / ext / MIME / Base64 / t / bad-sv.t
1 #!perl -w
2
3 BEGIN {
4     eval {
5         require Perl::API;
6     };
7     if ($@) {
8         print "1..0 # skipped: Perl::API needed for this test\n";
9         print $@;
10         exit;
11     }
12 }
13
14 use strict;
15 use Test qw(plan ok);
16 use Perl::API qw(SvCUR SvCUR_set SvLEN);
17 use MIME::Base64 qw(encode_base64 decode_base64);
18 use MIME::QuotedPrint qw(encode_qp decode_qp);
19
20 plan tests => 6;
21
22 my $a = "abc";
23
24 ok(SvCUR($a), 3);
25 ok(SvLEN($a), 4);
26
27 # Make sure that encode_base64 does not look beyond SvCUR().
28 # This was fixed in v2.21.  Valgrind would also show some
29 # illegal reads on this.
30
31 SvCUR_set($a, 1);
32 ok(encode_base64($a), "YQ==\n");
33
34 SvCUR_set($a, 4);
35 ok(encode_base64($a), "YWJjAA==\n");
36
37 ok(encode_qp($a), "abc=00");
38
39 $a = "ab\n";
40
41 SvCUR_set($a, 2);
42 ok(encode_qp($a), "ab");