File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,7 +164,12 @@ mod tests {
164164 arbtest:: arbtest ( |u| {
165165 let r = float_in_unit_interval ( u) ?;
166166 let p: Poly < 6 > = poly_with_planted_root ( u, r, 1e-6 ) ?;
167- assert ! ( p. eval( r) . abs( ) <= 1e-12 * p. max_abs_coefficient( ) . max( 1.0 ) ) ;
167+ let threshold = 1e-12 * p. max_abs_coefficient ( ) . max ( 1.0 ) ;
168+ let y = p. eval ( r) ;
169+ assert ! (
170+ y. abs( ) <= threshold,
171+ "poly {p:?} had planted root {r} evaluate to {y:?}, but expected |y| <= {threshold:?}"
172+ ) ;
168173 Ok ( ( ) )
169174 } ) ;
170175 }
Original file line number Diff line number Diff line change @@ -452,16 +452,28 @@ mod tests {
452452 }
453453 let roots = poly. roots_between ( -2.0 , 2.0 , 1e-13 ) ;
454454
455- assert ! ( roots. iter( ) . all( |r| r. is_finite( ) ) ) ;
455+ assert ! (
456+ roots. iter( ) . all( |r| r. is_finite( ) ) ,
457+ "found non-finite roots: {roots:?}"
458+ ) ;
456459
457460 // Check that the roots are sorted.
458- assert ! ( roots. is_sorted( ) ) ;
459- assert ! ( roots. iter( ) . all( |r| ( -2.0 ..=2.0 ) . contains( r) ) ) ;
461+ assert ! (
462+ roots. is_sorted( ) ,
463+ "roots are not sorted: {roots:?}"
464+ ) ;
465+ assert ! (
466+ roots. iter( ) . all( |r| ( -2.0 ..=2.0 ) . contains( r) ) ,
467+ "found roots out of range [-2.0, 2.0]: {roots:?}"
468+ ) ;
460469
461470 // We can't expect great accuracy for huge coefficients, because the
462471 // evaluations during Newton iteration are subject to error.
463472 let error = poly. max_abs_coefficient ( ) . max ( 1.0 ) * 1e-12 ;
464- assert ! ( roots. iter( ) . any( |r| ( r - planted_root) . abs( ) <= error) ) ;
473+ assert ! (
474+ roots. iter( ) . any( |r| ( r - planted_root) . abs( ) <= error) ,
475+ "could not find something close to planted_root {planted_root} in found {roots:?} with allowed error {error} for poly {poly:?}"
476+ ) ;
465477 Ok ( ( ) )
466478 } )
467479 . budget_ms ( 5_000 ) ;
Original file line number Diff line number Diff line change @@ -125,7 +125,10 @@ mod tests {
125125 let r_magnitude = r. abs ( ) . max ( 1.0 ) ;
126126 let threshold = r_magnitude * 1e-14 * r_magnitude * magnitude;
127127 if y. is_finite ( ) && threshold. is_finite ( ) {
128- assert ! ( y. abs( ) <= threshold) ;
128+ assert ! (
129+ y. abs( ) <= threshold,
130+ "quadratic {q:?} had root {r} evaluate to {y:?}, but expected |y| <= {threshold:?}"
131+ ) ;
129132 }
130133 }
131134 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments