From 5e24c7b89a7f4ad914dcf338e9ea71c8f1b289bb Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 5 Mar 2026 20:32:46 +0000 Subject: [PATCH] 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 --- .../HoldsQueue/TransportCostOptimizations.t | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/HoldsQueue/TransportCostOptimizations.t b/t/db_dependent/HoldsQueue/TransportCostOptimizations.t index 21e3b923f86..ab936fff1b5 100755 --- a/t/db_dependent/HoldsQueue/TransportCostOptimizations.t +++ b/t/db_dependent/HoldsQueue/TransportCostOptimizations.t @@ -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", [ -- 2.39.5