use strict;
use warnings;
use Test::More;
use File::Raw::Base64;
use File::Raw qw(import);
use File::Temp qw(tempfile);

# Empty input round-trips to empty output (both directions)
{
    my ($fh, $p) = tempfile(UNLINK => 1); close $fh;
    file_spew($p, '', plugin => 'base64');
    my $enc = do { local (@ARGV, $/) = $p; <> };
    $enc = '' unless defined $enc;
    is($enc, '', 'encode empty -> empty');

    my $b = file_slurp($p, plugin => 'base64');
    is($b, '', 'decode empty -> empty');
}

# 5 MB blob round-trip (perf sanity + larger-than-default-buffer growth)
{
    srand(123);
    my $payload = pack 'C*', map { int rand 256 } 1 .. (5 * 1024 * 1024);
    is(length($payload), 5 * 1024 * 1024, '5 MiB random blob built');

    my ($fh, $p) = tempfile(UNLINK => 1); close $fh;
    file_spew($p, $payload, plugin => 'base64');
    my $back = file_slurp($p, plugin => 'base64');
    ok($back eq $payload, '5 MiB round-trip preserves all bytes');
}

done_testing;
