@@ -253,6 +253,7 @@ fn maximize_orders(warehouse: &Warehouse) -> Result<usize> {
253253mod tests {
254254 use super :: * ;
255255
256+ #[ inline]
256257 fn grid_to_string ( grid : & [ Vec < char > ] ) -> String {
257258 grid. iter ( )
258259 . map ( |row| row. iter ( ) . collect :: < String > ( ) )
@@ -275,7 +276,8 @@ mod tests {
275276 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
276277
277278 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
278- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 1 ) ;
279+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
280+ assert_eq ! ( result, 1 ) ;
279281 }
280282
281283 #[ test]
@@ -288,11 +290,12 @@ mod tests {
288290
289291 let grid_str = grid_to_string ( & grid) ;
290292 let orders = "2 2 0 0 5" ;
291- let robots = "1 1 1 10 " ;
293+ let robots = "1 1 1 4 " ;
292294 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
293295
294296 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
295- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 0 ) ;
297+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
298+ assert_eq ! ( result, 0 ) ;
296299 }
297300
298301 #[ test]
@@ -310,7 +313,8 @@ mod tests {
310313 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
311314
312315 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
313- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 1 ) ;
316+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
317+ assert_eq ! ( result, 1 ) ;
314318 }
315319
316320 #[ test]
@@ -328,7 +332,8 @@ mod tests {
328332 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
329333
330334 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
331- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 0 ) ;
335+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
336+ assert_eq ! ( result, 0 ) ;
332337 }
333338
334339 #[ test]
@@ -348,7 +353,8 @@ mod tests {
348353 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
349354
350355 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
351- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 1 ) ;
356+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
357+ assert_eq ! ( result, 1 ) ;
352358 }
353359
354360 #[ test]
@@ -368,7 +374,8 @@ mod tests {
368374 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
369375
370376 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
371- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 2 ) ;
377+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
378+ assert_eq ! ( result, 2 ) ;
372379 }
373380
374381 #[ test]
@@ -387,7 +394,8 @@ mod tests {
387394 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
388395
389396 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
390- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 0 ) ;
397+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
398+ assert_eq ! ( result, 0 ) ;
391399 }
392400
393401 #[ test]
@@ -407,7 +415,8 @@ mod tests {
407415
408416 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
409417 // Robot has enough battery to reach charging station but not complete order
410- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 0 ) ;
418+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
419+ assert_eq ! ( result, 0 ) ;
411420 }
412421
413422 #[ test]
@@ -427,7 +436,8 @@ mod tests {
427436
428437 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
429438 // Should prioritize the order with earlier deadline (5 vs 10)
430- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 1 ) ;
439+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
440+ assert_eq ! ( result, 1 ) ;
431441 }
432442
433443 #[ test]
@@ -441,7 +451,8 @@ mod tests {
441451 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
442452
443453 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
444- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 0 ) ;
454+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
455+ assert_eq ! ( result, 0 ) ;
445456 }
446457
447458 #[ test]
@@ -455,7 +466,8 @@ mod tests {
455466 let input = format ! ( "{grid_str}\n \n {orders}\n \n {robots}" ) ;
456467
457468 let warehouse = Warehouse :: new ( & input) . unwrap ( ) ;
458- assert_eq ! ( maximize_orders( & warehouse) . expect( "Should not fail" ) , 0 ) ;
469+ let result = maximize_orders ( & warehouse) . unwrap ( ) ;
470+ assert_eq ! ( result, 0 ) ;
459471 }
460472
461473 #[ test]
0 commit comments