@ -53,6 +53,9 @@ struct FunctionsTest: Corrade::TestSuite::Tester {
void ceil ( ) ;
void fmod ( ) ;
void binomialCoefficient ( ) ;
void binomialCoefficientOverflow ( ) ;
void sqrt ( ) ;
void sqrtInverted ( ) ;
void lerp ( ) ;
@ -115,6 +118,9 @@ FunctionsTest::FunctionsTest() {
& FunctionsTest : : ceil ,
& FunctionsTest : : fmod ,
& FunctionsTest : : binomialCoefficient ,
& FunctionsTest : : binomialCoefficientOverflow ,
& FunctionsTest : : sqrt ,
& FunctionsTest : : sqrtInverted ,
& FunctionsTest : : lerp ,
@ -293,6 +299,27 @@ void FunctionsTest::ceil() {
CORRADE_COMPARE ( Math : : ceil ( 2.7 _degf ) , 3.0 _degf ) ;
}
void FunctionsTest : : binomialCoefficient ( ) {
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1 , 1 ) , 1ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1 , 0 ) , 1ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 19 , 11 ) , 75582ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1000 , 999 ) , 1000ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 0 , 0 ) , 1ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 32 , 11 ) , 129024480ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 62 , 31 ) , 465428353255261088ul ) ;
}
void FunctionsTest : : binomialCoefficientOverflow ( ) {
# ifdef CORRADE_NO_ASSERT
CORRADE_SKIP ( " CORRADE_NO_ASSERT defined, can't test assertions " ) ;
# endif
std : : ostringstream out ;
Error redirectError { & out } ;
Math : : binomialCoefficient ( 63 , 31 ) ;
CORRADE_COMPARE ( out . str ( ) , " Math::binomialCoefficient(): overflow for (63 choose 31) \n " ) ;
}
void FunctionsTest : : fmod ( ) {
CORRADE_COMPARE ( Math : : fmod ( 5.1f , 3.0f ) , 2.1f ) ;
CORRADE_COMPARE ( Math : : fmod ( Vector3 ( 5.1f , - 5.1f , 6.8f ) , Vector3 ( 3.0f , 3.0f , 1.1f ) ) , Vector3 ( 2.1f , - 2.1f , 0.2f ) ) ;