Algorithm-Voting
view release on metacpan or search on metacpan
t/sortition/10-rfc3797.t view on Meta::CPAN
use strict;
use warnings;
use Data::Dumper;
use Test::More 'no_plan';
my $avs = 'Algorithm::Voting::Sortition';
use_ok($avs);
# verify that A::V::S generates the same keystring as in
# L<http://tools.ietf.org/html/rfc3797#section-6>
{
my @source = (
"9319",
[ qw/ 2 5 12 8 10 / ], # <= this one gets sorted
[ qw/ 9 18 26 34 41 45 /],
);
my $ks = q(9319./2.5.8.10.12./9.18.26.34.41.45./);
is ($avs->make_keystring(@source), $ks);
}
# verify that A::V::S generates checksums identical to
# L<http://tools.ietf.org/html/rfc3797#section-6>
{
my $ks = q(9319./2.5.8.10.12./9.18.26.34.41.45./);
my $box = Algorithm::Voting::Sortition->new(candidates => [], n => 10, keystring => $ks);
is($box->n, 10);
is($box->keystring, $ks);
# the first string is the digest of the keystring bracketed by the string
# "\x00\x00", the next "\x00\x01", and so on.
my @rfc_digests = split(/\n/,<<__digests__);
( run in 1.326 second using v1.01-cache-2.11-cpan-39bf76dae61 )