X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=t%2FAlgorithm-BIT-XS.t;h=914792a9c0780c375a27e3c05be2cabd36b43255;hb=02b65a500f8dd89caf2b13ae066dbb4b7e1b5e3c;hp=c2ee47a3cee96a3c35df85d77af74a37722d69ae;hpb=2b47d13cc3268a21ebe79ead99ad55dd902d6003;p=algorithm-bit-xs.git diff --git a/t/Algorithm-BIT-XS.t b/t/Algorithm-BIT-XS.t index c2ee47a..914792a 100644 --- a/t/Algorithm-BIT-XS.t +++ b/t/Algorithm-BIT-XS.t @@ -2,11 +2,13 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 24; BEGIN { use_ok('Algorithm::BIT::XS') }; BEGIN { use_ok('Algorithm::BIT2D::XS') }; -my $bit = Algorithm::BIT::XS->new(100); +my $bit = Algorithm::BIT::XS->new(25); +ok !eval{$bit->query(26); 1}, 'query(26) fails'; +ok !eval{$bit->update(26, 5); 1}, 'update(26, 5) fails'; is $bit->query(5), 0; $bit->update(4, 2); $bit->update(5, 3); @@ -14,6 +16,7 @@ is $bit->query(3), 0; is $bit->query(4), 2; is $bit->query(5), 5; is $bit->query(6), 5; +is $bit->query(0), 0; $bit->update(5, -3); is $bit->query(5), 2; @@ -32,7 +35,11 @@ is $bit->query(15), 0; is $bit->query(16), 10; -my $bit2d = Algorithm::BIT2D::XS->new(100, 50); +my $bit2d = Algorithm::BIT2D::XS->new(10, 5); +ok !eval{$bit2d->query(11, 5); 1}, 'query(11, 5) fails'; +ok !eval{$bit2d->query(10, 6); 1}, 'query(10, 6) fails'; +ok !eval{$bit2d->update(11, 5, 2); 1}, 'update(11, 5, 2) fails'; +ok !eval{$bit2d->update(10, 6, 2); 1}, 'update(10, 6, 2) fails'; is $bit2d->query(5, 5), 0; $bit2d->update(4, 4, 2); $bit2d->update(5, 1, 3);