Skip to content

Commit

Permalink
Convert all tests to use Test::More rather than Test.pm
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg authored and mbeijen committed Jan 9, 2025
1 parent 254d239 commit 0660002
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 50 deletions.
2 changes: 0 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ my %WriteMakefileArgs = (
"TEST_REQUIRES" => {
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"Test" => 0,
"Test::More" => 0,
"strict" => 0,
"warnings" => 0
Expand All @@ -40,7 +39,6 @@ my %FallbackPrereqs = (
"Exporter" => 0,
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"Test" => 0,
"Test::More" => 0,
"XSLoader" => 0,
"strict" => 0,
Expand Down
1 change: 0 additions & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on 'configure' => sub {
on 'test' => sub {
requires 'strict';
requires 'warnings';
requires 'Test';
requires 'Test::More';
};

Expand Down
1 change: 0 additions & 1 deletion t/00-report-prereqs.dd
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ do { my $x = {
'requires' => {
'ExtUtils::MakeMaker' => '0',
'File::Spec' => '0',
'Test' => '0',
'Test::More' => '0',
'perl' => '5.006',
'strict' => '0',
Expand Down
17 changes: 9 additions & 8 deletions t/base64url.t
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!perl -w

use strict;
use warnings;
use Test qw(plan ok skip);
use Test::More;

use MIME::Base64 qw(encode_base64url decode_base64url);

if (ord("A") != 65) {
plan skip_all => "ASCII-centric test";
}

my @tests;

while (<DATA>) {
Expand All @@ -14,15 +16,14 @@ while (<DATA>) {
push(@tests, [split]);
}

plan tests => 2 * @tests;

for (@tests) {
my($name, $input, $output) = @$_;
print "# $name\n";
skip(ord("A") != 65 ? "ASCII-centric test" : 0, decode_base64url($input), $output);
skip(ord("A") != 65 ? "ASCII-centric test" : 0, encode_base64url($output), $input);
ok(decode_base64url($input), $output);
ok(encode_base64url($output), $input);
}

done_testing;

__END__
# https://github.com/ptarjan/base64url/blob/master/tests.txt
# Name <space> Input <space> Ouput <newline>
Expand Down
70 changes: 34 additions & 36 deletions t/length.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,47 @@

use strict;
use warnings;
use Test qw(plan ok);

plan tests => 129;
use Test::More tests => 129;

use MIME::Base64 qw(encode_base64 encoded_base64_length decoded_base64_length);
*elen = *encoded_base64_length;
*dlen = *decoded_base64_length;

ok(elen(""), 0);
ok(elen("a"), 5);
ok(elen("aa"), 5);
ok(elen("aaa"), 5);
ok(elen("aaaa"), 9);
ok(elen("aaaaa"), 9);

ok(elen("", ""), 0);
ok(elen("a", ""), 4);
ok(elen("aa", ""), 4);
ok(elen("aaa", ""), 4);
ok(elen("aaaa", ""), 8);
ok(elen("aaaaa", ""), 8);

ok(dlen(""), 0);
ok(dlen("a"), 0);
ok(dlen("aa"), 1);
ok(dlen("aaa"), 2);
ok(dlen("aaaa"), 3);
ok(dlen("aaaaa"), 3);
ok(dlen("aaaaaa"), 4);
ok(dlen("aaaaaaa"), 5);
ok(dlen("aaaaaaaa"), 6);

ok(dlen("=aaaa"), 0);
ok(dlen("a=aaa"), 0);
ok(dlen("aa=aa"), 1);
ok(dlen("aaa=a"), 2);
ok(dlen("aaaa="), 3);

ok(dlen("a\na\na a"), 3);
is(elen(""), 0);
is(elen("a"), 5);
is(elen("aa"), 5);
is(elen("aaa"), 5);
is(elen("aaaa"), 9);
is(elen("aaaaa"), 9);

is(elen("", ""), 0);
is(elen("a", ""), 4);
is(elen("aa", ""), 4);
is(elen("aaa", ""), 4);
is(elen("aaaa", ""), 8);
is(elen("aaaaa", ""), 8);

is(dlen(""), 0);
is(dlen("a"), 0);
is(dlen("aa"), 1);
is(dlen("aaa"), 2);
is(dlen("aaaa"), 3);
is(dlen("aaaaa"), 3);
is(dlen("aaaaaa"), 4);
is(dlen("aaaaaaa"), 5);
is(dlen("aaaaaaaa"), 6);

is(dlen("=aaaa"), 0);
is(dlen("a=aaa"), 0);
is(dlen("aa=aa"), 1);
is(dlen("aaa=a"), 2);
is(dlen("aaaa="), 3);

is(dlen("a\na\na a"), 3);

for my $i (50..100) {
my $a = "a" x $i;
my $a_enc = encode_base64($a);
ok(elen($a), length($a_enc));
ok(dlen($a_enc), $i);
is(elen($a), length($a_enc));
is(dlen($a_enc), $i);
}
3 changes: 1 addition & 2 deletions t/unicode.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use strict;
use warnings;

use Test;
plan tests => 11;
use Test::More tests => 11;

require MIME::Base64;
require MIME::QuotedPrint;
Expand Down

0 comments on commit 0660002

Please sign in to comment.