package TestCase::Lib::SPVM::MIME::Base64 {
  use SPVM::MIME::Base64;

  private sub round_trip : string ($string : string) {
    my $encoder = SPVM::MIME::Base64->new;
    return $encoder->decode($encoder->encode($string));
  }

  sub test_basic : int () {
    unless (round_trip("example") eq "example") {
      return 0;
    }
    return 1;
  }

  sub test_all : int () {
    my $encoder = SPVM::MIME::Base64->new;
    for (my $case_index = 0; $case_index < 300; $case_index++) {
      my $bytes = new byte[$case_index];
      for (my $c = 0; $c < $case_index; $c++) {
        $bytes->[$c] = (byte)($c % 127 + 1);
      }
      my $test = (string)$bytes;
      unless (round_trip($test) eq $test) {
        return 0;
      }
    }
    return 1;
  }
}
