Math: Remove Algorithm file and move string functions to StringExt
This commit is contained in:
parent
c87c45f332
commit
caf8446707
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include <NazaraUtils/Prerequisites.hpp>
|
#include <NazaraUtils/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/Unicode.hpp>
|
#include <Nazara/Core/Unicode.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp> //< FIXME
|
|
||||||
#include <NazaraUtils/Algorithm.hpp>
|
#include <NazaraUtils/Algorithm.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
@ -38,6 +37,8 @@ namespace Nz
|
||||||
|
|
||||||
NAZARA_CORE_API bool MatchPattern(const std::string_view& str, const std::string_view& pattern);
|
NAZARA_CORE_API bool MatchPattern(const std::string_view& str, const std::string_view& pattern);
|
||||||
|
|
||||||
|
inline std::string NumberToString(long long number, UInt8 radix = 10);
|
||||||
|
|
||||||
NAZARA_CORE_API std::string PointerToString(const void* ptr);
|
NAZARA_CORE_API std::string PointerToString(const void* ptr);
|
||||||
|
|
||||||
inline std::string& ReplaceStr(std::string& str, const std::string_view& from, const std::string_view& to);
|
inline std::string& ReplaceStr(std::string& str, const std::string_view& from, const std::string_view& to);
|
||||||
|
|
@ -55,6 +56,8 @@ namespace Nz
|
||||||
NAZARA_CORE_API bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware);
|
NAZARA_CORE_API bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware);
|
||||||
NAZARA_CORE_API bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware);
|
NAZARA_CORE_API bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware);
|
||||||
|
|
||||||
|
inline long long StringToNumber(const std::string_view& str, UInt8 radix = 10, bool* ok = nullptr);
|
||||||
|
|
||||||
NAZARA_CORE_API std::string ToLower(const std::string_view& str);
|
NAZARA_CORE_API std::string ToLower(const std::string_view& str);
|
||||||
NAZARA_CORE_API std::string ToLower(const std::string_view& str, UnicodeAware);
|
NAZARA_CORE_API std::string ToLower(const std::string_view& str, UnicodeAware);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
inline bool EndsWith(const std::string_view& str, const std::string_view& s)
|
inline bool EndsWith(const std::string_view& str, const std::string_view& s)
|
||||||
{
|
{
|
||||||
//FIXME: Replace with proper C++20 value once it's available
|
#if NAZARA_CPP_VER >= NAZARA_CPP20
|
||||||
#if NAZARA_CPP_VER > 201703L
|
|
||||||
// C++20
|
// C++20
|
||||||
return str.ends_with(s);
|
return str.ends_with(s);
|
||||||
#else
|
#else
|
||||||
|
|
@ -34,6 +33,49 @@ namespace Nz
|
||||||
return std::find_if(str.begin(), str.end(), [](unsigned char c) { return !std::isdigit(c); }) == str.end();
|
return std::find_if(str.begin(), str.end(), [](unsigned char c) { return !std::isdigit(c); }) == str.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup math
|
||||||
|
* \brief Converts the number to String
|
||||||
|
* \return String representation of the number
|
||||||
|
*
|
||||||
|
* \param number Number to represent
|
||||||
|
* \param radix Base of the number
|
||||||
|
*
|
||||||
|
* \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior
|
||||||
|
* \remark With NAZARA_MATH_SAFE, a NazaraError is produced and String() is returned
|
||||||
|
*/
|
||||||
|
inline std::string NumberToString(long long number, UInt8 radix)
|
||||||
|
{
|
||||||
|
NazaraAssert(radix >= 2 && radix <= 36, "base must be between 2 and 36");
|
||||||
|
|
||||||
|
bool negative;
|
||||||
|
if (number < 0)
|
||||||
|
{
|
||||||
|
negative = true;
|
||||||
|
number = -number;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
negative = false;
|
||||||
|
|
||||||
|
std::string str;
|
||||||
|
|
||||||
|
constexpr char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
str.push_back(symbols[number % radix]);
|
||||||
|
number /= radix;
|
||||||
|
} while (number > 0);
|
||||||
|
|
||||||
|
if (negative)
|
||||||
|
str.push_back('-');
|
||||||
|
|
||||||
|
std::reverse(str.begin(), str.end());
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
inline std::string& ReplaceStr(std::string& str, const std::string_view& from, const std::string_view& to)
|
inline std::string& ReplaceStr(std::string& str, const std::string_view& from, const std::string_view& to)
|
||||||
{
|
{
|
||||||
if (str.empty())
|
if (str.empty())
|
||||||
|
|
@ -51,8 +93,7 @@ namespace Nz
|
||||||
|
|
||||||
inline bool StartsWith(const std::string_view& str, const std::string_view& s)
|
inline bool StartsWith(const std::string_view& str, const std::string_view& s)
|
||||||
{
|
{
|
||||||
//FIXME: Replace with proper C++20 value once it's available
|
#if NAZARA_CPP_VER >= NAZARA_CPP20
|
||||||
#if NAZARA_CPP_VER > 201703L
|
|
||||||
// C++20
|
// C++20
|
||||||
return str.starts_with(s);
|
return str.starts_with(s);
|
||||||
#else
|
#else
|
||||||
|
|
@ -115,6 +156,60 @@ namespace Nz
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup math
|
||||||
|
* \brief Converts the string to number
|
||||||
|
* \return Number which is represented by the string
|
||||||
|
*
|
||||||
|
* \param str String representation
|
||||||
|
* \param radix Base of the number
|
||||||
|
* \param ok Optional argument to know if convertion is correct
|
||||||
|
*
|
||||||
|
* \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior
|
||||||
|
* \remark With NAZARA_MATH_SAFE, a NazaraError is produced and 0 is returned
|
||||||
|
*/
|
||||||
|
inline long long StringToNumber(const std::string_view& str, UInt8 radix, bool* ok)
|
||||||
|
{
|
||||||
|
NazaraAssert(radix >= 2 && radix <= 36, "base must be between 2 and 36");
|
||||||
|
|
||||||
|
if (str.empty())
|
||||||
|
{
|
||||||
|
if (ok)
|
||||||
|
*ok = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
|
||||||
|
bool negative = (str.front() == '-');
|
||||||
|
|
||||||
|
const char* digit = &str[(negative) ? 1 : 0];
|
||||||
|
unsigned long long total = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (*digit == ' ')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
total *= radix;
|
||||||
|
const char* c = std::strchr(symbols, *digit);
|
||||||
|
if (c && c - symbols < radix)
|
||||||
|
total += c - symbols;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ok)
|
||||||
|
*ok = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} while (*++digit);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
*ok = true;
|
||||||
|
|
||||||
|
return (negative) ? -static_cast<long long>(total) : total;
|
||||||
|
}
|
||||||
|
|
||||||
inline std::string_view Trim(std::string_view str)
|
inline std::string_view Trim(std::string_view str)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef NAZARA_GLOBAL_MATH_HPP
|
#ifndef NAZARA_GLOBAL_MATH_HPP
|
||||||
#define NAZARA_GLOBAL_MATH_HPP
|
#define NAZARA_GLOBAL_MATH_HPP
|
||||||
|
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Math/Angle.hpp>
|
#include <Nazara/Math/Angle.hpp>
|
||||||
#include <Nazara/Math/BoundingVolume.hpp>
|
#include <Nazara/Math/BoundingVolume.hpp>
|
||||||
#include <Nazara/Math/Box.hpp>
|
#include <Nazara/Math/Box.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
|
||||||
// This file is part of the "Nazara Engine - Math module"
|
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef NAZARA_MATH_ALGORITHM_HPP
|
|
||||||
#define NAZARA_MATH_ALGORITHM_HPP
|
|
||||||
|
|
||||||
#include <NazaraUtils/Prerequisites.hpp>
|
|
||||||
#include <Nazara/Math/Enums.hpp>
|
|
||||||
#include <NazaraUtils/Algorithm.hpp>
|
|
||||||
#include <cmath>
|
|
||||||
#include <limits>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Nz
|
|
||||||
{
|
|
||||||
template<AngleUnit Unit, typename T> class Angle;
|
|
||||||
|
|
||||||
template<typename T, AngleUnit Unit> constexpr Angle<Unit, T> Clamp(Angle<Unit, T> value, T min, T max);
|
|
||||||
|
|
||||||
constexpr unsigned int GetNumberLength(signed char number);
|
|
||||||
constexpr unsigned int GetNumberLength(unsigned char number);
|
|
||||||
unsigned int GetNumberLength(int number);
|
|
||||||
/*constexpr*/ unsigned int GetNumberLength(unsigned int number);
|
|
||||||
unsigned int GetNumberLength(long long number);
|
|
||||||
/*constexpr*/ unsigned int GetNumberLength(unsigned long long number);
|
|
||||||
unsigned int GetNumberLength(float number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
|
||||||
unsigned int GetNumberLength(double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
|
||||||
unsigned int GetNumberLength(long double number, UInt8 precision = NAZARA_CORE_DECIMAL_DIGITS);
|
|
||||||
inline std::string NumberToString(long long number, UInt8 radix = 10);
|
|
||||||
inline long long StringToNumber(const std::string_view& str, UInt8 radix = 10, bool* ok = nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <Nazara/Math/Algorithm.inl>
|
|
||||||
|
|
||||||
#endif // NAZARA_MATH_ALGORITHM_HPP
|
|
||||||
|
|
@ -1,298 +0,0 @@
|
||||||
// Copyright (C) 2023 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
|
||||||
// This file is part of the "Nazara Engine - Math module"
|
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
|
||||||
|
|
||||||
#include <Nazara/Core/Error.hpp>
|
|
||||||
#include <Nazara/Math/Config.hpp>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstring>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <Nazara/Core/Debug.hpp>
|
|
||||||
|
|
||||||
namespace Nz
|
|
||||||
{
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Clamps an angle value between min and max and returns the expected value
|
|
||||||
* \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval
|
|
||||||
*
|
|
||||||
* \param value Value to clamp
|
|
||||||
* \param min Minimum of the interval
|
|
||||||
* \param max Maximum of the interval
|
|
||||||
*/
|
|
||||||
template<typename T, AngleUnit Unit>
|
|
||||||
constexpr Angle<Unit, T> Clamp(Angle<Unit, T> value, T min, T max)
|
|
||||||
{
|
|
||||||
return std::max(std::min(value.value, max), min);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
*/
|
|
||||||
constexpr inline unsigned int GetNumberLength(signed char number)
|
|
||||||
{
|
|
||||||
// Char is expected to be 1 byte
|
|
||||||
static_assert(sizeof(number) == 1, "Signed char must be one byte-sized");
|
|
||||||
|
|
||||||
if (number >= 100)
|
|
||||||
return 3;
|
|
||||||
else if (number >= 10)
|
|
||||||
return 2;
|
|
||||||
else if (number >= 0)
|
|
||||||
return 1;
|
|
||||||
else if (number > -10)
|
|
||||||
return 2;
|
|
||||||
else if (number > -100)
|
|
||||||
return 3;
|
|
||||||
else
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
*/
|
|
||||||
constexpr inline unsigned int GetNumberLength(unsigned char number)
|
|
||||||
{
|
|
||||||
// Char is expected to be 1 byte
|
|
||||||
static_assert(sizeof(number) == 1, "Unsigned char must be one byte-sized");
|
|
||||||
|
|
||||||
if (number >= 100)
|
|
||||||
return 3;
|
|
||||||
else if (number >= 10)
|
|
||||||
return 2;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
*/
|
|
||||||
inline unsigned int GetNumberLength(int number)
|
|
||||||
{
|
|
||||||
if (number == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return static_cast<unsigned int>(std::log10(std::abs(number))) + (number < 0 ? 2 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
*/
|
|
||||||
//TODO: Mark as constexpr when supported by all major compilers
|
|
||||||
/*constexpr*/ inline unsigned int GetNumberLength(unsigned int number)
|
|
||||||
{
|
|
||||||
if (number == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return static_cast<unsigned int>(std::log10(number))+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
*/
|
|
||||||
inline unsigned int GetNumberLength(long long number)
|
|
||||||
{
|
|
||||||
if (number == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return static_cast<unsigned int>(std::log10(std::abs(number))) + (number < 0 ? 2 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
*/
|
|
||||||
//TODO: Mark as constexpr when supported by all major compilers
|
|
||||||
/*constexpr*/ inline unsigned int GetNumberLength(unsigned long long number)
|
|
||||||
{
|
|
||||||
if (number == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return static_cast<unsigned int>(std::log10(number)) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits + 1 for the dot
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
* \param precision Number of digit after the dot
|
|
||||||
*/
|
|
||||||
inline unsigned int GetNumberLength(float number, UInt8 precision)
|
|
||||||
{
|
|
||||||
// The imprecision of floats need a cast (log10(9.99999) = 0.99999)
|
|
||||||
return GetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus one for the dot
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits + 1 for the dot
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
* \param precision Number of digit after the dot
|
|
||||||
*/
|
|
||||||
inline unsigned int GetNumberLength(double number, UInt8 precision)
|
|
||||||
{
|
|
||||||
// The imprecision of floats need a cast (log10(9.99999) = 0.99999)
|
|
||||||
return GetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus one for the dot
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Gets the number of digits to represent the number in base 10
|
|
||||||
* \return Number of digits + 1 for the dot
|
|
||||||
*
|
|
||||||
* \param number Number to get number of digits
|
|
||||||
* \param precision Number of digit after the dot
|
|
||||||
*/
|
|
||||||
inline unsigned int GetNumberLength(long double number, UInt8 precision)
|
|
||||||
{
|
|
||||||
// The imprecision of floats need a cast (log10(9.99999) = 0.99999)
|
|
||||||
return GetNumberLength(static_cast<long long>(number)) + precision + 1; // Plus one for the dot
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Converts the number to String
|
|
||||||
* \return String representation of the number
|
|
||||||
*
|
|
||||||
* \param number Number to represent
|
|
||||||
* \param radix Base of the number
|
|
||||||
*
|
|
||||||
* \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior
|
|
||||||
* \remark With NAZARA_MATH_SAFE, a NazaraError is produced and String() is returned
|
|
||||||
*/
|
|
||||||
inline std::string NumberToString(long long number, UInt8 radix)
|
|
||||||
{
|
|
||||||
#if NAZARA_MATH_SAFE
|
|
||||||
if (radix < 2 || radix > 36)
|
|
||||||
{
|
|
||||||
NazaraError("Base must be between 2 and 36");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (number == 0)
|
|
||||||
return "0";
|
|
||||||
|
|
||||||
bool negative;
|
|
||||||
if (number < 0)
|
|
||||||
{
|
|
||||||
negative = true;
|
|
||||||
number = -number;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
negative = false;
|
|
||||||
|
|
||||||
std::string str;
|
|
||||||
|
|
||||||
const char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
str.push_back(symbols[number % radix]);
|
|
||||||
number /= radix;
|
|
||||||
}
|
|
||||||
while (number > 0);
|
|
||||||
|
|
||||||
if (negative)
|
|
||||||
str.push_back('-');
|
|
||||||
|
|
||||||
std::reverse(str.begin(), str.end());
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \ingroup math
|
|
||||||
* \brief Converts the string to number
|
|
||||||
* \return Number which is represented by the string
|
|
||||||
*
|
|
||||||
* \param str String representation
|
|
||||||
* \param radix Base of the number
|
|
||||||
* \param ok Optional argument to know if convertion is correct
|
|
||||||
*
|
|
||||||
* \remark radix is meant to be between 2 and 36, other values are potentially undefined behavior
|
|
||||||
* \remark With NAZARA_MATH_SAFE, a NazaraError is produced and 0 is returned
|
|
||||||
*/
|
|
||||||
inline long long StringToNumber(const std::string_view& str, UInt8 radix, bool* ok)
|
|
||||||
{
|
|
||||||
#if NAZARA_MATH_SAFE
|
|
||||||
if (radix < 2 || radix > 36)
|
|
||||||
{
|
|
||||||
NazaraError("Radix must be between 2 and 36");
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
*ok = false;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (str.empty())
|
|
||||||
{
|
|
||||||
if (ok)
|
|
||||||
*ok = false;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char symbols[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
||||||
|
|
||||||
bool negative = (str.front() == '-');
|
|
||||||
|
|
||||||
const char* digit = &str[(negative) ? 1 : 0];
|
|
||||||
unsigned long long total = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (*digit == ' ')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
total *= radix;
|
|
||||||
const char* c = std::strchr(symbols, *digit);
|
|
||||||
if (c && c-symbols < radix)
|
|
||||||
total += c-symbols;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ok)
|
|
||||||
*ok = false;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (*++digit);
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
*ok = true;
|
|
||||||
|
|
||||||
return (negative) ? -static_cast<long long>(total) : total;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <Nazara/Core/DebugOff.hpp>
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
#ifndef NAZARA_MATH_ANGLE_HPP
|
#ifndef NAZARA_MATH_ANGLE_HPP
|
||||||
#define NAZARA_MATH_ANGLE_HPP
|
#define NAZARA_MATH_ANGLE_HPP
|
||||||
|
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Math/Enums.hpp>
|
#include <Nazara/Math/Enums.hpp>
|
||||||
#include <NazaraUtils/TypeTag.hpp>
|
#include <NazaraUtils/TypeTag.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
@ -81,6 +80,7 @@ namespace Nz
|
||||||
|
|
||||||
static constexpr bool ApproxEqual(const Angle& lhs, const Angle& rhs);
|
static constexpr bool ApproxEqual(const Angle& lhs, const Angle& rhs);
|
||||||
static constexpr bool ApproxEqual(const Angle& lhs, const Angle& rhs, T maxDifference);
|
static constexpr bool ApproxEqual(const Angle& lhs, const Angle& rhs, T maxDifference);
|
||||||
|
static constexpr Angle Clamp(Angle angle, Angle min, Angle max);
|
||||||
template<AngleUnit FromUnit> static constexpr Angle From(T value);
|
template<AngleUnit FromUnit> static constexpr Angle From(T value);
|
||||||
static constexpr Angle FromDegrees(T degrees);
|
static constexpr Angle FromDegrees(T degrees);
|
||||||
static constexpr Angle FromRadians(T radians);
|
static constexpr Angle FromRadians(T radians);
|
||||||
|
|
|
||||||
|
|
@ -619,6 +619,12 @@ namespace Nz
|
||||||
return lhs.ApproxEqual(rhs, maxDifference);
|
return lhs.ApproxEqual(rhs, maxDifference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<AngleUnit Unit, typename T>
|
||||||
|
constexpr Angle<Unit, T> Angle<Unit, T>::Clamp(Angle angle, Angle min, Angle max)
|
||||||
|
{
|
||||||
|
return Angle(std::clamp(angle.value, min.value, max.value));
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Builds an Angle instance using a FromUnit angle, converting if needed
|
* \brief Builds an Angle instance using a FromUnit angle, converting if needed
|
||||||
* \return An angle describing the FromUnit angle as Unit
|
* \return An angle describing the FromUnit angle as Unit
|
||||||
|
|
@ -720,6 +726,21 @@ namespace Nz
|
||||||
return Detail::AngleUtils<Unit>::ToString(out, angle.value);
|
return Detail::AngleUtils<Unit>::ToString(out, angle.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup math
|
||||||
|
* \brief Clamps an angle value between min and max and returns the expected value
|
||||||
|
* \return If value is not in the interval of min..max, value obtained is the nearest limit of this interval
|
||||||
|
*
|
||||||
|
* \param value Value to clamp
|
||||||
|
* \param min Minimum of the interval
|
||||||
|
* \param max Maximum of the interval
|
||||||
|
*/
|
||||||
|
template<typename T, AngleUnit Unit>
|
||||||
|
constexpr Angle<Unit, T> Clamp(Angle<Unit, T> value, T min, T max)
|
||||||
|
{
|
||||||
|
return std::max(std::min(value.value, max), min);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Serializes an Angle
|
* \brief Serializes an Angle
|
||||||
* \return true if successfully serialized
|
* \return true if successfully serialized
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
#include <Nazara/Core/StringExt.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Math/Config.hpp>
|
#include <Nazara/Math/Config.hpp>
|
||||||
#include <Nazara/Math/Quaternion.hpp>
|
#include <Nazara/Math/Quaternion.hpp>
|
||||||
#include <Nazara/Math/Vector3.hpp>
|
#include <Nazara/Math/Vector3.hpp>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
// http://www.lighthouse3d.com/tutorials/view-frustum-culling/
|
// http://www.lighthouse3d.com/tutorials/view-frustum-culling/
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <NazaraUtils/EnumArray.hpp>
|
#include <NazaraUtils/EnumArray.hpp>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Core/Log.hpp>
|
#include <Nazara/Core/Log.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Math/Config.hpp>
|
#include <Nazara/Math/Config.hpp>
|
||||||
#include <Nazara/Math/EulerAngles.hpp>
|
#include <Nazara/Math/EulerAngles.hpp>
|
||||||
#include <Nazara/Math/Quaternion.hpp>
|
#include <Nazara/Math/Quaternion.hpp>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Math/Config.hpp>
|
#include <Nazara/Math/Config.hpp>
|
||||||
#include <Nazara/Math/EulerAngles.hpp>
|
#include <Nazara/Math/EulerAngles.hpp>
|
||||||
#include <Nazara/Math/Vector3.hpp>
|
#include <Nazara/Math/Vector3.hpp>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
#include <Nazara/Core/StringExt.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Math/Box.hpp>
|
#include <Nazara/Math/Box.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Renderer/Debug.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Renderer/Debug.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <Nazara/Widgets/Debug.hpp>
|
#include <Nazara/Widgets/Debug.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include <Nazara/Core/AbstractHash.hpp>
|
#include <Nazara/Core/AbstractHash.hpp>
|
||||||
#include <Nazara/Core/Algorithm.hpp>
|
#include <Nazara/Core/Algorithm.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
#include <Nazara/Core/StringExt.hpp>
|
||||||
#include <Nazara/Core/Hash/CRC32.hpp>
|
#include <Nazara/Core/Hash/CRC32.hpp>
|
||||||
#include <Nazara/Core/Hash/CRC64.hpp>
|
#include <Nazara/Core/Hash/CRC64.hpp>
|
||||||
#include <Nazara/Core/Hash/Fletcher16.hpp>
|
#include <Nazara/Core/Hash/Fletcher16.hpp>
|
||||||
|
|
@ -15,7 +16,6 @@
|
||||||
#include <Nazara/Core/Hash/SHA384.hpp>
|
#include <Nazara/Core/Hash/SHA384.hpp>
|
||||||
#include <Nazara/Core/Hash/SHA512.hpp>
|
#include <Nazara/Core/Hash/SHA512.hpp>
|
||||||
#include <Nazara/Core/Hash/Whirlpool.hpp>
|
#include <Nazara/Core/Hash/Whirlpool.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Core/Debug.hpp>
|
#include <Nazara/Core/Debug.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@
|
||||||
#include <NazaraUtils/Prerequisites.hpp>
|
#include <NazaraUtils/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/DynLib.hpp>
|
#include <Nazara/Core/DynLib.hpp>
|
||||||
#include <NazaraUtils/MovablePtr.hpp>
|
#include <NazaraUtils/MovablePtr.hpp>
|
||||||
#include <filesystem>
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPipelineInfo renderPipelineInfo;
|
RenderPipelineInfo renderPipelineInfo;
|
||||||
static_cast<RenderStates&>(renderPipelineInfo).operator=(m_pipelineInfo);
|
static_cast<RenderStates&>(renderPipelineInfo) = m_pipelineInfo;
|
||||||
|
|
||||||
renderPipelineInfo.pipelineLayout = m_pipelineInfo.pipelineLayout;
|
renderPipelineInfo.pipelineLayout = m_pipelineInfo.pipelineLayout;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Nazara/Network/ENetHost.hpp>
|
#include <Nazara/Network/ENetHost.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
#include <Nazara/Core/StringExt.hpp>
|
||||||
#include <Nazara/Network/Algorithm.hpp>
|
#include <Nazara/Network/Algorithm.hpp>
|
||||||
#include <Nazara/Network/ENetPeer.hpp>
|
#include <Nazara/Network/ENetPeer.hpp>
|
||||||
#include <Nazara/Network/NetPacket.hpp>
|
#include <Nazara/Network/NetPacket.hpp>
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static std::size_t s_enetCommandSizes[ENetProtocolCommand_Count] =
|
constexpr std::size_t s_enetCommandSizes[ENetProtocolCommand_Count] =
|
||||||
{
|
{
|
||||||
0,
|
0,
|
||||||
sizeof(ENetProtocolAcknowledge),
|
sizeof(ENetProtocolAcknowledge),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include <Nazara/Utility/PixelFormat.hpp>
|
#include <Nazara/Utility/PixelFormat.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <NazaraUtils/Endianness.hpp>
|
#include <NazaraUtils/Endianness.hpp>
|
||||||
#include <Nazara/Utility/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Widgets/ScrollAreaWidget.hpp>
|
#include <Nazara/Widgets/ScrollAreaWidget.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Widgets/ScrollbarWidget.hpp>
|
#include <Nazara/Widgets/ScrollbarWidget.hpp>
|
||||||
#include <Nazara/Widgets/Debug.hpp>
|
#include <Nazara/Widgets/Debug.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Widgets/ScrollbarWidget.hpp>
|
#include <Nazara/Widgets/ScrollbarWidget.hpp>
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Widgets/ImageButtonWidget.hpp>
|
#include <Nazara/Widgets/ImageButtonWidget.hpp>
|
||||||
#include <Nazara/Widgets/ScrollbarButtonWidget.hpp>
|
#include <Nazara/Widgets/ScrollbarButtonWidget.hpp>
|
||||||
#include <Nazara/Widgets/Debug.hpp>
|
#include <Nazara/Widgets/Debug.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
#include <Nazara/Math/Algorithm.hpp>
|
|
||||||
#include <Nazara/Math/Angle.hpp>
|
#include <Nazara/Math/Angle.hpp>
|
||||||
#include <catch2/catch_approx.hpp>
|
#include <catch2/catch_approx.hpp>
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
@ -84,63 +83,6 @@ TEST_CASE("GetNearestPowerOfTwo", "[MATH][ALGORITHM]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("GetNumberLength", "[MATH][ALGORITHM]")
|
|
||||||
{
|
|
||||||
SECTION("GetNumberLength of -127 signed char")
|
|
||||||
{
|
|
||||||
signed char minus127 = -127;
|
|
||||||
REQUIRE(Nz::GetNumberLength(minus127) == 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("GetNumberLength of 255 unsigned char")
|
|
||||||
{
|
|
||||||
unsigned char plus255 = 255;
|
|
||||||
REQUIRE(Nz::GetNumberLength(plus255) == 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("GetNumberLength of -1270 signed int")
|
|
||||||
{
|
|
||||||
signed int minus1270 = -1270;
|
|
||||||
REQUIRE(Nz::GetNumberLength(minus1270) == 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("GetNumberLength of 2550 unsigned int")
|
|
||||||
{
|
|
||||||
unsigned int plus2550 = 2550;
|
|
||||||
REQUIRE(Nz::GetNumberLength(plus2550) == 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("GetNumberLength of -1270 signed long long")
|
|
||||||
{
|
|
||||||
signed long long minus12700 = -12700;
|
|
||||||
REQUIRE(Nz::GetNumberLength(minus12700) == 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("GetNumberLength of 2550 unsigned long long")
|
|
||||||
{
|
|
||||||
unsigned long long plus25500 = 25500;
|
|
||||||
REQUIRE(Nz::GetNumberLength(plus25500) == 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("GetNumberLength of -2.456f float")
|
|
||||||
{
|
|
||||||
float minus2P456 = -2.456f;
|
|
||||||
REQUIRE(Nz::GetNumberLength(minus2P456, 3) == 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("GetNumberLength of -2.456 double")
|
|
||||||
{
|
|
||||||
double minus2P456 = -2.456;
|
|
||||||
REQUIRE(Nz::GetNumberLength(minus2P456, 3) == 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION("GetNumberLength of -2.456 long double")
|
|
||||||
{
|
|
||||||
long double minus2P456 = -2.456L;
|
|
||||||
REQUIRE(Nz::GetNumberLength(minus2P456, 3) == 6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("IntegralLog2", "[MATH][ALGORITHM]")
|
TEST_CASE("IntegralLog2", "[MATH][ALGORITHM]")
|
||||||
{
|
{
|
||||||
SECTION("According to implementation, log in base 2 of 0 = 0")
|
SECTION("According to implementation, log in base 2 of 0 = 0")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue