@@ -166,6 +166,34 @@ public static void Clamp_MinGreaterThanMax_ThrowsArgumentException()
166166#pragma warning restore IDE0004
167167 }
168168
169+ [ TestMethod ]
170+ public static void Cbrt ( )
171+ {
172+ double [ ] d = new double [ ] { - 3.1415926535897932 , - 2.7182818284590452 , - 2.3025850929940457 , - 1.5707963267948966 , - 1.0 , - 0.78539816339744831 , - 0.63661977236758134 , - 0.31830988618379067 , - 0.0 , double . NaN , 0.0 , 0.31830988618379067 , 0.63661977236758134 , 0.70710678118654752 , 1.0 , 1.1283791670955126 , 1.4426950408889634 , 2.3025850929940457 , 3.1415926535897932 , double . PositiveInfinity } ;
173+ double [ ] answer = new double [ ] { - 1.4645918875615233 , - 1.3956124250860895 , - 1.3205004784536852 , - 1.1624473515096265 , - 1.0 , - 0.92263507432201421 , - 0.86025401382809963 , - 0.68278406325529568 , - 0.0 , double . NaN , 0.0 , 0.68278406325529568 , 0.86025401382809963 , 0.89089871814033930 , 1.0 , 1.0410821966965807 , 1.1299472763373901 , 1.320500478453685 , 1.4645918875615233 , double . PositiveInfinity } ;
174+ double res ;
175+
176+ for ( int i = 0 ; i < d . Length ; i ++ )
177+ {
178+ res = Math . Cbrt ( d [ i ] ) ;
179+
180+ if ( double . IsNaN ( d [ i ] ) )
181+ {
182+ Assert . True ( double . IsNaN ( res ) , $ "Cbrt(...{ d [ i ] } ) -- FAILED AT: { res } ") ;
183+
184+ }
185+ else if ( double . IsPositiveInfinity ( d [ i ] ) )
186+ {
187+ Assert . True ( double . IsPositiveInfinity ( res ) , $ "Cbrt(...{ d [ i ] } ) -- FAILED AT: { res } ") ;
188+
189+ }
190+ else
191+ {
192+ Assert . False ( ( answer [ i ] - res ) > 0.0001d || ( answer [ i ] - res ) < - 0.0001d , $ "Cbrt(...{ d [ i ] } ) -- FAILED AT: { res } ") ;
193+ }
194+ }
195+ }
196+
169197 [ TestMethod ]
170198 public static void Test_Not_Numbers ( )
171199 {
@@ -472,7 +500,7 @@ public static void Test_IEEERemainder()
472500 }
473501
474502 res = Math . IEEERemainder ( 3 , 2 ) ; // x/y = 1.5, case of when x/y falls halfway between two integers
475- Assert . False ( ( res - 2 ) > 0.0001d , $ "IEEERemainder(...3,2) -- FAILED AT: { res } ") ;
503+ Assert . False ( ( res - 2 ) > 0.0001d , $ "IEEERemainder(...3,2) -- FAILED AT: { res } ") ;
476504
477505 res = Math . IEEERemainder ( 4 , 2 ) ; // x/y = 2, case when x - (y Q) is zero, the value +0 is returned if x is positive
478506 Assert . Equal ( res , 0 , $ "IEEERemainder(...4,2) -- FAILED AT: { res } ") ;
@@ -970,7 +998,7 @@ public static void Test_Tan()
970998 }
971999
9721000 // pi/2
973- res = Math . Tan ( 1.57079632679490000000 ) ;
1001+ res = Math . Tan ( 1.57079632679490000000 ) ;
9741002 Assert . False ( double . IsNaN ( res ) , $ "Tan(...PI/2) -- FAILED AT: { res } ") ;
9751003
9761004 res = Math . Tan ( double . NaN ) ;
0 commit comments