mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 18:20:26 +01:00
This reverts commit b1823b61c0
.
This commit is contained in:
parent
bbe09e48d1
commit
674446d44d
@ -59,13 +59,13 @@ public:
|
||||
/// right justified and zero-padded in a field
|
||||
/// having at least the specified width.
|
||||
|
||||
static std::string formatHex(int value, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(int value, bool prefix = false);
|
||||
/// Formats an int value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static std::string formatHex(int value, int width, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(int value, int width, bool prefix = false);
|
||||
/// Formats a int value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
@ -86,12 +86,12 @@ public:
|
||||
/// right justified and zero-padded in a field having at
|
||||
/// least the specified width.
|
||||
|
||||
static std::string formatHex(unsigned value, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(unsigned value, bool prefix = false);
|
||||
/// Formats an unsigned int value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
static std::string formatHex(unsigned value, int width, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(unsigned value, int width, bool prefix = false);
|
||||
/// Formats a int value in hexadecimal notation,
|
||||
/// right justified and zero-padded in
|
||||
/// a field having at least the specified width.
|
||||
@ -111,13 +111,13 @@ public:
|
||||
/// right justified and zero-padded in a field
|
||||
/// having at least the specified width.
|
||||
|
||||
static std::string formatHex(long value, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(long value, bool prefix = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static std::string formatHex(long value, int width, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(long value, int width, bool prefix = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
@ -138,12 +138,12 @@ public:
|
||||
/// right justified and zero-padded
|
||||
/// in a field having at least the specified width.
|
||||
|
||||
static std::string formatHex(unsigned long value, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(unsigned long value, bool prefix = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
static std::string formatHex(unsigned long value, int width, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(unsigned long value, int width, bool prefix = false);
|
||||
/// Formats an unsigned long value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
@ -165,13 +165,13 @@ public:
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
|
||||
static std::string formatHex(long long value, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(long long value, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static std::string formatHex(long long value, int width, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(long long value, int width, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
@ -190,12 +190,12 @@ public:
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
|
||||
static std::string formatHex(unsigned long long value, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(unsigned long long value, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
static std::string formatHex(unsigned long long value, int width, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(unsigned long long value, int width, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width. If prefix is true, "0x" prefix is
|
||||
@ -215,13 +215,13 @@ public:
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
|
||||
static std::string formatHex(Int64 value, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(Int64 value, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
/// The value is treated as unsigned.
|
||||
|
||||
static std::string formatHex(Int64 value, int width, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(Int64 value, int width, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
@ -240,12 +240,12 @@ public:
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
|
||||
static std::string formatHex(UInt64 value, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(UInt64 value, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation.
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
static std::string formatHex(UInt64 value, int width, bool prefix = false, bool upper = true);
|
||||
static std::string formatHex(UInt64 value, int width, bool prefix = false);
|
||||
/// Formats a 64-bit integer value in hexadecimal notation,
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width. If prefix is true, "0x" prefix is
|
||||
@ -532,18 +532,18 @@ inline std::string NumberFormatter::format0(int value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(int value, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(int value, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix, -1, ' ', 0, upper);
|
||||
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(int value, int width, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(int value, int width, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix, width, '0', 0, upper);
|
||||
uIntToStr(static_cast<unsigned int>(value), 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -572,18 +572,18 @@ inline std::string NumberFormatter::format0(unsigned int value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned value, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(unsigned value, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, -1, ' ', 0, upper);
|
||||
uIntToStr(value, 0x10, result, prefix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned value, int width, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(unsigned value, int width, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0', 0, upper);
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -612,18 +612,18 @@ inline std::string NumberFormatter::format0(long value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(long value, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(long value, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix, -1, ' ', 0, upper);
|
||||
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(long value, int width, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(long value, int width, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix, width, '0', 0, upper);
|
||||
uIntToStr(static_cast<unsigned long>(value), 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -652,18 +652,18 @@ inline std::string NumberFormatter::format0(unsigned long value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned long value, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(unsigned long value, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, -1, ' ', 0, upper);
|
||||
uIntToStr(value, 0x10, result, prefix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned long value, int width, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(unsigned long value, int width, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0', 0, upper);
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -696,18 +696,18 @@ inline std::string NumberFormatter::format0(long long value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(long long value, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(long long value, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, -1, ' ', 0, upper);
|
||||
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(long long value, int width, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(long long value, int width, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, width, '0', 0, upper);
|
||||
uIntToStr(static_cast<unsigned long long>(value), 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -736,18 +736,18 @@ inline std::string NumberFormatter::format0(unsigned long long value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned long long value, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(unsigned long long value, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, -1, ' ', 0, upper);
|
||||
uIntToStr(value, 0x10, result, prefix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(unsigned long long value, int width, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(unsigned long long value, int width, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0', 0, upper);
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -779,18 +779,18 @@ inline std::string NumberFormatter::format0(Int64 value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(Int64 value, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(Int64 value, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix, -1, ' ', 0, upper);
|
||||
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(Int64 value, int width, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(Int64 value, int width, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix, width, '0', 0, upper);
|
||||
uIntToStr(static_cast<UInt64>(value), 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -819,18 +819,18 @@ inline std::string NumberFormatter::format0(UInt64 value, int width)
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(UInt64 value, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(UInt64 value, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, -1, ' ', 0, upper);
|
||||
uIntToStr(value, 0x10, result, prefix);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
inline std::string NumberFormatter::formatHex(UInt64 value, int width, bool prefix, bool upper)
|
||||
inline std::string NumberFormatter::formatHex(UInt64 value, int width, bool prefix)
|
||||
{
|
||||
std::string result;
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0', 0, upper);
|
||||
uIntToStr(value, 0x10, result, prefix, width, '0');
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -374,8 +374,7 @@ bool intToStr(T value,
|
||||
bool prefix = false,
|
||||
int width = -1,
|
||||
char fill = ' ',
|
||||
char thSep = 0,
|
||||
bool upper = true)
|
||||
char thSep = 0)
|
||||
/// Converts integer to string. Numeric bases from binary to hexadecimal are supported.
|
||||
/// If width is non-zero, it pads the return value with fill character to the specified width.
|
||||
/// When padding is zero character ('0'), it is prepended to the number itself; all other
|
||||
@ -397,10 +396,7 @@ bool intToStr(T value,
|
||||
{
|
||||
tmpVal = value;
|
||||
value /= base;
|
||||
if (upper)
|
||||
*ptr++ = "FEDCBA9876543210123456789ABCDEF"[15 + (tmpVal - value * base)];
|
||||
else
|
||||
*ptr++ = "fedcba9876543210123456789abcdef"[15 + (tmpVal - value * base)];
|
||||
*ptr++ = "FEDCBA9876543210123456789ABCDEF"[15 + (tmpVal - value * base)];
|
||||
if (thSep && (base == 10) && (++thCount == 3))
|
||||
{
|
||||
*ptr++ = thSep;
|
||||
@ -456,8 +452,7 @@ bool uIntToStr(T value,
|
||||
bool prefix = false,
|
||||
int width = -1,
|
||||
char fill = ' ',
|
||||
char thSep = 0,
|
||||
bool upper = true)
|
||||
char thSep = 0)
|
||||
/// Converts unsigned integer to string. Numeric bases from binary to hexadecimal are supported.
|
||||
/// If width is non-zero, it pads the return value with fill character to the specified width.
|
||||
/// When padding is zero character ('0'), it is prepended to the number itself; all other
|
||||
@ -479,10 +474,7 @@ bool uIntToStr(T value,
|
||||
{
|
||||
tmpVal = value;
|
||||
value /= base;
|
||||
if (upper)
|
||||
*ptr++ = "FEDCBA9876543210123456789ABCDEF"[15 + (tmpVal - value * base)];
|
||||
else
|
||||
*ptr++ = "fedcba9876543210123456789abcdef"[15 + (tmpVal - value * base)];
|
||||
*ptr++ = "FEDCBA9876543210123456789ABCDEF"[15 + (tmpVal - value * base)];
|
||||
if (thSep && (base == 10) && (++thCount == 3))
|
||||
{
|
||||
*ptr++ = thSep;
|
||||
@ -528,26 +520,26 @@ bool uIntToStr(T value,
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool intToStr (T number, unsigned short base, std::string& result, bool prefix = false, int width = -1, char fill = ' ', char thSep = 0, bool upper = true)
|
||||
bool intToStr (T number, unsigned short base, std::string& result, bool prefix = false, int width = -1, char fill = ' ', char thSep = 0)
|
||||
/// Converts integer to string; This is a wrapper function, for details see see the
|
||||
/// bool intToStr(T, unsigned short, char*, int, int, char, char) implementation.
|
||||
{
|
||||
char res[POCO_MAX_INT_STRING_LEN] = {0};
|
||||
std::size_t size = POCO_MAX_INT_STRING_LEN;
|
||||
bool ret = intToStr(number, base, res, size, prefix, width, fill, thSep, upper);
|
||||
bool ret = intToStr(number, base, res, size, prefix, width, fill, thSep);
|
||||
result.assign(res, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool uIntToStr (T number, unsigned short base, std::string& result, bool prefix = false, int width = -1, char fill = ' ', char thSep = 0, bool upper = true)
|
||||
bool uIntToStr (T number, unsigned short base, std::string& result, bool prefix = false, int width = -1, char fill = ' ', char thSep = 0)
|
||||
/// Converts unsigned integer to string; This is a wrapper function, for details see see the
|
||||
/// bool uIntToStr(T, unsigned short, char*, int, int, char, char) implementation.
|
||||
{
|
||||
char res[POCO_MAX_INT_STRING_LEN] = {0};
|
||||
std::size_t size = POCO_MAX_INT_STRING_LEN;
|
||||
bool ret = uIntToStr(number, base, res, size, prefix, width, fill, thSep, upper);
|
||||
bool ret = uIntToStr(number, base, res, size, prefix, width, fill, thSep);
|
||||
result.assign(res, size);
|
||||
return ret;
|
||||
}
|
||||
|
@ -115,142 +115,103 @@ void NumberFormatterTest::testFormatHex()
|
||||
{
|
||||
assertTrue (NumberFormatter::formatHex(0x12) == "12");
|
||||
assertTrue (NumberFormatter::formatHex(0xab) == "AB");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, false, false) == "ab");
|
||||
assertTrue (NumberFormatter::formatHex(0x12, 4) == "0012");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, 4) == "00AB");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, 4, false, false) == "00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0x12) == "12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab) == "AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, false, false) == "ab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0x12, 4) == "0012");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 4) == "00AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 4, false, false) == "00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((long) 0x12) == "12");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab) == "AB");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab, false, false) == "ab");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0x12, 4) == "0012");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab, 4) == "00AB");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12) == "12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab) == "AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, false, false) == "ab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12, 4) == "0012");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 4) == "00AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 4, false, false) == "00ab");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0x12) == "12");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab) == "AB");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, false, false) == "ab");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0x12, 4) == "0012");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 4) == "00AB");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 4, false, false) == "00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0x12) == "12");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab) == "AB");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, false, false) == "ab");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0x12, 4) == "0012");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 4) == "00AB");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 4, false, false) == "00ab");
|
||||
#if defined(POCO_LONG_IS_64_BIT)
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0x12) == "12");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab) == "AB");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, false, false) == "ab");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0x12, 4) == "0012");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, 4) == "00AB");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, 4, false, false) == "00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12) == "12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab) == "AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, false, false) == "ab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12, 4) == "0012");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 4) == "00AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 4, false, false) == "00ab");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
assertTrue (NumberFormatter::formatHex(0x12, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex(0x12, 4, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, 4, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, 4, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex(0x12, 6, true) == "0x0012");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, 6, true) == "0x00AB");
|
||||
assertTrue (NumberFormatter::formatHex(0xab, 6, true, false) == "0x00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0x12, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0x12, 4, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 4, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 4, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0x12, 6, true) == "0x0012");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 6, true) == "0x00AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned) 0xab, 6, true, false) == "0x00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((long) 0x12, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0x12, 4, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab, 4, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab, 4, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0x12, 6, true) == "0x0012");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab, 6, true) == "0x00AB");
|
||||
assertTrue (NumberFormatter::formatHex((long) 0xab, 6, true, false) == "0x00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12, 4, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 4, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 4, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0x12, 6, true) == "0x0012");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 6, true) == "0x00AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long) 0xab, 6, true, false) == "0x00ab");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0x12, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0x12, 4, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 4, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 4, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0x12, 6, true) == "0x0012");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 6, true) == "0x00AB");
|
||||
assertTrue (NumberFormatter::formatHex((Int64) 0xab, 6, true, false) == "0x00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0x12, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0x12, 4, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 4, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 4, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0x12, 6, true) == "0x0012");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 6, true) == "0x00AB");
|
||||
assertTrue (NumberFormatter::formatHex((UInt64) 0xab, 6, true, false) == "0x00ab");
|
||||
#if defined(POCO_LONG_IS_64_BIT)
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0x12, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0x12, 4, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, 4, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, 4, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0x12, 6, true) == "0x0012");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, 6, true) == "0x00AB");
|
||||
assertTrue (NumberFormatter::formatHex((long long) 0xab, 6, true, false) == "0x00ab");
|
||||
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12, 4, true) == "0x12");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 4, true) == "0xAB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 4, true, false) == "0xab");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0x12, 6, true) == "0x0012");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 6, true) == "0x00AB");
|
||||
assertTrue (NumberFormatter::formatHex((unsigned long long) 0xab, 6, true, false) == "0x00ab");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -1005,10 +1005,6 @@ void StringTest::testIntToString()
|
||||
assertTrue (result == "0xFFFFFFFFFFFFFFFF");
|
||||
#endif
|
||||
|
||||
// hexadecimal with lower case
|
||||
assertTrue (uIntToStr(0x1234567890ABCDEF, 0x10, result, true, -1, ' ', 0, false));
|
||||
assertTrue (result == "0x1234567890abcdef");
|
||||
|
||||
try
|
||||
{
|
||||
char pResult[POCO_MAX_INT_STRING_LEN];
|
||||
|
Loading…
Reference in New Issue
Block a user