@ -54,6 +54,7 @@ struct FunctionsTest: Corrade::TestSuite::Tester {
void fmod ( ) ;
void fmod ( ) ;
void binomialCoefficient ( ) ;
void binomialCoefficient ( ) ;
void binomialCoefficientOverflow ( ) ;
void sqrt ( ) ;
void sqrt ( ) ;
void sqrtInverted ( ) ;
void sqrtInverted ( ) ;
@ -118,6 +119,7 @@ FunctionsTest::FunctionsTest() {
& FunctionsTest : : fmod ,
& FunctionsTest : : fmod ,
& FunctionsTest : : binomialCoefficient ,
& FunctionsTest : : binomialCoefficient ,
& FunctionsTest : : binomialCoefficientOverflow ,
& FunctionsTest : : sqrt ,
& FunctionsTest : : sqrt ,
& FunctionsTest : : sqrtInverted ,
& FunctionsTest : : sqrtInverted ,
@ -298,12 +300,24 @@ void FunctionsTest::ceil() {
}
}
void FunctionsTest : : binomialCoefficient ( ) {
void FunctionsTest : : binomialCoefficient ( ) {
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1 , 1 ) , 1 ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1 , 1 ) , 1ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1 , 0 ) , 1 ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1 , 0 ) , 1ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 19 , 11 ) , 75582 ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 19 , 11 ) , 75582ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1000 , 999 ) , 1000 ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 1000 , 999 ) , 1000ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 0 , 0 ) , 1 ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 0 , 0 ) , 1ul ) ;
CORRADE_COMPARE ( Math : : binomialCoefficient ( 32 , 11 ) , 129024480 ) ;
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 ( ) {
void FunctionsTest : : fmod ( ) {