Bug 41959: Unit tests

This adds a test for the condition where there are 2 holds, 1 item, and the item cannot fulfill the first hold

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This commit is contained in:
Nick Clemens 2026-03-05 20:32:46 +00:00 committed by Martin Renvoize
parent 97d980a7ba
commit 890ce7cc49
No known key found for this signature in database
GPG Key ID: 2D86E0EAEC83711B
1 changed files with 20 additions and 2 deletions

View File

@ -9,7 +9,7 @@
use Modern::Perl;
use Test::More tests => 120;
use Test::More tests => 123;
use Test::NoWarnings;
use Test::Warn;
use Data::Dumper;
@ -193,7 +193,10 @@ sub test_allocation {
if ($expected_allocation) {
my @indices = allocation_indices( $libraries, $holds_queue );
is( scalar(@indices), scalar(@$expected_allocation), "$label correct number of allocations" );
is(
scalar(@indices), scalar(@$expected_allocation),
"$label correct number of allocations (" . scalar @$expected_allocation . ")"
);
# print STDERR Dumper(\@indices);
@ -349,6 +352,21 @@ test_allocation(
2
);
test_allocation(
"more holds than items and items cannot fill all holds",
[
[ 0, 1, 1, -1, 1 ],
[ -1, 0, -1, -1, 1 ],
[ -1, -1, 0, -1, -1 ],
[ -1, -1, -1, 0, -1 ],
[ -1, -1, -1, -1, 0 ]
],
[ 1, 0, 0, 0, 0 ],
[ 0, 0, 0, 1, 1 ],
[ [ 0, 4 ] ],
1
);
test_allocation(
"large volume",
[