"Fossies" - the Fresh Open Source Software Archive

Member "MIME-Base64-3.16/t/length.t" (27 Sep 2020, 954 Bytes) of package /linux/privat/MIME-Base64-3.16.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "length.t": 3.15_vs_3.16.

    1 #!perl -w
    2 
    3 use strict;
    4 use warnings;
    5 use Test qw(plan ok);
    6 
    7 plan tests => 129;
    8 
    9 use MIME::Base64 qw(encode_base64 encoded_base64_length decoded_base64_length);
   10 *elen = *encoded_base64_length;
   11 *dlen = *decoded_base64_length;
   12 
   13 ok(elen(""), 0);
   14 ok(elen("a"), 5);
   15 ok(elen("aa"), 5);
   16 ok(elen("aaa"), 5);
   17 ok(elen("aaaa"), 9);
   18 ok(elen("aaaaa"), 9);
   19 
   20 ok(elen("", ""), 0);
   21 ok(elen("a", ""), 4);
   22 ok(elen("aa", ""), 4);
   23 ok(elen("aaa", ""), 4);
   24 ok(elen("aaaa", ""), 8);
   25 ok(elen("aaaaa", ""), 8);
   26 
   27 ok(dlen(""), 0);
   28 ok(dlen("a"), 0);
   29 ok(dlen("aa"), 1);
   30 ok(dlen("aaa"), 2);
   31 ok(dlen("aaaa"), 3);
   32 ok(dlen("aaaaa"), 3);
   33 ok(dlen("aaaaaa"), 4);
   34 ok(dlen("aaaaaaa"), 5);
   35 ok(dlen("aaaaaaaa"), 6);
   36 
   37 ok(dlen("=aaaa"), 0);
   38 ok(dlen("a=aaa"), 0);
   39 ok(dlen("aa=aa"), 1);
   40 ok(dlen("aaa=a"), 2);
   41 ok(dlen("aaaa="), 3);
   42 
   43 ok(dlen("a\na\na a"), 3);
   44 
   45 for my $i (50..100) {
   46     my $a = "a" x $i;
   47     my $a_enc = encode_base64($a);
   48     ok(elen($a), length($a_enc));
   49     ok(dlen($a_enc), $i);
   50 }