Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (28 sloc) 1.17 KB
use v6;
use Test;
use Enc::MIME::Base64;
plan 8;
# from Perl 5 Mime::Base64 base64.t
# I don't think it makes sense any more to test encoding each individual byte
# value but may make sense to do a few end cases
is encode_base64(, 'AA==', 'encode Test on NULL/0 byte';
is encode_base64(, 'AQ==', 'encode Test on byte value 1';
is encode_base64(, '/w==', 'encode Test on byte value 255';
ok decode_base64('AA==') eq, 'decode Test on NULL/0 byte';
ok decode_base64('AQ==') eq, 'decode Test on byte value 1';
ok decode_base64('/w==') eq, 'decode Test on byte value 255';
my Buf $camelia_ico = slurp(
$? ~ '/data/camelia-favicon.ico', :bin
# .b64 file generated from .ico file with gnu base64 program
my Str $camelia_b64 = slurp(
$? ~ '/data/camelia-favicon.b64'
is encode_base64($camelia_ico), $camelia_b64.chomp, 'binary img encode test';
ok decode_base64($camelia_b64) eq $camelia_ico, 'binary img decode test';
my $x = decode_base64($camelia_b64);
say $x.bytes;
say $camelia_ico.bytes;
loop (my $i = 0; $i < $x.bytes; $i++) {
if $x[$i] != $camelia_ico[$i] { say $i }
Jump to Line
Something went wrong with that request. Please try again.