]>
Commit | Line | Data |
---|---|---|
1a1c8cd6 MG |
1 | #!/usr/bin/perl |
2 | use strict; | |
3 | use warnings; | |
4 | ||
0ca5f559 | 5 | use Test::More tests => 9; |
1a1c8cd6 MG |
6 | BEGIN { use_ok('Convert::Base91', qw/encode_base91 decode_base91/) }; |
7 | ||
8 | is encode_base91("Hello, World!\n"), '>OwJh>}AQ;r@@Y?FF', 'encode'; | |
9 | is decode_base91('>OwJh>}AQ;r@@Y?FF'), "Hello, World!\n", 'decode'; | |
10 | ||
11 | my $str = 'abc_def'; | |
12 | is decode_base91(encode_base91($str)), $str, 'roundtrip'; | |
13 | ||
14 | my $base91 = Convert::Base91->new; | |
15 | $base91->encode('Hello, '); | |
16 | $base91->encode('World!'); | |
17 | $base91->encode("\n"); | |
18 | my $encoded = $base91->encode_end; | |
19 | is $encoded, '>OwJh>}AQ;r@@Y?FF', 'OO encode'; | |
20 | ||
21 | $base91->decode('>OwJh>}AQ'); | |
22 | $base91->decode(';r@@Y?FF'); | |
23 | my $decoded = $base91->decode_end; | |
24 | is $decoded, "Hello, World!\n", 'OO decode'; | |
0ca5f559 MG |
25 | |
26 | is $base91->decode_end, '', 'double decode_end'; | |
27 | is $base91->encode_end, '', 'encode_end without data'; | |
28 | ||
29 | is decode_base91(">\x00OwJh\x01>}A\xFE\xDDQ;r@\@Y?FF\x05"), "Hello, World!\n", 'decode with junk'; |