4#include <cppunit/TestFixture.h>
5#include <cppunit/extensions/HelperMacros.h>
11using namespace CPPUNIT_NS;
15static_assert(
min(1, 2, 3) == 1,
"min");
16static_assert(
min(3, 2, 1) == 1,
"min");
17static_assert(
min(3, 4, 2, 1) == 1,
"min");
18static_assert(
min(3, 4, -2, 2, 1) == -2,
"min");
19static_assert(
max(1, 2, 3) == 3,
"max");
20static_assert(
max(3, 2, 1) == 3,
"max");
21static_assert(
max(3, 4, 2, 1) == 4,
"max");
22static_assert(
max(3, -2, 4, 2, 1) == 4,
"max");
36 CPPUNIT_TEST_SUITE_END();
57 CPPUNIT_ASSERT_EQUAL(0,
digitsum(0));
58 CPPUNIT_ASSERT_EQUAL(7,
digitsum(16));
59 CPPUNIT_ASSERT_EQUAL(1,
digitsum(16, 16));
69 CPPUNIT_ASSERT_EQUAL(25u,
powerModulo(5u, 2u, 30u));
The MathTests class tests functions provided by misc/math.h.
CPPUNIT_TEST_SUITE_REGISTRATION(MathTests)
Contains literals to ease asserting with CPPUNIT_ASSERT_EQUAL.
Contains all utilities provides by the c++utilities library.
constexpr IntegralType factorial(IntegralType number)
Returns the factorial of the given number.
constexpr IntegralType inverseModulo(IntegralType number, IntegralType module)
Computes the inverse of number modulo module.
constexpr IntegralType digitsum(IntegralType number, IntegralType base=10)
Returns the digitsum of the given number using the specified base.
constexpr T max(T first, T second)
Returns the greatest of the given items.
constexpr IntegralType powerModulo(const IntegralType base, const IntegralType exponent, const IntegralType module)
Computes base power exponent modulo module.
constexpr T min(T first, T second)
Returns the smallest of the given items.
constexpr IntegralType orderModulo(const IntegralType number, const IntegralType module)
Computes the order of number modulo module.