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();
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.
IntegralType stringToNumber(const StringType &string, BaseType base=10)
Converts the given string to an unsigned/signed number assuming string uses the specified base.
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.