@@ -495,9 +495,9 @@ protected bool CheckEqualityFromPathsCore(string relPath, string basePath, strin
495
495
}
496
496
497
497
count ++ ;
498
- GetNumbersFromFile ( ref line1 , ref line2 , digitsOfPrecision ) ;
498
+ var inRange = GetNumbersFromFile ( ref line1 , ref line2 , digitsOfPrecision ) ;
499
499
500
- if ( line1 != line2 )
500
+ if ( ! inRange || line1 != line2 )
501
501
{
502
502
if ( line1 == null || line2 == null )
503
503
Fail ( "Output and baseline different lengths: '{0}'" , relPath ) ;
@@ -509,19 +509,26 @@ protected bool CheckEqualityFromPathsCore(string relPath, string basePath, strin
509
509
}
510
510
}
511
511
512
- private void GetNumbersFromFile ( ref string firstString , ref string secondString , int digitsOfPrecision )
512
+ private bool GetNumbersFromFile ( ref string firstString , ref string secondString , int digitsOfPrecision )
513
513
{
514
-
514
+
515
515
MatchCollection firstCollection = MatchNumbers . Matches ( firstString ) ;
516
516
MatchCollection secondCollection = MatchNumbers . Matches ( secondString ) ;
517
517
518
518
if ( firstCollection . Count == secondCollection . Count )
519
- MatchNumberWithTolerance ( firstCollection , secondCollection , digitsOfPrecision ) ;
519
+ {
520
+ if ( ! MatchNumberWithTolerance ( firstCollection , secondCollection , digitsOfPrecision ) )
521
+ {
522
+ return false ;
523
+ }
524
+ }
525
+
520
526
firstString = MatchNumbers . Replace ( firstString , "%Number%" ) ;
521
527
secondString = MatchNumbers . Replace ( secondString , "%Number%" ) ;
528
+ return true ;
522
529
}
523
530
524
- private void MatchNumberWithTolerance ( MatchCollection firstCollection , MatchCollection secondCollection , int digitsOfPrecision )
531
+ private bool MatchNumberWithTolerance ( MatchCollection firstCollection , MatchCollection secondCollection , int digitsOfPrecision )
525
532
{
526
533
for ( int i = 0 ; i < firstCollection . Count ; i ++ )
527
534
{
@@ -547,9 +554,16 @@ private void MatchNumberWithTolerance(MatchCollection firstCollection, MatchColl
547
554
if ( ! inRange )
548
555
{
549
556
delta = Math . Round ( f1 - f2 , digitsOfPrecision ) ;
550
- Assert . InRange ( delta , - allowedVariance , allowedVariance ) ;
557
+ inRange = delta >= - allowedVariance && delta <= allowedVariance ;
558
+ }
559
+
560
+ if ( ! inRange )
561
+ {
562
+ return false ;
551
563
}
552
564
}
565
+
566
+ return true ;
553
567
}
554
568
555
569
private static double Round ( double value , int digitsOfPrecision )
0 commit comments