mirror of
https://github.com/ETLCPP/etl.git
synced 2026-10-28 18:07:10 +08:00
Finished floating point conversions and tests
This commit is contained in:
parent
7b9c1f97ad
commit
743d4e32ca
@ -47,12 +47,14 @@ SOFTWARE.
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// bit_cast
|
||||
/// bit_cast - Type to different type.
|
||||
//***************************************************************************
|
||||
template <typename TDestination, typename TSource>
|
||||
typename etl::enable_if<(sizeof(TDestination) == sizeof(TSource)) &&
|
||||
etl::is_trivially_copyable<TSource>::value &&
|
||||
etl::is_trivially_copyable<TDestination>::value, TDestination>::type
|
||||
ETL_NODISCARD
|
||||
typename etl::enable_if<!(etl::is_integral<TDestination>::value&& etl::is_integral<TSource>::value) &&
|
||||
(sizeof(TDestination) == sizeof(TSource)) &&
|
||||
etl::is_trivially_copyable<TSource>::value &&
|
||||
etl::is_trivially_copyable<TDestination>::value, TDestination>::type
|
||||
bit_cast(const TSource& source) ETL_NOEXCEPT
|
||||
{
|
||||
TDestination destination;
|
||||
@ -62,6 +64,19 @@ namespace etl
|
||||
return destination;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// bit_cast - Integral to integral
|
||||
//***************************************************************************
|
||||
template <typename TDestination, typename TSource>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
typename etl::enable_if<(etl::is_integral<TDestination>::value && etl::is_integral<TSource>::value) &&
|
||||
(sizeof(TDestination) == sizeof(TSource)), TDestination>::type
|
||||
bit_cast(const TSource& source) ETL_NOEXCEPT
|
||||
{
|
||||
return static_cast<TDestination>(source);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// byteswap
|
||||
//***************************************************************************
|
||||
|
||||
@ -55,6 +55,7 @@ namespace etl
|
||||
{
|
||||
Not_Set,
|
||||
Valid,
|
||||
Invalid_Radix,
|
||||
Invalid_Format,
|
||||
Invalid_Float,
|
||||
Signed_To_Unsigned,
|
||||
@ -62,8 +63,9 @@ namespace etl
|
||||
};
|
||||
|
||||
ETL_DECLARE_ENUM_TYPE(to_arithmetic_status, int)
|
||||
ETL_ENUM_TYPE(Not_Set, "Not_Set")
|
||||
ETL_ENUM_TYPE(Not_Set, "Not Set")
|
||||
ETL_ENUM_TYPE(Valid, "Valid")
|
||||
ETL_ENUM_TYPE(Invalid_Radix, "Invalid Radix")
|
||||
ETL_ENUM_TYPE(Invalid_Format, "Invalid Format")
|
||||
ETL_ENUM_TYPE(Invalid_Float, "Invalid Float")
|
||||
ETL_ENUM_TYPE(Signed_To_Unsigned, "Signed To Unsigned")
|
||||
@ -85,6 +87,8 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Default constructor.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
to_arithmetic_result()
|
||||
: conversion_value(static_cast<value_type>(0))
|
||||
, conversion_status(status_type::Not_Set)
|
||||
@ -94,6 +98,8 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Copy constructor.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
to_arithmetic_result(const to_arithmetic_result& other)
|
||||
: conversion_value(other.conversion_value)
|
||||
, conversion_status(other.conversion_status)
|
||||
@ -103,6 +109,8 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Returns <b>true</b> if the result has a valid value.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool has_value() const
|
||||
{
|
||||
return (conversion_status == status_type::Valid);
|
||||
@ -111,6 +119,8 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Returns <b>true</b> if the result has a valid value.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
operator bool() const
|
||||
{
|
||||
return has_value();
|
||||
@ -120,6 +130,8 @@ namespace etl
|
||||
/// Returns the value, if valid.
|
||||
/// Otherwise undefined.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
value_type value() const
|
||||
{
|
||||
return conversion_value;
|
||||
@ -128,6 +140,7 @@ namespace etl
|
||||
//*******************************************
|
||||
/// Sets the value.
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
void value(value_type value)
|
||||
{
|
||||
conversion_value = value;
|
||||
@ -137,6 +150,8 @@ namespace etl
|
||||
/// Returns the value, if valid.
|
||||
/// Otherwise undefined.
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
operator value_type() const
|
||||
{
|
||||
return value();
|
||||
@ -147,10 +162,14 @@ namespace etl
|
||||
/// One of the following:-
|
||||
/// Not_Set
|
||||
/// Valid
|
||||
/// Invalid_Radix
|
||||
/// Invalid_Format
|
||||
/// Invalid_Float
|
||||
/// Signed_To_Unsigned
|
||||
/// Overflow
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
status_type status() const
|
||||
{
|
||||
return conversion_status;
|
||||
@ -158,7 +177,16 @@ namespace etl
|
||||
|
||||
//*******************************************
|
||||
/// Sets the status.
|
||||
/// One of the following:-
|
||||
/// Not_Set
|
||||
/// Valid
|
||||
/// Invalid_Radix
|
||||
/// Invalid_Format
|
||||
/// Invalid_Float
|
||||
/// Signed_To_Unsigned
|
||||
/// Overflow
|
||||
//*******************************************
|
||||
ETL_CONSTEXPR14
|
||||
void status(status_type status_)
|
||||
{
|
||||
conversion_status = status_;
|
||||
@ -172,97 +200,88 @@ namespace etl
|
||||
|
||||
namespace private_to_arithmetic
|
||||
{
|
||||
//***********************************************************************
|
||||
///
|
||||
//***********************************************************************
|
||||
struct character_set
|
||||
static ETL_CONSTANT char Positive_Char = '+';
|
||||
static ETL_CONSTANT char Negative_Char = '-';
|
||||
static ETL_CONSTANT char Radix_Point1_Char = '.';
|
||||
static ETL_CONSTANT char Radix_Point2_Char = ',';
|
||||
static ETL_CONSTANT char Exponential_Char = 'e';
|
||||
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
inline
|
||||
ETL_CONSTEXPR14
|
||||
bool is_valid(char c, etl::radix::value_type radix)
|
||||
{
|
||||
typedef char value_type;
|
||||
typedef const value_type* string_type;
|
||||
static ETL_CONSTANT string_type Valid_Chars = "+-.,eE0123456789abcdefABCDEF";
|
||||
static ETL_CONSTANT int Valid_Length = etl::strlen(Valid_Chars);
|
||||
static ETL_CONSTANT value_type Positive_Char = '+';
|
||||
static ETL_CONSTANT value_type Negative_Char = '-';
|
||||
static ETL_CONSTANT value_type Radix_Point1 = '.';
|
||||
static ETL_CONSTANT value_type Radix_Point2 = ',';
|
||||
static ETL_CONSTANT value_type Exponential = 'e';
|
||||
static ETL_CONSTANT value_type Unknown_Char = '?';
|
||||
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
static bool is_valid(char c, etl::radix::value_type radix)
|
||||
switch (radix)
|
||||
{
|
||||
switch (radix)
|
||||
case etl::radix::binary:
|
||||
{
|
||||
case etl::radix::binary:
|
||||
{
|
||||
return (c >= '0') && (c <= '1');
|
||||
break;
|
||||
}
|
||||
return (c >= '0') && (c <= '1');
|
||||
break;
|
||||
}
|
||||
|
||||
case etl::radix::octal:
|
||||
{
|
||||
return (c >= '0') && (c <= '7');
|
||||
break;
|
||||
}
|
||||
case etl::radix::octal:
|
||||
{
|
||||
return (c >= '0') && (c <= '7');
|
||||
break;
|
||||
}
|
||||
|
||||
case etl::radix::decimal:
|
||||
{
|
||||
return (c >= '0') && (c <= '9');
|
||||
break;
|
||||
}
|
||||
case etl::radix::decimal:
|
||||
{
|
||||
return (c >= '0') && (c <= '9');
|
||||
break;
|
||||
}
|
||||
|
||||
case etl::radix::hex:
|
||||
{
|
||||
return ((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f'));
|
||||
break;
|
||||
}
|
||||
case etl::radix::hex:
|
||||
{
|
||||
return ((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f'));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
static char digit_value(char c, etl::radix::value_type radix)
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
inline
|
||||
ETL_CONSTEXPR14
|
||||
char digit_value(char c, etl::radix::value_type radix)
|
||||
{
|
||||
switch (radix)
|
||||
{
|
||||
switch (radix)
|
||||
case etl::radix::binary:
|
||||
case etl::radix::octal:
|
||||
case etl::radix::decimal:
|
||||
{
|
||||
case etl::radix::binary:
|
||||
case etl::radix::octal:
|
||||
case etl::radix::decimal:
|
||||
{
|
||||
return c - '0';
|
||||
break;
|
||||
}
|
||||
|
||||
case etl::radix::hex:
|
||||
{
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
{
|
||||
return c - '0';
|
||||
break;
|
||||
}
|
||||
|
||||
case etl::radix::hex:
|
||||
else
|
||||
{
|
||||
if ((c >= '0') && (c <= '9'))
|
||||
{
|
||||
return c - '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
return (c - 'a') + 10;
|
||||
}
|
||||
break;
|
||||
return (c - 'a') + 10;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
@ -279,69 +298,12 @@ namespace etl
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
template <typename TChar>
|
||||
ETL_NODISCARD
|
||||
inline
|
||||
ETL_CONSTEXPR14
|
||||
char convert(char c)
|
||||
char convert(TChar c)
|
||||
{
|
||||
return to_lower(c);
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
inline
|
||||
ETL_CONSTEXPR14
|
||||
char convert(wchar_t c)
|
||||
{
|
||||
ETL_STATIC_CONSTANT wchar_t* Valid_Chars = L"+-.,eE0123456789abcdefABCDEF";
|
||||
|
||||
for (int i = 0; i < character_set::Valid_Length; ++i)
|
||||
{
|
||||
if (c == Valid_Chars[i])
|
||||
{
|
||||
return to_lower(character_set::Valid_Chars[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return character_set::Unknown_Char;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
inline
|
||||
ETL_CONSTEXPR14
|
||||
char convert(char16_t c)
|
||||
{
|
||||
ETL_STATIC_CONSTANT char16_t* Valid_Chars = u"+-.,eE0123456789abcdefABCDEF";
|
||||
|
||||
for (int i = 0; i < character_set::Valid_Length; ++i)
|
||||
{
|
||||
if (c == Valid_Chars[i])
|
||||
{
|
||||
return to_lower(character_set::Valid_Chars[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return character_set::Unknown_Char;
|
||||
}
|
||||
|
||||
//*******************************************
|
||||
ETL_NODISCARD
|
||||
inline
|
||||
ETL_CONSTEXPR14
|
||||
char convert(char32_t c)
|
||||
{
|
||||
ETL_STATIC_CONSTANT char32_t* Valid_Chars = U"+-.,eE0123456789abcdefABCDEF";
|
||||
|
||||
for (int i = 0; i < character_set::Valid_Length; ++i)
|
||||
{
|
||||
if (c == Valid_Chars[i])
|
||||
{
|
||||
return to_lower(character_set::Valid_Chars[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return character_set::Unknown_Char;
|
||||
return to_lower(static_cast<char>(c));
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -356,8 +318,8 @@ namespace etl
|
||||
{
|
||||
// Check for prefix.
|
||||
const char c = convert(view[0]);
|
||||
const bool has_positive_prefix = (c == character_set::Positive_Char);
|
||||
const bool has_negative_prefix = (c == character_set::Negative_Char);
|
||||
const bool has_positive_prefix = (c == Positive_Char);
|
||||
const bool has_negative_prefix = (c == Negative_Char);
|
||||
|
||||
// Step over the prefix, if present.
|
||||
if (has_positive_prefix || has_negative_prefix)
|
||||
@ -409,7 +371,7 @@ namespace etl
|
||||
bool is_success = false;
|
||||
bool is_not_overflow = false;
|
||||
|
||||
const bool is_valid_char = character_set::is_valid(c, radix);
|
||||
const bool is_valid_char = is_valid(c, radix);
|
||||
|
||||
if (is_valid_char)
|
||||
{
|
||||
@ -421,7 +383,7 @@ namespace etl
|
||||
|
||||
if (is_not_overflow)
|
||||
{
|
||||
const char digit = character_set::digit_value(c, radix);
|
||||
const char digit = digit_value(c, radix);
|
||||
|
||||
// No addition overflow?
|
||||
is_not_overflow = ((maximum - digit) >= integral_value);
|
||||
@ -449,24 +411,24 @@ namespace etl
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool has_value() const
|
||||
ETL_CONSTEXPR14
|
||||
bool has_value() const
|
||||
{
|
||||
return conversion_status == to_arithmetic_status::Valid;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
TValue value() const
|
||||
ETL_CONSTEXPR14
|
||||
TValue value() const
|
||||
{
|
||||
return integral_value;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
to_arithmetic_status status() const
|
||||
ETL_CONSTEXPR14
|
||||
to_arithmetic_status status() const
|
||||
{
|
||||
return conversion_status;
|
||||
}
|
||||
@ -492,10 +454,10 @@ namespace etl
|
||||
, floating_point_value(0)
|
||||
, is_negative_mantissa(false)
|
||||
, is_negative_exponent(false)
|
||||
, exponent_value(0)
|
||||
, conversion_status(to_arithmetic_status::Valid)
|
||||
, state(Integral)
|
||||
, expecting_sign(true)
|
||||
, exponent_value(0)
|
||||
, state(Integral)
|
||||
, conversion_status(to_arithmetic_status::Valid)
|
||||
{
|
||||
}
|
||||
|
||||
@ -511,26 +473,26 @@ namespace etl
|
||||
//***************************
|
||||
case Integral:
|
||||
{
|
||||
if (expecting_sign && ((c == character_set::Positive_Char) || (c == character_set::Negative_Char)))
|
||||
if (expecting_sign && ((c == Positive_Char) || (c == Negative_Char)))
|
||||
{
|
||||
is_negative_mantissa = (c == character_set::Negative_Char);
|
||||
is_negative_mantissa = (c == Negative_Char);
|
||||
expecting_sign = false;
|
||||
}
|
||||
// Radix point?
|
||||
else if ((c == character_set::Radix_Point1) || (c == character_set::Radix_Point2))
|
||||
else if ((c == Radix_Point1_Char) || (c == Radix_Point2_Char))
|
||||
{
|
||||
expecting_sign = false;
|
||||
state = Fractional;
|
||||
}
|
||||
// Exponential?
|
||||
else if (c == character_set::Exponential)
|
||||
else if (c == Exponential_Char)
|
||||
{
|
||||
expecting_sign = true;
|
||||
state = Exponential;
|
||||
}
|
||||
else if (character_set::is_valid(c, etl::radix::decimal))
|
||||
else if (is_valid(c, etl::radix::decimal))
|
||||
{
|
||||
const char digit = character_set::digit_value(c, etl::radix::decimal);
|
||||
const char digit = digit_value(c, etl::radix::decimal);
|
||||
floating_point_value *= 10;
|
||||
is_negative_mantissa ? floating_point_value -= digit : floating_point_value += digit;
|
||||
conversion_status = to_arithmetic_status::Valid;
|
||||
@ -548,20 +510,20 @@ namespace etl
|
||||
case Fractional:
|
||||
{
|
||||
// Radix point?
|
||||
if ((c == character_set::Radix_Point1) || (c == character_set::Radix_Point2))
|
||||
if ((c == Radix_Point1_Char) || (c == Radix_Point2_Char))
|
||||
{
|
||||
conversion_status = to_arithmetic_status::Invalid_Format;
|
||||
is_success = false;
|
||||
}
|
||||
// Exponential?
|
||||
else if (c == character_set::Exponential)
|
||||
else if (c == Exponential_Char)
|
||||
{
|
||||
expecting_sign = true;
|
||||
state = Exponential;
|
||||
}
|
||||
else if (character_set::is_valid(c, etl::radix::decimal))
|
||||
else if (is_valid(c, etl::radix::decimal))
|
||||
{
|
||||
const char digit = character_set::digit_value(c, etl::radix::decimal);
|
||||
const char digit = digit_value(c, etl::radix::decimal);
|
||||
divisor *= 10;
|
||||
long double fraction = digit / divisor;
|
||||
is_negative_mantissa ? floating_point_value -= fraction : floating_point_value += fraction;
|
||||
@ -578,20 +540,20 @@ namespace etl
|
||||
//***************************
|
||||
case Exponential:
|
||||
{
|
||||
if (expecting_sign && ((c == character_set::Positive_Char) || (c == character_set::Negative_Char)))
|
||||
if (expecting_sign && ((c == Positive_Char) || (c == Negative_Char)))
|
||||
{
|
||||
is_negative_exponent = (c == character_set::Negative_Char);
|
||||
is_negative_exponent = (c == Negative_Char);
|
||||
expecting_sign = false;
|
||||
}
|
||||
// Radix point?
|
||||
else if ((c == character_set::Radix_Point1) || (c == character_set::Radix_Point2) || (c == character_set::Exponential))
|
||||
else if ((c == Radix_Point1_Char) || (c == Radix_Point2_Char) || (c == Exponential_Char))
|
||||
{
|
||||
conversion_status = to_arithmetic_status::Invalid_Format;
|
||||
is_success = false;
|
||||
}
|
||||
else if (character_set::is_valid(c, etl::radix::decimal))
|
||||
else if (is_valid(c, etl::radix::decimal))
|
||||
{
|
||||
const char digit = character_set::digit_value(c, etl::radix::decimal);
|
||||
const char digit = digit_value(c, etl::radix::decimal);
|
||||
exponent_value *= etl::radix::decimal;
|
||||
is_negative_exponent ? exponent_value -= digit : exponent_value += digit;
|
||||
}
|
||||
@ -657,23 +619,46 @@ namespace etl
|
||||
|
||||
long double divisor;
|
||||
long double floating_point_value;
|
||||
bool is_negative_mantissa;
|
||||
bool is_negative_exponent;
|
||||
int exponent_value;
|
||||
to_arithmetic_status conversion_status;
|
||||
int state;
|
||||
bool is_negative_mantissa;
|
||||
bool is_negative_exponent;
|
||||
bool expecting_sign;
|
||||
int exponent_value;
|
||||
int state;
|
||||
to_arithmetic_status conversion_status;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
// Define an unsigned accumulator type that is at least as large as TValue.
|
||||
//***************************************************************************
|
||||
template <typename TValue>
|
||||
struct accumulator_type_select
|
||||
template <size_t Bits>
|
||||
struct accumulator_type_select;
|
||||
|
||||
template <>
|
||||
struct accumulator_type_select<8U>
|
||||
{
|
||||
typedef typename etl::smallest_uint_for_bits<etl::integral_limits<TValue>::bits>::type type;
|
||||
typedef uint32_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct accumulator_type_select<16U>
|
||||
{
|
||||
typedef uint32_t type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct accumulator_type_select<32U>
|
||||
{
|
||||
typedef uint32_t type;
|
||||
};
|
||||
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
template <>
|
||||
struct accumulator_type_select<64U>
|
||||
{
|
||||
typedef uint64_t type;
|
||||
};
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Text to integral from view, radix value and maximum.
|
||||
//***************************************************************************
|
||||
@ -686,8 +671,8 @@ namespace etl
|
||||
{
|
||||
etl::to_arithmetic_result<TAccumulatorType> accumulator_result;
|
||||
|
||||
etl::basic_string_view<TChar>::const_iterator itr = view.begin();
|
||||
const etl::basic_string_view<TChar>::const_iterator itr_end = view.end();
|
||||
typename etl::basic_string_view<TChar>::const_iterator itr = view.begin();
|
||||
const typename etl::basic_string_view<TChar>::const_iterator itr_end = view.end();
|
||||
|
||||
integral_accumulator<TAccumulatorType> accumulator(radix, maximum);
|
||||
|
||||
@ -721,44 +706,55 @@ namespace etl
|
||||
using namespace etl::private_to_arithmetic;
|
||||
|
||||
etl::to_arithmetic_result<TValue> result;
|
||||
|
||||
// Is this a negative number?
|
||||
const bool is_negative = check_and_remove_sign_prefix(view);
|
||||
|
||||
if (view.empty())
|
||||
if (is_valid_radix(radix))
|
||||
{
|
||||
result.status(to_arithmetic_status::Invalid_Format);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make sure we're not trying to put a negative value into an unsigned type.
|
||||
if (is_negative && etl::is_unsigned<TValue>::value)
|
||||
// Is this a negative number?
|
||||
const bool is_negative = check_and_remove_sign_prefix(view);
|
||||
|
||||
if (view.empty())
|
||||
{
|
||||
result.status(to_arithmetic_status::Signed_To_Unsigned);
|
||||
result.status(to_arithmetic_status::Invalid_Format);
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool is_decimal = (radix == etl::radix::decimal);
|
||||
|
||||
// What's the maximum absolute value for the type value we're trying to convert to?
|
||||
typedef typename accumulator_type_select<TValue>::type accumulator_type;
|
||||
|
||||
const accumulator_type maximum = is_negative ? etl::absolute_unsigned(etl::integral_limits<TValue>::min)
|
||||
: is_decimal ? etl::integral_limits<TValue>::max
|
||||
: etl::integral_limits<typename etl::make_unsigned<TValue>::type>::max;
|
||||
// Do the conversion.
|
||||
etl::to_arithmetic_result<accumulator_type> accumulator_result = to_arithmetic_integral<TChar>(view, radix, maximum);
|
||||
|
||||
result.status(accumulator_result.status());
|
||||
|
||||
// Was it successful?
|
||||
if (accumulator_result.has_value())
|
||||
// Make sure we're not trying to put a negative value into an unsigned type.
|
||||
if (is_negative && etl::is_unsigned<TValue>::value)
|
||||
{
|
||||
// Convert from the accumulator type to the desired type.
|
||||
result.value(is_negative ? static_cast<TValue>(0) - accumulator_result.value() : etl::bit_cast<TValue>(accumulator_result.value()));
|
||||
result.status(to_arithmetic_status::Signed_To_Unsigned);
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool is_decimal = (radix == etl::radix::decimal);
|
||||
|
||||
// Select the type we use for the accumulator.
|
||||
typedef typename accumulator_type_select<etl::integral_limits<TValue>::bits>::type accumulator_type;
|
||||
|
||||
// Find the maximum absolute value for the type value we're trying to convert to.
|
||||
const accumulator_type maximum = is_negative ? etl::absolute_unsigned(etl::integral_limits<TValue>::min)
|
||||
: is_decimal ? etl::integral_limits<TValue>::max
|
||||
: etl::integral_limits<typename etl::make_unsigned<TValue>::type>::max;
|
||||
// Do the conversion.
|
||||
etl::to_arithmetic_result<accumulator_type> accumulator_result = to_arithmetic_integral<TChar>(view, radix, maximum);
|
||||
|
||||
result.status(accumulator_result.status());
|
||||
|
||||
// Was it successful?
|
||||
if (accumulator_result.has_value())
|
||||
{
|
||||
typedef typename etl::make_unsigned<TValue>::type uvalue_t;
|
||||
const uvalue_t uvalue = static_cast<uvalue_t>(accumulator_result.value());
|
||||
|
||||
// Convert from the accumulator type to the desired type.
|
||||
result.value(is_negative ? static_cast<TValue>(0) - uvalue : etl::bit_cast<TValue>(uvalue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.status(to_arithmetic_status::Invalid_Radix);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -916,8 +912,8 @@ namespace etl
|
||||
{
|
||||
floating_point_accumulator accumulator;
|
||||
|
||||
etl::basic_string_view<TChar>::const_iterator itr = view.begin();
|
||||
etl::basic_string_view<TChar>::const_iterator itr_end = view.end();
|
||||
typename etl::basic_string_view<TChar>::const_iterator itr = view.begin();
|
||||
const typename etl::basic_string_view<TChar>::const_iterator itr_end = view.end();
|
||||
|
||||
while ((itr != itr_end) && accumulator.add(convert(*itr)))
|
||||
{
|
||||
@ -932,14 +928,16 @@ namespace etl
|
||||
TValue value = static_cast<TValue>(accumulator.value());
|
||||
int exponent = accumulator.exponent();
|
||||
|
||||
value *= pow(10.0, exponent);
|
||||
value *= pow(static_cast<TValue>(10.0), static_cast<TValue>(exponent));
|
||||
|
||||
// Check that the result is a valid floating point number.
|
||||
if (value == etl::numeric_limits<TValue>::infinity())
|
||||
if ((value == etl::numeric_limits<TValue>::infinity()) ||
|
||||
(value == -etl::numeric_limits<TValue>::infinity()))
|
||||
{
|
||||
result.status(to_arithmetic_status::Overflow);
|
||||
}
|
||||
else if (value == etl::numeric_limits<TValue>::quiet_NaN())
|
||||
// Check for NaN.
|
||||
else if (value != value)
|
||||
{
|
||||
result.status(to_arithmetic_status::Invalid_Float);
|
||||
}
|
||||
|
||||
@ -196,12 +196,31 @@ namespace
|
||||
SUITE(test_bit)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_bit_cast)
|
||||
TEST(test_bit_cast_integrals)
|
||||
{
|
||||
int32_t i = 0x12345678;
|
||||
uint32_t ui = etl::bit_cast<uint32_t>(i);
|
||||
int32_t i;
|
||||
uint32_t ui;
|
||||
|
||||
i = 0x12345678;
|
||||
ui = etl::bit_cast<uint32_t>(i);
|
||||
CHECK_EQUAL(i, ui);
|
||||
|
||||
i = -1234567890;
|
||||
ui = etl::bit_cast<uint32_t>(i);
|
||||
CHECK_EQUAL(i, static_cast<int32_t>(ui));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_bit_cast_different_types)
|
||||
{
|
||||
using Int = etl::smallest_int_for_bits_t<sizeof(float) * CHAR_BIT>;
|
||||
|
||||
Int i1;
|
||||
float f = 123.456789f;
|
||||
memcpy(&i1, &f, sizeof(float));
|
||||
|
||||
Int i2 = etl::bit_cast<Int>(f);
|
||||
CHECK_EQUAL(i1, i2);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -1,989 +0,0 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2019 John Wellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "unit_test_framework.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "etl/to_arithmetic.h"
|
||||
#include "etl/string.h"
|
||||
#include "etl/format_spec.h"
|
||||
|
||||
#undef STR
|
||||
#define STR(x) x
|
||||
|
||||
namespace
|
||||
{
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
std::ostream& operator <<(std::ostream& os, const etl::to_arithmetic_result<T>& result)
|
||||
{
|
||||
if (result.has_value())
|
||||
{
|
||||
os << result.value();
|
||||
}
|
||||
else
|
||||
{
|
||||
os << result.status().c_str();
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
typedef etl::format_spec Format;
|
||||
|
||||
SUITE(test_to_arithmetic)
|
||||
{
|
||||
//*************************************************************************
|
||||
TEST(test_invalid_radixes)
|
||||
{
|
||||
const std::string text("128");
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 0));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 1));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 3));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 4));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 5));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 6));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 7));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 9));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 11));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 12));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 13));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 14));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 15));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text.c_str(), text.size(), 17));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_invalid_binary_numerics)
|
||||
{
|
||||
const std::string text1(" 101");
|
||||
const std::string text2("101 ");
|
||||
const std::string text3("121");
|
||||
const std::string text4("");
|
||||
const std::string text5("-101");
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text1.c_str(), text1.size(), etl::bin));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text2.c_str(), text2.size(), etl::bin));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text3.c_str(), text3.size(), etl::bin));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text4.c_str(), text4.size(), etl::bin));
|
||||
CHECK(!etl::to_arithmetic<uint8_t>(text5.c_str(), text5.size(), etl::bin));
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<int8_t>(text1.c_str(), text1.size(), etl::bin).status());
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<int8_t>(text2.c_str(), text2.size(), etl::bin).status());
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<int8_t>(text3.c_str(), text3.size(), etl::bin).status());
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<int8_t>(text4.c_str(), text4.size(), etl::bin).status());
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Signed_To_Unsigned, etl::to_arithmetic<uint8_t>(text5.c_str(), text5.size(), etl::bin).status());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_valid_binary_numerics)
|
||||
{
|
||||
const std::string value1("0");
|
||||
const std::string value2("1");
|
||||
const std::string value3("0101");
|
||||
const std::string value4("1010");
|
||||
const std::string value5("01010011");
|
||||
const std::string value6("10101100");
|
||||
const std::string value7("-01010100");
|
||||
|
||||
CHECK_EQUAL(int(0), int(etl::to_arithmetic<int8_t>(value1.c_str(), value1.size(), etl::bin).value()));
|
||||
CHECK_EQUAL(int(1), int(etl::to_arithmetic<int8_t>(value2.c_str(), value2.size(), etl::bin).value()));
|
||||
CHECK_EQUAL(int(5), int(etl::to_arithmetic<int8_t>(value3.c_str(), value3.size(), etl::bin).value()));
|
||||
CHECK_EQUAL(int(10), int(etl::to_arithmetic<int8_t>(value4.c_str(), value4.size(), etl::bin).value()));
|
||||
CHECK_EQUAL(int(83), int(etl::to_arithmetic<int8_t>(value5.c_str(), value5.size(), etl::bin).value()));
|
||||
CHECK_EQUAL(int(-84), int(etl::to_arithmetic<int8_t>(value6.c_str(), value6.size(), etl::bin).value()));
|
||||
CHECK_EQUAL(int(-84), int(etl::to_arithmetic<int8_t>(value7.c_str(), value7.size(), etl::bin).value()));
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, int(etl::to_arithmetic<int8_t>(value1.c_str(), value1.size(), etl::bin).status()));
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, int(etl::to_arithmetic<int8_t>(value2.c_str(), value2.size(), etl::bin).status()));
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, int(etl::to_arithmetic<int8_t>(value3.c_str(), value3.size(), etl::bin).status()));
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, int(etl::to_arithmetic<int8_t>(value4.c_str(), value4.size(), etl::bin).status()));
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, int(etl::to_arithmetic<int8_t>(value5.c_str(), value5.size(), etl::bin).status()));
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, int(etl::to_arithmetic<int8_t>(value6.c_str(), value6.size(), etl::bin).status()));
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, int(etl::to_arithmetic<int8_t>(value7.c_str(), value7.size(), etl::bin).status()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_maximum_binary_numerics)
|
||||
{
|
||||
const std::string int8_max("01111111");
|
||||
const std::string int8_min_neg("-10000000");
|
||||
const std::string int8_min_2c("10000000");
|
||||
|
||||
const std::string uint8_max("11111111");
|
||||
const std::string uint8_min("00000000");
|
||||
|
||||
const std::string int16_max("0111111111111111");
|
||||
const std::string int16_min_neg("-1000000000000000");
|
||||
const std::string int16_min_2c("1000000000000000");
|
||||
|
||||
const std::string uint16_max("1111111111111111");
|
||||
const std::string uint16_min("0000000000000000");
|
||||
|
||||
const std::string int32_max("01111111111111111111111111111111");
|
||||
const std::string int32_min_neg("-10000000000000000000000000000000");
|
||||
const std::string int32_min_2c("10000000000000000000000000000000");
|
||||
|
||||
const std::string uint32_max("11111111111111111111111111111111");
|
||||
const std::string uint32_min("0");
|
||||
|
||||
const std::string int64_max("0111111111111111111111111111111111111111111111111111111111111111");
|
||||
const std::string int64_min_neg("-1000000000000000000000000000000000000000000000000000000000000000");
|
||||
const std::string int64_min_2c("1000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
const std::string uint64_max("1111111111111111111111111111111111111111111111111111111111111111");
|
||||
const std::string uint64_min("0");
|
||||
|
||||
CHECK_EQUAL(127, etl::to_arithmetic<int8_t>(int8_max.c_str(), int8_max.size(), etl::bin));
|
||||
CHECK_EQUAL(-128, etl::to_arithmetic<int8_t>(int8_min_neg.c_str(), int8_min_neg.size(), etl::bin));
|
||||
CHECK_EQUAL(-128, etl::to_arithmetic<int8_t>(int8_min_2c.c_str(), int8_min_2c.size(), etl::bin));
|
||||
|
||||
CHECK_EQUAL(255, etl::to_arithmetic<uint8_t>(uint8_max.c_str(), uint8_max.size(), etl::bin));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint8_t>(uint8_min.c_str(), uint8_min.size(), etl::bin));
|
||||
|
||||
CHECK_EQUAL(32767, etl::to_arithmetic<int16_t>(int16_max.c_str(), int16_max.size(), etl::bin));
|
||||
CHECK_EQUAL(-32768, etl::to_arithmetic<int16_t>(int16_min_neg.c_str(), int16_min_neg.size(), etl::bin));
|
||||
CHECK_EQUAL(-32768, etl::to_arithmetic<int16_t>(int16_min_2c.c_str(), int16_min_2c.size(), etl::bin));
|
||||
|
||||
CHECK_EQUAL(65535, etl::to_arithmetic<uint16_t>(uint16_max.c_str(), uint16_max.size(), etl::bin));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint16_t>(uint16_min.c_str(), uint16_min.size(), etl::bin));
|
||||
|
||||
CHECK_EQUAL(2147483647LL, etl::to_arithmetic<int32_t>(int32_max.c_str(), int32_max.size(), etl::bin));
|
||||
CHECK_EQUAL(-2147483648LL, etl::to_arithmetic<int32_t>(int32_min_neg.c_str(), int32_min_neg.size(), etl::bin));
|
||||
CHECK_EQUAL(-2147483648LL, etl::to_arithmetic<int32_t>(int32_min_2c.c_str(), int32_min_2c.size(), etl::bin));
|
||||
|
||||
CHECK_EQUAL(4294967295, etl::to_arithmetic<uint32_t>(uint32_max.c_str(), uint32_max.size(), etl::bin));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint32_t>(uint32_min.c_str(), uint32_min.size(), etl::bin));
|
||||
|
||||
CHECK_EQUAL(9223372036854775807LL, etl::to_arithmetic<int64_t>(int64_max.c_str(), int64_max.size(), etl::bin));
|
||||
CHECK_EQUAL(-9223372036854775808LL, etl::to_arithmetic<int64_t>(int64_min_neg.c_str(), int64_min_neg.size(), etl::bin));
|
||||
CHECK_EQUAL(-9223372036854775808LL, etl::to_arithmetic<int64_t>(int64_min_2c.c_str(), int64_min_2c.size(), etl::bin));
|
||||
|
||||
CHECK_EQUAL(18446744073709551615ULL, etl::to_arithmetic<uint64_t>(uint64_max.c_str(), uint64_max.size(), etl::bin));
|
||||
CHECK_EQUAL(0ULL, etl::to_arithmetic<uint64_t>(uint64_min.c_str(), uint64_min.size(), etl::bin));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_binary_numerics_overflow)
|
||||
{
|
||||
const std::string int8_overflow_max("100000000");
|
||||
const std::string int8_overflow_min("-100000000");
|
||||
|
||||
const std::string uint8_overflow_max("100000000");
|
||||
|
||||
const std::string int16_overflow_max("10000000000000000");
|
||||
const std::string int16_overflow_min("-10000000000000000");
|
||||
|
||||
const std::string uint16_overflow_max("10000000000000000");
|
||||
|
||||
const std::string int32_overflow_max("100000000000000000000000000000000");
|
||||
const std::string int32_overflow_min("-100000000000000000000000000000000");
|
||||
|
||||
const std::string uint32_overflow_max("100000000000000000000000000000000");
|
||||
|
||||
const std::string int64_overflow_max("10000000000000000000000000000000000000000000000000000000000000000");
|
||||
const std::string int64_overflow_min("-10000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
const std::string uint64_overflow_max("10000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_max.c_str(), int8_overflow_max.size(), etl::bin));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_min.c_str(), int8_overflow_min.size(), etl::bin));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint8_t>(uint8_overflow_max.c_str(), uint8_overflow_max.size(), etl::bin));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int16_t>(int16_overflow_max.c_str(), int16_overflow_max.size(), etl::bin));
|
||||
CHECK(!etl::to_arithmetic<int16_t>(int16_overflow_min.c_str(), int16_overflow_min.size(), etl::bin));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint16_t>(uint16_overflow_max.c_str(), uint16_overflow_max.size(), etl::bin));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int32_t>(int32_overflow_max.c_str(), int32_overflow_max.size(), etl::bin));
|
||||
CHECK(!etl::to_arithmetic<int32_t>(int32_overflow_min.c_str(), int32_overflow_min.size(), etl::bin));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint32_t>(uint32_overflow_max.c_str(), uint32_overflow_max.size(), etl::bin));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int64_t>(int64_overflow_max.c_str(), int64_overflow_max.size(), etl::bin));
|
||||
CHECK(!etl::to_arithmetic<int64_t>(int64_overflow_min.c_str(), int64_overflow_min.size(), etl::bin));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint64_t>(uint64_overflow_max.c_str(), uint64_overflow_max.size(), etl::bin));
|
||||
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<int8_t>(int8_overflow_max.c_str(), int8_overflow_max.size(), etl::bin).status());
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<int8_t>(int8_overflow_min.c_str(), int8_overflow_min.size(), etl::bin).status());
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<uint8_t>(uint8_overflow_max.c_str(), uint8_overflow_max.size(), etl::bin).status());
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<int16_t>(int16_overflow_max.c_str(), int16_overflow_max.size(), etl::bin).status());
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<int16_t>(int16_overflow_min.c_str(), int16_overflow_min.size(), etl::bin).status());
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<uint16_t>(uint16_overflow_max.c_str(), uint16_overflow_max.size(), etl::bin).status());
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<int32_t>(int32_overflow_max.c_str(), int32_overflow_max.size(), etl::bin).status());
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<int32_t>(int32_overflow_min.c_str(), int32_overflow_min.size(), etl::bin).status());
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<uint32_t>(uint32_overflow_max.c_str(), uint32_overflow_max.size(), etl::bin).status());
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<int64_t>(int64_overflow_max.c_str(), int64_overflow_max.size(), etl::bin).status());
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<int64_t>(int64_overflow_min.c_str(), int64_overflow_min.size(), etl::bin).status());
|
||||
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<uint64_t>(uint64_overflow_max.c_str(), uint64_overflow_max.size(), etl::bin).status());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_invalid_octal_numerics)
|
||||
{
|
||||
const std::string text1(" 127");
|
||||
const std::string text2("127 ");
|
||||
const std::string text3("187");
|
||||
const std::string text4("-187");
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text1.c_str(), text1.size(), etl::oct));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text2.c_str(), text2.size(), etl::oct));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text3.c_str(), text3.size(), etl::oct));
|
||||
CHECK(!etl::to_arithmetic<uint8_t>(text4.c_str(), text4.size(), etl::oct));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_valid_octal_numerics)
|
||||
{
|
||||
const std::string value1("0");
|
||||
const std::string value2("01");
|
||||
const std::string value3("05");
|
||||
const std::string value4("012");
|
||||
const std::string value5("0123");
|
||||
const std::string value6("0254");
|
||||
const std::string value7("-0124");
|
||||
|
||||
CHECK_EQUAL(int(0), int(etl::to_arithmetic<int8_t>(value1.c_str(), value1.size(), etl::oct).value()));
|
||||
CHECK_EQUAL(int(1), int(etl::to_arithmetic<int8_t>(value2.c_str(), value2.size(), etl::oct).value()));
|
||||
CHECK_EQUAL(int(5), int(etl::to_arithmetic<int8_t>(value3.c_str(), value3.size(), etl::oct).value()));
|
||||
CHECK_EQUAL(int(10), int(etl::to_arithmetic<int8_t>(value4.c_str(), value4.size(), etl::oct).value()));
|
||||
CHECK_EQUAL(int(83), int(etl::to_arithmetic<int8_t>(value5.c_str(), value5.size(), etl::oct).value()));
|
||||
CHECK_EQUAL(int(-84), int(etl::to_arithmetic<int8_t>(value6.c_str(), value6.size(), etl::oct).value()));
|
||||
CHECK_EQUAL(int(-84), int(etl::to_arithmetic<int8_t>(value7.c_str(), value7.size(), etl::oct).value()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_maximum_octal_numerics)
|
||||
{
|
||||
const std::string int8_max("177");
|
||||
const std::string int8_min_neg("-200");
|
||||
const std::string int8_min_2c("200");
|
||||
|
||||
const std::string uint8_max("377");
|
||||
const std::string uint8_min("0");
|
||||
|
||||
const std::string int16_max("77777");
|
||||
const std::string int16_min_neg("-100000");
|
||||
const std::string int16_min_2c("100000");
|
||||
|
||||
const std::string uint16_max("177777");
|
||||
const std::string uint16_min("0");
|
||||
|
||||
const std::string int32_max("17777777777");
|
||||
const std::string int32_min_neg("-20000000000");
|
||||
const std::string int32_min_2c("20000000000");
|
||||
|
||||
const std::string uint32_max("37777777777");
|
||||
const std::string uint32_min("0");
|
||||
|
||||
const std::string int64_max("777777777777777777777");
|
||||
const std::string int64_min_neg("-1000000000000000000000");
|
||||
const std::string int64_min_2c("1000000000000000000000");
|
||||
|
||||
const std::string uint64_max("1777777777777777777777");
|
||||
const std::string uint64_min("0");
|
||||
|
||||
CHECK_EQUAL(127, etl::to_arithmetic<int8_t>(int8_max.c_str(), int8_max.size(), etl::oct));
|
||||
CHECK_EQUAL(-128, etl::to_arithmetic<int8_t>(int8_min_neg.c_str(), int8_min_neg.size(), etl::oct));
|
||||
CHECK_EQUAL(-128, etl::to_arithmetic<int8_t>(int8_min_2c.c_str(), int8_min_2c.size(), etl::oct));
|
||||
|
||||
CHECK_EQUAL(255, etl::to_arithmetic<uint8_t>(uint8_max.c_str(), uint8_max.size(), etl::oct));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint8_t>(uint8_min.c_str(), uint8_min.size(), etl::oct));
|
||||
|
||||
CHECK_EQUAL(32767, etl::to_arithmetic<int16_t>(int16_max.c_str(), int16_max.size(), etl::oct));
|
||||
CHECK_EQUAL(-32768, etl::to_arithmetic<int16_t>(int16_min_neg.c_str(), int16_min_neg.size(), etl::oct));
|
||||
CHECK_EQUAL(-32768, etl::to_arithmetic<int16_t>(int16_min_2c.c_str(), int16_min_2c.size(), etl::oct));
|
||||
|
||||
CHECK_EQUAL(65535, etl::to_arithmetic<uint16_t>(uint16_max.c_str(), uint16_max.size(), etl::oct));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint16_t>(uint16_min.c_str(), uint16_min.size(), etl::oct));
|
||||
|
||||
CHECK_EQUAL(2147483647LL, etl::to_arithmetic<int32_t>(int32_max.c_str(), int32_max.size(), etl::oct));
|
||||
CHECK_EQUAL(-2147483648LL, etl::to_arithmetic<int32_t>(int32_min_neg.c_str(), int32_min_neg.size(), etl::oct));
|
||||
CHECK_EQUAL(-2147483648LL, etl::to_arithmetic<int32_t>(int32_min_2c.c_str(), int32_min_2c.size(), etl::oct));
|
||||
|
||||
CHECK_EQUAL(4294967295, etl::to_arithmetic<uint32_t>(uint32_max.c_str(), uint32_max.size(), etl::oct));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint32_t>(uint32_min.c_str(), uint32_min.size(), etl::oct));
|
||||
|
||||
CHECK_EQUAL(9223372036854775807LL, etl::to_arithmetic<int64_t>(int64_max.c_str(), int64_max.size(), etl::oct));
|
||||
CHECK_EQUAL(-9223372036854775808LL, etl::to_arithmetic<int64_t>(int64_min_neg.c_str(), int64_min_neg.size(), etl::oct));
|
||||
CHECK_EQUAL(-9223372036854775808LL, etl::to_arithmetic<int64_t>(int64_min_2c.c_str(), int64_min_2c.size(), etl::oct));
|
||||
|
||||
CHECK_EQUAL(18446744073709551615ULL, etl::to_arithmetic<uint64_t>(uint64_max.c_str(), uint64_max.size(), etl::oct));
|
||||
CHECK_EQUAL(0ULL, etl::to_arithmetic<uint64_t>(uint64_min.c_str(), uint64_min.size(), etl::oct));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_octal_numerics_overflow)
|
||||
{
|
||||
const std::string int8_overflow_max("400");
|
||||
const std::string int8_overflow_min("-400");
|
||||
|
||||
const std::string uint8_overflow_max("400");
|
||||
|
||||
const std::string int16_overflow_max("200000");
|
||||
const std::string int16_overflow_min("-200000");
|
||||
|
||||
const std::string uint16_overflow_max("200000");
|
||||
|
||||
const std::string int32_overflow_max("40000000000");
|
||||
const std::string int32_overflow_min("-40000000000");
|
||||
|
||||
const std::string uint32_overflow_max("40000000000");
|
||||
|
||||
const std::string int64_overflow_max("2000000000000000000000");
|
||||
const std::string int64_overflow_min("-2000000000000000000000");
|
||||
|
||||
const std::string uint64_overflow_max("2000000000000000000000");
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_max.c_str(), int8_overflow_max.size(), etl::oct));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_min.c_str(), int8_overflow_min.size(), etl::oct));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint8_t>(uint8_overflow_max.c_str(), uint8_overflow_max.size(), etl::oct));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int16_t>(int16_overflow_max.c_str(), int16_overflow_max.size(), etl::oct));
|
||||
CHECK(!etl::to_arithmetic<int16_t>(int16_overflow_min.c_str(), int16_overflow_min.size(), etl::oct));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint16_t>(uint16_overflow_max.c_str(), uint16_overflow_max.size(), etl::oct));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int32_t>(int32_overflow_max.c_str(), int32_overflow_max.size(), etl::oct));
|
||||
CHECK(!etl::to_arithmetic<int32_t>(int32_overflow_min.c_str(), int32_overflow_min.size(), etl::oct));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint32_t>(uint32_overflow_max.c_str(), uint32_overflow_max.size(), etl::oct));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int64_t>(int64_overflow_max.c_str(), int64_overflow_max.size(), etl::oct));
|
||||
CHECK(!etl::to_arithmetic<int64_t>(int64_overflow_min.c_str(), int64_overflow_min.size(), etl::oct));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint64_t>(uint64_overflow_max.c_str(), uint64_overflow_max.size(), etl::oct));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_invalid_decimal_numerics)
|
||||
{
|
||||
const std::string text1(" 128");
|
||||
const std::string text2("128 ");
|
||||
const std::string text3("1A8");
|
||||
const std::string text4("++128");
|
||||
const std::string text5("-+128");
|
||||
const std::string text6("+-128");
|
||||
const std::string text7("--128");
|
||||
const std::string text8("+");
|
||||
const std::string text9("-");
|
||||
const std::string text10("");
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text1.c_str(), text1.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text2.c_str(), text2.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text3.c_str(), text3.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text4.c_str(), text4.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text5.c_str(), text5.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text6.c_str(), text6.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text7.c_str(), text7.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text8.c_str(), text8.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text9.c_str(), text9.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text10.c_str(), text10.size(), etl::dec));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_valid_decimal_numerics)
|
||||
{
|
||||
const std::string text1("0");
|
||||
const std::string text2("1");
|
||||
const std::string text3("5");
|
||||
const std::string text4("+10");
|
||||
const std::string text5("83");
|
||||
const std::string text6("-84");
|
||||
|
||||
CHECK_EQUAL(int(0), int(etl::to_arithmetic<int8_t>(text1.c_str(), text1.size(), etl::dec).value()));
|
||||
CHECK_EQUAL(int(1), int(etl::to_arithmetic<int8_t>(text2.c_str(), text2.size(), etl::dec).value()));
|
||||
CHECK_EQUAL(int(5), int(etl::to_arithmetic<int8_t>(text3.c_str(), text3.size(), etl::dec).value()));
|
||||
CHECK_EQUAL(int(10), int(etl::to_arithmetic<int8_t>(text4.c_str(), text4.size(), etl::dec).value()));
|
||||
CHECK_EQUAL(int(83), int(etl::to_arithmetic<int8_t>(text5.c_str(), text5.size(), etl::dec).value()));
|
||||
CHECK_EQUAL(int(83), int(etl::to_arithmetic<uint8_t>(text5.c_str(), text5.size(), etl::dec).value()));
|
||||
CHECK_EQUAL(int(-84), int(etl::to_arithmetic<int8_t>(text6.c_str(), text6.size(), etl::dec).value()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_maximum_decimal_numerics)
|
||||
{
|
||||
const std::string int8_max("127");
|
||||
const std::string int8_min("-128");
|
||||
|
||||
const std::string uint8_max("255");
|
||||
const std::string uint8_min("0");
|
||||
|
||||
const std::string int16_max("32767");
|
||||
const std::string int16_min("-32768");
|
||||
|
||||
const std::string uint16_max("65535");
|
||||
const std::string uint16_min("0");
|
||||
|
||||
const std::string int32_max("2147483647");
|
||||
const std::string int32_min("-2147483648");
|
||||
|
||||
const std::string uint32_max("4294967295");
|
||||
const std::string uint32_min("0");
|
||||
|
||||
const std::string int64_max("9223372036854775807");
|
||||
const std::string int64_min("-9223372036854775808");
|
||||
|
||||
const std::string uint64_max("18446744073709551615");
|
||||
const std::string uint64_min("0");
|
||||
|
||||
CHECK_EQUAL( 127, etl::to_arithmetic<int8_t>(int8_max.c_str(), int8_max.size(), etl::dec));
|
||||
CHECK_EQUAL(-128, etl::to_arithmetic<int8_t>(int8_min.c_str(), int8_min.size(), etl::dec));
|
||||
|
||||
CHECK_EQUAL(255, etl::to_arithmetic<uint8_t>(uint8_max.c_str(), uint8_max.size(), etl::dec));
|
||||
CHECK_EQUAL( 0, etl::to_arithmetic<uint8_t>(uint8_min.c_str(), uint8_min.size(), etl::dec));
|
||||
|
||||
CHECK_EQUAL( 32767, etl::to_arithmetic<int16_t>(int16_max.c_str(), int16_max.size(), etl::dec));
|
||||
CHECK_EQUAL(-32768, etl::to_arithmetic<int16_t>(int16_min.c_str(), int16_min.size(), etl::dec));
|
||||
|
||||
CHECK_EQUAL(65535, etl::to_arithmetic<uint16_t>(uint16_max.c_str(), uint16_max.size(), etl::dec));
|
||||
CHECK_EQUAL( 0, etl::to_arithmetic<uint16_t>(uint16_min.c_str(), uint16_min.size(), etl::dec));
|
||||
|
||||
CHECK_EQUAL( 2147483647LL, etl::to_arithmetic<int32_t>(int32_max.c_str(), int32_max.size(), etl::dec));
|
||||
CHECK_EQUAL(-2147483648LL, etl::to_arithmetic<int32_t>(int32_min.c_str(), int32_min.size(), etl::dec));
|
||||
|
||||
CHECK_EQUAL(4294967295ULL, etl::to_arithmetic<uint32_t>(uint32_max.c_str(), uint32_max.size(), etl::dec));
|
||||
CHECK_EQUAL( 0ULL, etl::to_arithmetic<uint32_t>(uint32_min.c_str(), uint32_min.size(), etl::dec));
|
||||
|
||||
CHECK_EQUAL( 9223372036854775807LL, etl::to_arithmetic<int64_t>(int64_max.c_str(), int64_max.size(), etl::dec));
|
||||
CHECK_EQUAL(-9223372036854775808LL, etl::to_arithmetic<int64_t>(int64_min.c_str(), int64_min.size(), etl::dec));
|
||||
|
||||
CHECK_EQUAL(18446744073709551615ULL, etl::to_arithmetic<uint64_t>(uint64_max.c_str(), uint64_max.size(), etl::dec));
|
||||
CHECK_EQUAL( 0ULL, etl::to_arithmetic<uint64_t>(uint64_min.c_str(), uint64_min.size(), etl::dec));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_decimal_numerics_overflow)
|
||||
{
|
||||
const std::string int8_overflow_max("128");
|
||||
const std::string int8_overflow_min("-129");
|
||||
|
||||
const std::string int8_overflow_max_plus("1000");
|
||||
const std::string int8_overflow_min_plus("-1000");
|
||||
|
||||
const std::string uint8_overflow_max("256");
|
||||
|
||||
const std::string int16_overflow_max("32768");
|
||||
const std::string int16_overflow_min("-32769");
|
||||
|
||||
const std::string uint16_overflow_max("65536");
|
||||
|
||||
const std::string int32_overflow_max("2147483648");
|
||||
const std::string int32_overflow_min("-2147483649");
|
||||
|
||||
const std::string uint32_overflow_max("4294967296");
|
||||
|
||||
const std::string int64_overflow_max("9223372036854775808");
|
||||
const std::string int64_overflow_min("-9223372036854775809");
|
||||
|
||||
const std::string uint64_overflow_max("18446744073709551616");
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_max.c_str(), int8_overflow_max.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_min.c_str(), int8_overflow_min.size(), etl::dec));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_max_plus.c_str(), int8_overflow_max_plus.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_min_plus.c_str(), int8_overflow_min_plus.size(), etl::dec));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint8_t>(uint8_overflow_max.c_str(), uint8_overflow_max.size(), etl::dec));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int16_t>(int16_overflow_max.c_str(), int16_overflow_max.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int16_t>(int16_overflow_min.c_str(), int16_overflow_min.size(), etl::dec));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint16_t>(uint16_overflow_max.c_str(), uint16_overflow_max.size(), etl::dec));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int32_t>(int32_overflow_max.c_str(), int32_overflow_max.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int32_t>(int32_overflow_min.c_str(), int32_overflow_min.size(), etl::dec));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint32_t>(uint32_overflow_max.c_str(), uint32_overflow_max.size(), etl::dec));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int64_t>(int64_overflow_max.c_str(), int64_overflow_max.size(), etl::dec));
|
||||
CHECK(!etl::to_arithmetic<int64_t>(int64_overflow_min.c_str(), int64_overflow_min.size(), etl::dec));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint64_t>(uint64_overflow_max.c_str(), uint64_overflow_max.size(), etl::dec));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_invalid_hex_numerics)
|
||||
{
|
||||
const std::string text1(" 1Af");
|
||||
const std::string text2("1Af ");
|
||||
const std::string text3("1Gf");
|
||||
const std::string text4("-1Af");
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text1.c_str(), text1.size(), etl::hex));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text2.c_str(), text2.size(), etl::hex));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(text3.c_str(), text3.size(), etl::hex));
|
||||
CHECK(!etl::to_arithmetic<uint8_t>(text4.c_str(), text4.size(), etl::hex));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_valid_hex_numerics)
|
||||
{
|
||||
const std::string text1("0");
|
||||
const std::string text2("1");
|
||||
const std::string text3("5");
|
||||
const std::string text4("a");
|
||||
const std::string text5("53");
|
||||
const std::string text6("Ac");
|
||||
const std::string text7("-54");
|
||||
|
||||
CHECK_EQUAL(int(0), int(etl::to_arithmetic<int8_t>(text1.c_str(), text1.size(), etl::hex).value()));
|
||||
CHECK_EQUAL(int(1), int(etl::to_arithmetic<int8_t>(text2.c_str(), text2.size(), etl::hex).value()));
|
||||
CHECK_EQUAL(int(5), int(etl::to_arithmetic<int8_t>(text3.c_str(), text3.size(), etl::hex).value()));
|
||||
CHECK_EQUAL(int(10), int(etl::to_arithmetic<int8_t>(text4.c_str(), text4.size(), etl::hex).value()));
|
||||
CHECK_EQUAL(int(83), int(etl::to_arithmetic<int8_t>(text5.c_str(), text5.size(), etl::hex).value()));
|
||||
CHECK_EQUAL(int(-84), int(etl::to_arithmetic<int8_t>(text6.c_str(), text6.size(), etl::hex).value()));
|
||||
CHECK_EQUAL(int(-84), int(etl::to_arithmetic<int8_t>(text7.c_str(), text7.size(), etl::hex).value()));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_maximum_hex_numerics)
|
||||
{
|
||||
const std::string int8_max("7F");
|
||||
const std::string int8_min_neg("-80");
|
||||
const std::string int8_min_2c("80");
|
||||
|
||||
const std::string uint8_max("FF");
|
||||
const std::string uint8_min("0");
|
||||
|
||||
const std::string int16_max("7FFF");
|
||||
const std::string int16_min_neg("-8000");
|
||||
const std::string int16_min_2c("8000");
|
||||
|
||||
const std::string uint16_max("FFFF");
|
||||
const std::string uint16_min("0");
|
||||
|
||||
const std::string int32_max("7FFFFFFF");
|
||||
const std::string int32_min_neg("-80000000");
|
||||
const std::string int32_min_2c("80000000");
|
||||
|
||||
const std::string uint32_max("FFFFFFFF");
|
||||
const std::string uint32_min("0");
|
||||
|
||||
const std::string int64_max("7FFFFFFFFFFFFFFF");
|
||||
const std::string int64_min_neg("-8000000000000000");
|
||||
const std::string int64_min_2c("8000000000000000");
|
||||
|
||||
const std::string uint64_max("FFFFFFFFFFFFFFFF");
|
||||
const std::string uint64_min("0");
|
||||
|
||||
CHECK_EQUAL(127, etl::to_arithmetic<int8_t>(int8_max.c_str(), int8_max.size(), etl::hex));
|
||||
CHECK_EQUAL(-128, etl::to_arithmetic<int8_t>(int8_min_neg.c_str(), int8_min_neg.size(), etl::hex));
|
||||
CHECK_EQUAL(-128, etl::to_arithmetic<int8_t>(int8_min_2c.c_str(), int8_min_2c.size(), etl::hex));
|
||||
|
||||
CHECK_EQUAL(255, etl::to_arithmetic<uint8_t>(uint8_max.c_str(), uint8_max.size(), etl::hex));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint8_t>(uint8_min.c_str(), uint8_min.size(), etl::hex));
|
||||
|
||||
CHECK_EQUAL(32767, etl::to_arithmetic<int16_t>(int16_max.c_str(), int16_max.size(), etl::hex));
|
||||
CHECK_EQUAL(-32768, etl::to_arithmetic<int16_t>(int16_min_neg.c_str(), int16_min_neg.size(), etl::hex));
|
||||
CHECK_EQUAL(-32768, etl::to_arithmetic<int16_t>(int16_min_2c.c_str(), int16_min_2c.size(), etl::hex));
|
||||
|
||||
CHECK_EQUAL(65535, etl::to_arithmetic<uint16_t>(uint16_max.c_str(), uint16_max.size(), etl::hex));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint16_t>(uint16_min.c_str(), uint16_min.size(), etl::hex));
|
||||
|
||||
CHECK_EQUAL(2147483647LL, etl::to_arithmetic<int32_t>(int32_max.c_str(), int32_max.size(), etl::hex));
|
||||
CHECK_EQUAL(-2147483648LL, etl::to_arithmetic<int32_t>(int32_min_neg.c_str(), int32_min_neg.size(), etl::hex));
|
||||
CHECK_EQUAL(-2147483648LL, etl::to_arithmetic<int32_t>(int32_min_2c.c_str(), int32_min_2c.size(), etl::hex));
|
||||
|
||||
CHECK_EQUAL(4294967295, etl::to_arithmetic<uint32_t>(uint32_max.c_str(), uint32_max.size(), etl::hex));
|
||||
CHECK_EQUAL(0, etl::to_arithmetic<uint32_t>(uint32_min.c_str(), uint32_min.size(), etl::hex));
|
||||
|
||||
CHECK_EQUAL(9223372036854775807LL, etl::to_arithmetic<int64_t>(int64_max.c_str(), int64_max.size(), etl::hex));
|
||||
CHECK_EQUAL(-9223372036854775808LL, etl::to_arithmetic<int64_t>(int64_min_neg.c_str(), int64_min_neg.size(), etl::hex));
|
||||
CHECK_EQUAL(-9223372036854775808LL, etl::to_arithmetic<int64_t>(int64_min_2c.c_str(), int64_min_2c.size(), etl::hex));
|
||||
|
||||
CHECK_EQUAL(18446744073709551615ULL, etl::to_arithmetic<uint64_t>(uint64_max.c_str(), uint64_max.size(), etl::hex));
|
||||
CHECK_EQUAL(0ULL, etl::to_arithmetic<uint64_t>(uint64_min.c_str(), uint64_min.size(), etl::hex));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_hex_numerics_overflow)
|
||||
{
|
||||
const std::string int8_overflow_max("100");
|
||||
const std::string int8_overflow_min("-100");
|
||||
|
||||
const std::string uint8_overflow_max("100");
|
||||
|
||||
const std::string int16_overflow_max("10000");
|
||||
const std::string int16_overflow_min("-10000");
|
||||
|
||||
const std::string uint16_overflow_max("10000");
|
||||
|
||||
const std::string int32_overflow_max("100000000");
|
||||
const std::string int32_overflow_min("-100000000");
|
||||
|
||||
const std::string uint32_overflow_max("100000000");
|
||||
|
||||
const std::string int64_overflow_max("10000000000000000");
|
||||
const std::string int64_overflow_min("-10000000000000000");
|
||||
|
||||
const std::string uint64_overflow_max("10000000000000000");
|
||||
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_max.c_str(), int8_overflow_max.size(), etl::hex));
|
||||
CHECK(!etl::to_arithmetic<int8_t>(int8_overflow_min.c_str(), int8_overflow_min.size(), etl::hex));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint8_t>(uint8_overflow_max.c_str(), uint8_overflow_max.size(), etl::hex));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int16_t>(int16_overflow_max.c_str(), int16_overflow_max.size(), etl::hex));
|
||||
CHECK(!etl::to_arithmetic<int16_t>(int16_overflow_min.c_str(), int16_overflow_min.size(), etl::hex));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint16_t>(uint16_overflow_max.c_str(), uint16_overflow_max.size(), etl::hex));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int32_t>(int32_overflow_max.c_str(), int32_overflow_max.size(), etl::hex));
|
||||
CHECK(!etl::to_arithmetic<int32_t>(int32_overflow_min.c_str(), int32_overflow_min.size(), etl::hex));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint32_t>(uint32_overflow_max.c_str(), uint32_overflow_max.size(), etl::hex));
|
||||
|
||||
CHECK(!etl::to_arithmetic<int64_t>(int64_overflow_max.c_str(), int64_overflow_max.size(), etl::hex));
|
||||
CHECK(!etl::to_arithmetic<int64_t>(int64_overflow_min.c_str(), int64_overflow_min.size(), etl::hex));
|
||||
|
||||
CHECK(!etl::to_arithmetic<uint64_t>(uint64_overflow_max.c_str(), uint64_overflow_max.size(), etl::hex));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_valid_float)
|
||||
{
|
||||
std::string text;
|
||||
|
||||
//*********************************
|
||||
text = "-123.456789";
|
||||
|
||||
float f1 = strtof(text.c_str(), nullptr);
|
||||
float f2 = etl::to_arithmetic<float>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.456789";
|
||||
|
||||
f1 = strtof(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<float>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-1.23456789e2";
|
||||
|
||||
f1 = strtof(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<float>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-12345.6789e-2";
|
||||
|
||||
f1 = strtof(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<float>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "+12345E-2";
|
||||
|
||||
f1 = strtof(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<float>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "+12345.6789E000";
|
||||
|
||||
f1 = strtof(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<float>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_invalid_float)
|
||||
{
|
||||
std::string text;
|
||||
|
||||
//*********************************
|
||||
text = " -123.456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-123.456789 ";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-12A.456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-123.456A89";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.-456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123E.45";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.45E1000";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<float>(text.c_str(), text.size()).status());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_valid_double)
|
||||
{
|
||||
std::string text;
|
||||
|
||||
//*********************************
|
||||
text = "-123.45678901234567";
|
||||
|
||||
double f1 = strtod(text.c_str(), nullptr);
|
||||
double f2 = etl::to_arithmetic<double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.45678901234567";
|
||||
|
||||
f1 = strtod(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-1.2345678901234567e2";
|
||||
|
||||
f1 = strtod(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-12345.678901234567e-2";
|
||||
|
||||
f1 = strtod(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "+12345E-2";
|
||||
|
||||
f1 = strtod(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "+12345.678901234567E0";
|
||||
|
||||
f1 = strtod(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_invalid_double)
|
||||
{
|
||||
std::string text;
|
||||
|
||||
//*********************************
|
||||
text = " -123.456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-123.456789 ";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-12A.456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-123.456A89";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.-456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123E.45";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.45E1000";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_valid_long_double)
|
||||
{
|
||||
std::string text;
|
||||
|
||||
//*********************************
|
||||
text = "-123.45678901234567";
|
||||
|
||||
long double f1 = strtold(text.c_str(), nullptr);
|
||||
long double f2 = etl::to_arithmetic<long double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.45678901234567";
|
||||
|
||||
f1 = strtold(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<long double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-1.2345678901234567e2";
|
||||
|
||||
f1 = strtold(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<long double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-12345.678901234567e-2";
|
||||
|
||||
f1 = strtold(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<long double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "+12345E-2";
|
||||
|
||||
f1 = strtold(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<long double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "+12345.678901234567E000";
|
||||
|
||||
f1 = strtold(text.c_str(), nullptr);
|
||||
f2 = etl::to_arithmetic<long double>(text.c_str(), text.size()).value();
|
||||
|
||||
CHECK_CLOSE(f1, f2, 0.00001);
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Valid, etl::to_arithmetic<double>(text.c_str(), text.size()).status());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_invalid_long_double)
|
||||
{
|
||||
std::string text;
|
||||
|
||||
//*********************************
|
||||
text = " -123.456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<long double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-123.456789 ";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<long double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-12A.456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<long double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "-123.456A89";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<long double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.-456789";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<long double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123E.45";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Invalid_Format, etl::to_arithmetic<long double>(text.c_str(), text.size()).status());
|
||||
|
||||
//*********************************
|
||||
text = "123.45E1000";
|
||||
CHECK_EQUAL(etl::to_arithmetic_status::Overflow, etl::to_arithmetic<long double>(text.c_str(), text.size()).status());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constexpr_integral)
|
||||
{
|
||||
// constexpr const char* text{ "123" };
|
||||
// constexpr etl::string_view view(text, 3);
|
||||
|
||||
// constexpr etl::optional<int> opt = etl::to_arithmetic<int>(view, etl::radix::decimal);
|
||||
// constexpr int i = opt.value();
|
||||
|
||||
// CHECK_EQUAL(123, i);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_constexpr_floating_point)
|
||||
{
|
||||
//constexpr const char* text{ "123.456789" };
|
||||
//constexpr etl::string_view view(text, 3);
|
||||
|
||||
//constexpr etl::optional<double> opt = etl::to_arithmetic<double>(view);
|
||||
//constexpr double i = opt.value();
|
||||
|
||||
//CHECK_EQUAL(123, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1020
test/test_to_arithmetic.cpp
Normal file
1020
test/test_to_arithmetic.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1020
test/test_to_arithmetic_u16.cpp
Normal file
1020
test/test_to_arithmetic_u16.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1020
test/test_to_arithmetic_u32.cpp
Normal file
1020
test/test_to_arithmetic_u32.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1020
test/test_to_arithmetic_wchar_t.cpp
Normal file
1020
test/test_to_arithmetic_wchar_t.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -10195,6 +10195,34 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\to_arithmetic.h.t.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Small Strings|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC C++20 - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='MSVC Debug - No STL - Appveyor|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Constexpr Algorithms|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM C++20|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No Unit Tests|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug LLVM - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug64|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - String Truncation Is Error|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Clang|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug - No STL - Force No Advanced|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force cpp03|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Intel - No STL|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Intel|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No Checks|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - Force C++03|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\to_string.h.t.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug MSVC - No STL - Force Built-ins|Win32'">true</ExcludedFromBuild>
|
||||
@ -12108,7 +12136,6 @@
|
||||
<ClCompile Include="..\test_state_chart_compile_time_with_data_parameter.cpp" />
|
||||
<ClCompile Include="..\test_state_chart_with_data_parameter.cpp" />
|
||||
<ClCompile Include="..\test_state_chart_with_rvalue_data_parameter.cpp" />
|
||||
<ClCompile Include="..\test_string_to_arithmetic.cpp" />
|
||||
<ClCompile Include="..\test_string_utilities_std.cpp" />
|
||||
<ClCompile Include="..\test_string_char.cpp" />
|
||||
<ClCompile Include="..\test_string_char_external_buffer.cpp" />
|
||||
@ -12130,6 +12157,10 @@
|
||||
<ClCompile Include="..\test_successor.cpp" />
|
||||
<ClCompile Include="..\test_task_scheduler.cpp" />
|
||||
<ClCompile Include="..\test_threshold.cpp" />
|
||||
<ClCompile Include="..\test_to_arithmetic.cpp" />
|
||||
<ClCompile Include="..\test_to_arithmetic_u16.cpp" />
|
||||
<ClCompile Include="..\test_to_arithmetic_u32.cpp" />
|
||||
<ClCompile Include="..\test_to_arithmetic_wchar_t.cpp" />
|
||||
<ClCompile Include="..\test_to_string.cpp" />
|
||||
<ClCompile Include="..\test_to_u16string.cpp" />
|
||||
<ClCompile Include="..\test_to_u32string.cpp" />
|
||||
|
||||
@ -3374,9 +3374,21 @@
|
||||
<ClCompile Include="..\test_bitset_new_ext_explicit_single_element_type.cpp">
|
||||
<Filter>Tests\Binary</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_string_to_arithmetic.cpp">
|
||||
<ClCompile Include="..\test_to_arithmetic_wchar_t.cpp">
|
||||
<Filter>Tests\Strings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_to_arithmetic.cpp">
|
||||
<Filter>Tests\Strings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_to_arithmetic_u16.cpp">
|
||||
<Filter>Tests\Strings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_to_arithmetic_u32.cpp">
|
||||
<Filter>Tests\Strings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\to_arithmetic.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks\Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\library.properties">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user