@@ -148,20 +148,20 @@ public static void Clamp_Float()
148148 [ TestMethod ]
149149 public static void Clamp_MinGreaterThanMax_ThrowsArgumentException ( )
150150 {
151- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( sbyte ) 1 , ( sbyte ) 2 , ( sbyte ) 1 ) ) ;
152- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( byte ) 1 , ( byte ) 2 , ( byte ) 1 ) ) ;
153- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( short ) 1 , ( short ) 2 , ( short ) 1 ) ) ;
154- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( ushort ) 1 , ( ushort ) 2 , ( ushort ) 1 ) ) ;
151+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( sbyte ) 1 , ( sbyte ) 2 , ( sbyte ) 1 ) ) ;
152+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( byte ) 1 , ( byte ) 2 , ( byte ) 1 ) ) ;
153+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( short ) 1 , ( short ) 2 , ( short ) 1 ) ) ;
154+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( ushort ) 1 , ( ushort ) 2 , ( ushort ) 1 ) ) ;
155155
156156 // keeping cast on purpose to be able to test the method
157157#pragma warning disable IDE0004
158158#pragma warning disable S1905
159- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( int ) 1 , ( int ) 2 , ( int ) 1 ) ) ;
160- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( uint ) 1 , ( uint ) 2 , ( uint ) 1 ) ) ;
161- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( long ) 1 , ( long ) 2 , ( long ) 1 ) ) ;
162- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( ulong ) 1 , ( ulong ) 2 , ( ulong ) 1 ) ) ;
163- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( float ) 1 , ( float ) 2 , ( float ) 1 ) ) ;
164- Assert . Throws ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( double ) 1 , ( double ) 2 , ( double ) 1 ) ) ;
159+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( int ) 1 , ( int ) 2 , ( int ) 1 ) ) ;
160+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( uint ) 1 , ( uint ) 2 , ( uint ) 1 ) ) ;
161+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( long ) 1 , ( long ) 2 , ( long ) 1 ) ) ;
162+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( ulong ) 1 , ( ulong ) 2 , ( ulong ) 1 ) ) ;
163+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( float ) 1 , ( float ) 2 , ( float ) 1 ) ) ;
164+ Assert . ThrowsException ( typeof ( ArgumentException ) , ( ) => Math . Clamp ( ( double ) 1 , ( double ) 2 , ( double ) 1 ) ) ;
165165#pragma warning restore S1905
166166#pragma warning restore IDE0004
167167 }
@@ -201,22 +201,23 @@ public static void Test_Not_Numbers()
201201 double pos_inf = ( 3.0 / 0.0 ) ;
202202 double neg_inf = ( - 3.0 / 0.0 ) ;
203203
204+ Console . WriteLine ( $ "Expect nan={ nan } , pos_inf={ pos_inf } , neg_inf={ neg_inf } ") ;
204205
205206 Assert . IsTrue ( double . IsNaN ( nan ) , "NaN was not correctly identified" ) ;
206207 Assert . IsFalse ( double . IsPositiveInfinity ( nan ) , "NaN was incorrectly identified as Positive Infinity" ) ;
207208 Assert . IsFalse ( double . IsNegativeInfinity ( nan ) , "NaN was incorrectly identified as Negative Infinity" ) ;
208209
209210 //--//
210211
212+ Assert . IsFalse ( double . IsNaN ( pos_inf ) , "Positive Infinity was incorrectly identified as double.NaN" ) ;
211213 Assert . IsTrue ( double . IsPositiveInfinity ( pos_inf ) , "Positive Infinity was not correctly identified" ) ;
212- Assert . IsFalse ( double . IsNaN ( pos_inf ) , "Positive Infinity was incorrectly identified asdouble.NaN" ) ;
213214 Assert . IsFalse ( double . IsNegativeInfinity ( pos_inf ) , "Positive Infinity was incorrectly identified as Negative Infinity" ) ;
214215
215216 //--//
216217
217- Assert . IsTrue ( double . IsNegativeInfinity ( neg_inf ) , "NegativeInfinity was not correctly identified" ) ;
218+ Assert . IsFalse ( double . IsNaN ( neg_inf ) , "NegativeInfinity Infinity was incorrectly identified as double.NaN " ) ;
218219 Assert . IsFalse ( double . IsPositiveInfinity ( neg_inf ) , "NegativeInfinity Infinity was incorrectly identified as Positive Infinity" ) ;
219- Assert . IsFalse ( double . IsNaN ( neg_inf ) , "NegativeInfinity Infinity was incorrectly identified asdouble.NaN " ) ;
220+ Assert . IsTrue ( double . IsNegativeInfinity ( neg_inf ) , "NegativeInfinity was not correctly identified " ) ;
220221 }
221222
222223 [ TestMethod ]
@@ -665,86 +666,6 @@ public static void Test_Log10()
665666 Assert . IsTrue ( double . IsNaN ( res ) , $ "Log10(...NegativeInfinity) -- FAILED AT: { res } ") ;
666667 }
667668
668- [ TestMethod ]
669- public static void Test_Max_2 ( )
670- {
671- //
672- // Summary:
673- // Returns the larger of two double-precision floating-point numbers.
674- //
675- // Parameters:
676- // val1:
677- // The first of two double-precision floating-point numbers to compare.
678- //
679- // val2:
680- // The second of two double-precision floating-point numbers to compare.
681- //
682- // Returns:
683- // Parameter val1 or val2, whichever is larger. If val1 OR both val1
684- // and val2 are equal to System.Double.NaN, System.Double.NaN is returned.
685- double [ ] x = new double [ ] { 6.00000000000000000000 , 6.50000000000000000000 , 7.00000000000000000000 , 7.50000000000000000000 , - 0.50000000000000000000 , - 1.00000000000000000000 , - 1.50000000000000000000 , - 2.00000000000000000000 } ;
686- double [ ] y = new double [ ] { 1 , 1.140238321 , 1.600286858 , 2.509178479 , 4.121836054 , 6.890572365 , 11.59195328 , - 0.50000000000000000000 } ;
687-
688- double [ ] answer = new double [ ] { 6.00000000000000000000 , 6.50000000000000000000 , 7.00000000000000000000 , 7.50000000000000000000 , 4.12183605386995000000 , 6.89057236497588000000 , 11.59195328 , - 0.50000000000000000000 } ;
689- double res ;
690-
691- for ( int i = 0 ; i < x . Length ; i ++ )
692- {
693- res = Math . Max ( x [ i ] , y [ i ] ) ;
694-
695- Assert . IsFalse ( ( answer [ i ] - res ) > 0.0001d || ( answer [ i ] - res ) < - 0.0001d , $ "Max(...{ x [ i ] } , { y [ i ] } ) -- FAILED AT: { res } ") ;
696- }
697-
698- res = Math . Max ( 10 , double . NaN ) ;
699- Assert . IsTrue ( double . IsNaN ( res ) , $ "Max(...10,double.NaN) -- FAILED AT: { res } ") ;
700-
701- res = Math . Max ( double . NaN , 10 ) ;
702- Assert . IsTrue ( double . IsNaN ( res ) , $ "Max(...NaN, 10) -- FAILED AT: { res } ") ;
703-
704- res = Math . Max ( double . NaN , double . NaN ) ;
705- Assert . IsTrue ( double . IsNaN ( res ) , $ "Max(...NaN,double.NaN) -- FAILED AT: { res } ") ;
706- }
707-
708- [ TestMethod ]
709- public static void Test_Min_2 ( )
710- {
711- //
712- // Summary:
713- // Returns the smaller of two double-precision floating-point numbers.
714- //
715- // Parameters:
716- // val1:
717- // The first of two double-precision floating-point numbers to compare.
718- //
719- // val2:
720- // The second of two double-precision floating-point numbers to compare.
721- //
722- // Returns:
723- // Parameter val1 or val2, whichever is smaller. If val1, val2, or both val1
724- // and val2 are equal to System.Double.NaN, System.Double.NaN is returned.
725- double [ ] x = new double [ ] { 6.00000000000000000000 , 6.50000000000000000000 , 7.00000000000000000000 , 7.50000000000000000000 , - 0.50000000000000000000 , - 1.00000000000000000000 , - 1.50000000000000000000 , - 2.00000000000000000000 } ;
726- double [ ] y = new double [ ] { 1 , 1.140238321 , 1.600286858 , 2.509178479 , 4.121836054 , 6.890572365 , 11.59195328 , - 0.50000000000000000000 } ;
727-
728- double [ ] answer = new double [ ] { 1 , 1.140238321 , 1.600286858 , 2.509178479 , - 0.50000000000000000000 , - 1.00000000000000000000 , - 1.50000000000000000000 , - 2.00000000000000000000 } ;
729- double res ;
730-
731- for ( int i = 0 ; i < x . Length ; i ++ )
732- {
733- res = Math . Min ( x [ i ] , y [ i ] ) ;
734-
735- Assert . IsFalse ( ( answer [ i ] - res ) > 0.0001d || ( answer [ i ] - res ) < - 0.0001d , $ "Min(...{ x [ i ] } , { y [ i ] } ) -- FAILED AT: { res } ") ;
736- }
737-
738- res = Math . Min ( 10 , double . NaN ) ;
739- Assert . IsTrue ( double . IsNaN ( res ) , $ "Min(...10,double.NaN) -- FAILED AT: { res } ") ;
740-
741- res = Math . Min ( double . NaN , 10 ) ;
742- Assert . AreEqual ( res , 10 , $ "Min(...NaN, 10) -- FAILED AT: { res } ") ;
743-
744- res = Math . Min ( double . NaN , double . NaN ) ;
745- Assert . IsTrue ( double . IsNaN ( res ) , $ "Min(...NaN,double.NaN) -- FAILED AT: { res } ") ;
746- }
747-
748669 [ TestMethod ]
749670 public static void Test_Pow_2 ( )
750671 {
0 commit comments