1+ using FluentAssertions ;
2+ using Xunit ;
3+
4+ namespace Light . GuardClauses . Tests . CommonAssertions ;
5+
6+ public static class IsGreaterThanOrApproximatelyTests
7+ {
8+ [ Theory ]
9+ [ InlineData ( 17.4 , 17.3 , true ) ]
10+ [ InlineData ( 19.9999999 , 20.0 , true ) ]
11+ [ InlineData ( - 5.49998 , - 5.5 , true ) ]
12+ [ InlineData ( - 5.4998 , - 5.4996 , false ) ]
13+ public static void DoubleWithDefaultTolerance ( double first , double second , bool expected ) =>
14+ first . IsGreaterThanOrApproximately ( second ) . Should ( ) . Be ( expected ) ;
15+
16+ [ Theory ]
17+ [ InlineData ( 15.91 , 15.9 , 0.1 , true ) ]
18+ [ InlineData ( 24.449 , 24.45 , 0.0001 , false ) ]
19+ [ InlineData ( - 3.12 , - 3.2 , 0.001 , true ) ]
20+ [ InlineData ( 2.369 , 2.37 , 0.0005 , false ) ]
21+ public static void DoubleWithCustomTolerance ( double first , double second , double tolerance , bool expected ) =>
22+ first . IsGreaterThanOrApproximately ( second , tolerance ) . Should ( ) . Be ( expected ) ;
23+
24+ [ Theory ]
25+ [ InlineData ( 100.225f , 100.2f , true ) ]
26+ [ InlineData ( - 5.9f , - 5.5f , false ) ]
27+ [ InlineData ( 0f , - 0.02f , true ) ]
28+ [ InlineData ( - 0.001f , 0f , false ) ]
29+ public static void FloatWithDefaultTolerance ( float first , float second , bool expected ) =>
30+ first . IsGreaterThanOrApproximately ( second ) . Should ( ) . Be ( expected ) ;
31+
32+ [ Theory ]
33+ [ InlineData ( 2.0f , 1.0f , 0.1f , true ) ]
34+ [ InlineData ( 1.0f , 1.0f , 0.1f , true ) ]
35+ [ InlineData ( 1.0f , 1.1f , 0.01f , false ) ]
36+ [ InlineData ( 1.0f , 2.0f , 0.1f , false ) ]
37+ public static void FloatWIthCustomTolerance ( float first , float second , float tolerance , bool expected ) =>
38+ first . IsGreaterThanOrApproximately ( second , tolerance ) . Should ( ) . Be ( expected ) ;
39+ }
0 commit comments