1 #include "../math/math.h" 3 #include <cppunit/TestFixture.h> 4 #include <cppunit/extensions/HelperMacros.h> 16 CPPUNIT_TEST(testRandom);
17 CPPUNIT_TEST(testDigitsum);
18 CPPUNIT_TEST(testFactorial);
19 CPPUNIT_TEST(testPowerModulo);
20 CPPUNIT_TEST(testInverseModulo);
21 CPPUNIT_TEST(testOrderModulo);
22 CPPUNIT_TEST_SUITE_END();
35 void testPowerModulo();
36 void testInverseModulo();
37 void testOrderModulo();
44 CPPUNIT_ASSERT_EQUAL(6,
random(5, 7));
49 CPPUNIT_ASSERT_EQUAL(0,
digitsum(0));
50 CPPUNIT_ASSERT_EQUAL(7,
digitsum(16));
51 CPPUNIT_ASSERT_EQUAL(1,
digitsum(16, 16));
CPP_UTILITIES_EXPORT int factorial(int number)
Returns the factorial of the given number.
CPP_UTILITIES_EXPORT uint64 orderModulo(uint64 number, uint64 module)
Computes the order of number modulo module.
CPP_UTILITIES_EXPORT int64 inverseModulo(int64 number, int64 module)
Computes the inverse of number modulo module.
Contains various mathematical functions.
The MathTests class tests functions of the MathUtilities namespace.
CPP_UTILITIES_EXPORT int random(int lowerbounds, int upperbounds)
Returns a pseudo random number between lowerbounds and upperbounds.
CPPUNIT_TEST_SUITE_REGISTRATION(MathTests)
CPP_UTILITIES_EXPORT int digitsum(int number, int base=10)
Returns the digitsum of the given number using the specified base.
CPP_UTILITIES_EXPORT uint64 powerModulo(uint64 base, uint64 expontent, uint64 module)
Computes base power exponent modulo module.