mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
Move to standard integer types #1147
This commit is contained in:
@@ -31,7 +31,11 @@ static void getProp(const TypeInfo& dataTypes, SQLSMALLINT sqlType, size_t& val)
|
||||
Poco::DynamicAny r;
|
||||
if (dataTypes.tryGetInfo(sqlType, NM, r))
|
||||
{
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
long sz = r.convert<long>();
|
||||
#else
|
||||
Poco::Int64 sz = r.convert<Poco::Int64>();
|
||||
#endif
|
||||
// Postgres driver returns SQL_NO_TOTAL(-4) in some cases
|
||||
if (sz >= 0)
|
||||
val = static_cast<size_t>(sz);
|
||||
|
||||
@@ -110,8 +110,6 @@ ODBCDB2Test::~ODBCDB2Test()
|
||||
|
||||
void ODBCDB2Test::testBareboneODBC()
|
||||
{
|
||||
if (! &session()) fail ("Test not available.");
|
||||
|
||||
std::string tableCreateString = "CREATE TABLE " + ExecUtil::test_tbl() +
|
||||
"(First VARCHAR(30),"
|
||||
"Second VARCHAR(30),"
|
||||
@@ -140,8 +138,6 @@ void ODBCDB2Test::testBareboneODBC()
|
||||
|
||||
void ODBCDB2Test::testBLOB()
|
||||
{
|
||||
if (! &session()) fail ("Test not available.");
|
||||
|
||||
const std::size_t maxFldSize = 1000000;
|
||||
session().setProperty("maxFieldSize", Poco::Any(maxFldSize-1));
|
||||
recreatePersonBLOBTable();
|
||||
@@ -177,8 +173,6 @@ void ODBCDB2Test::testBLOB()
|
||||
|
||||
void ODBCDB2Test::testFilter()
|
||||
{
|
||||
if (! &session()) fail ("Test not available.");
|
||||
|
||||
for (int i = 0; i < 8;)
|
||||
{
|
||||
recreateVectorsTable();
|
||||
@@ -192,8 +186,6 @@ void ODBCDB2Test::testFilter()
|
||||
|
||||
void ODBCDB2Test::testStoredProcedure()
|
||||
{
|
||||
if (! &session()) fail ("Test not available.");
|
||||
|
||||
const std::string nm = ExecUtil::stored_proc();
|
||||
|
||||
dropObject("PROCEDURE", nm + "(INTEGER)");
|
||||
@@ -266,8 +258,6 @@ void ODBCDB2Test::testStoredProcedure()
|
||||
|
||||
void ODBCDB2Test::testStoredProcedureAny()
|
||||
{
|
||||
if (! &session()) fail ("Test not available.");
|
||||
|
||||
const std::string nm = ExecUtil::stored_proc();
|
||||
|
||||
dropObject("PROCEDURE", nm + "(INTEGER)");
|
||||
@@ -306,8 +296,6 @@ void ODBCDB2Test::testStoredProcedureAny()
|
||||
|
||||
void ODBCDB2Test::testStoredProcedureDynamicAny()
|
||||
{
|
||||
if (! &session()) fail ("Test not available.");
|
||||
|
||||
const std::string nm = ExecUtil::stored_proc();
|
||||
|
||||
dropObject("PROCEDURE", nm + "(INTEGER)");
|
||||
@@ -346,7 +334,6 @@ void ODBCDB2Test::testStoredProcedureDynamicAny()
|
||||
void ODBCDB2Test::testStoredFunction()
|
||||
{
|
||||
const std::string nm = ExecUtil::stored_func();
|
||||
if (! &session()) fail ("Test not available.");
|
||||
|
||||
dropObject("PROCEDURE", nm + "()");
|
||||
dropObject("PROCEDURE", nm + "(INTEGER)");
|
||||
|
||||
@@ -115,7 +115,6 @@ ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString)
|
||||
|
||||
void SybaseODBC::testBareboneODBC()
|
||||
{
|
||||
if (!&session()) fail("Test not available.");
|
||||
}
|
||||
|
||||
|
||||
@@ -553,8 +552,6 @@ void SybaseODBC::testStoredProcedureAny()
|
||||
|
||||
void SybaseODBC::testTransaction()
|
||||
{
|
||||
if (!&session())fail("Test not available.");
|
||||
|
||||
for (int i = 0; i < 8;)
|
||||
{
|
||||
doPersonTable(" UNIQUE ");
|
||||
|
||||
@@ -1129,7 +1129,6 @@ void ODBCTest::testMultipleResults()
|
||||
|
||||
void ODBCTest::testMultipleResultsNoProj()
|
||||
{
|
||||
if (! &session()) fail("Test not available.");
|
||||
session().setFeature("autoBind", true); // DB2 fails without that
|
||||
for (int autoE = 0; autoE < 2; ++autoE)
|
||||
{
|
||||
|
||||
@@ -1393,6 +1393,30 @@ inline AbstractBinding::Ptr use(T& t, const std::string& name = "")
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
inline AbstractBinding::Ptr use(long& t, const std::string& name)
|
||||
/// Convenience function for a more compact Binding creation.
|
||||
{
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
return new Binding<long>(t, name, AbstractBinding::PD_IN);
|
||||
#else
|
||||
return new Binding<Poco::Int64>(reinterpret_cast<Poco::Int64&>(t), name, AbstractBinding::PD_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
inline AbstractBinding::Ptr use(unsigned long& t, const std::string& name)
|
||||
/// Convenience function for a more compact Binding creation.
|
||||
{
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
return new Binding<unsigned long>(t, name, AbstractBinding::PD_IN);
|
||||
#else
|
||||
return new Binding<Poco::UInt64>(reinterpret_cast<Poco::UInt64&>(t), name, AbstractBinding::PD_IN);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline AbstractBinding::Ptr use(const NullData& t, const std::string& name = "")
|
||||
/// NullData overload.
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include "Poco/Data/Data.h"
|
||||
#include "Poco/Types.h"
|
||||
#include "Poco/Data/AbstractExtraction.h"
|
||||
#include "Poco/Data/Preparation.h"
|
||||
#include "Poco/Data/TypeHandler.h"
|
||||
@@ -865,6 +866,30 @@ inline AbstractExtraction::Ptr into(T& t)
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
inline AbstractExtraction::Ptr into(long& t)
|
||||
/// Convenience function to allow for a more compact creation of an extraction object.
|
||||
{
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
return new Extraction<long>(t);
|
||||
#else
|
||||
return new Extraction<Poco::Int64>(reinterpret_cast<Poco::Int64&>(t));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
inline AbstractExtraction::Ptr into(unsigned long& t)
|
||||
/// Convenience function to allow for a more compact creation of an extraction object.
|
||||
{
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
return new Extraction<unsigned long>(t);
|
||||
#else
|
||||
return new Extraction<Poco::UInt64>(reinterpret_cast<Poco::UInt64&>(t));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline AbstractExtraction::Ptr into(T& t, const Position& pos)
|
||||
/// Convenience function to allow for a more compact creation of an extraction object
|
||||
|
||||
@@ -75,12 +75,8 @@ public:
|
||||
BinaryReader& operator >> (unsigned long& value);
|
||||
BinaryReader& operator >> (float& value);
|
||||
BinaryReader& operator >> (double& value);
|
||||
|
||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
BinaryReader& operator >> (Int64& value);
|
||||
BinaryReader& operator >> (UInt64& value);
|
||||
#endif
|
||||
|
||||
BinaryReader& operator >> (std::string& value);
|
||||
|
||||
template <typename T>
|
||||
@@ -105,12 +101,10 @@ public:
|
||||
/// See BinaryWriter::write7BitEncoded() for a description
|
||||
/// of the compression algorithm.
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
void read7BitEncoded(UInt64& value);
|
||||
/// Reads a 64-bit unsigned integer in compressed format.
|
||||
/// See BinaryWriter::write7BitEncoded() for a description
|
||||
/// of the compression algorithm.
|
||||
#endif
|
||||
|
||||
void readRaw(std::streamsize length, std::string& value);
|
||||
/// Reads length bytes of raw data into value.
|
||||
@@ -249,7 +243,7 @@ inline bool BinaryReader::good()
|
||||
return _istr.good();
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline bool BinaryReader::fail()
|
||||
{
|
||||
return _istr.fail();
|
||||
@@ -273,7 +267,7 @@ inline std::istream& BinaryReader::stream() const
|
||||
return _istr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline BinaryReader::StreamByteOrder BinaryReader::byteOrder() const
|
||||
{
|
||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||
|
||||
@@ -80,12 +80,8 @@ public:
|
||||
BinaryWriter& operator << (unsigned long value);
|
||||
BinaryWriter& operator << (float value);
|
||||
BinaryWriter& operator << (double value);
|
||||
|
||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
BinaryWriter& operator << (Int64 value);
|
||||
BinaryWriter& operator << (UInt64 value);
|
||||
#endif
|
||||
|
||||
BinaryWriter& operator << (const std::string& value);
|
||||
BinaryWriter& operator << (const char* value);
|
||||
|
||||
@@ -114,7 +110,6 @@ public:
|
||||
/// written out. value is then shifted by seven bits and the next byte is written.
|
||||
/// This process is repeated until the entire integer has been written.
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
void write7BitEncoded(UInt64 value);
|
||||
/// Writes a 64-bit unsigned integer in a compressed format.
|
||||
/// The value written out seven bits at a time, starting
|
||||
@@ -125,7 +120,6 @@ public:
|
||||
/// If value will not fit in seven bits, the high bit is set on the first byte and
|
||||
/// written out. value is then shifted by seven bits and the next byte is written.
|
||||
/// This process is repeated until the entire integer has been written.
|
||||
#endif
|
||||
|
||||
void writeRaw(const std::string& rawData);
|
||||
/// Writes the string as-is to the stream.
|
||||
@@ -141,19 +135,19 @@ public:
|
||||
|
||||
void flush();
|
||||
/// Flushes the underlying stream.
|
||||
|
||||
|
||||
bool good();
|
||||
/// Returns _ostr.good();
|
||||
|
||||
|
||||
bool fail();
|
||||
/// Returns _ostr.fail();
|
||||
|
||||
|
||||
bool bad();
|
||||
/// Returns _ostr.bad();
|
||||
|
||||
|
||||
std::ostream& stream() const;
|
||||
/// Returns the underlying stream.
|
||||
|
||||
|
||||
StreamByteOrder byteOrder() const;
|
||||
/// Returns the byte ordering used by the writer, which is
|
||||
/// either BIG_ENDIAN_BYTE_ORDER or LITTLE_ENDIAN_BYTE_ORDER.
|
||||
|
||||
@@ -150,8 +150,6 @@ public:
|
||||
/// If prefix is true, "0x" prefix is prepended to the
|
||||
/// resulting string.
|
||||
|
||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
static std::string format(Int64 value);
|
||||
/// Formats a 64-bit integer value in decimal notation.
|
||||
|
||||
@@ -200,8 +198,6 @@ public:
|
||||
/// the specified width. If prefix is true, "0x" prefix is
|
||||
/// prepended to the resulting string.
|
||||
|
||||
#endif // defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
static std::string format(float value);
|
||||
/// Formats a float value in decimal floating-point notation,
|
||||
/// according to std::printf's %g format with a precision of 8 fractional digits.
|
||||
@@ -325,8 +321,6 @@ public:
|
||||
/// right justified and zero-padded in a field having at least the
|
||||
/// specified width.
|
||||
|
||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
static void append(std::string& str, Int64 value);
|
||||
/// Formats a 64-bit integer value in decimal notation.
|
||||
|
||||
@@ -369,8 +363,6 @@ public:
|
||||
/// right justified and zero-padded in a field having at least
|
||||
/// the specified width.
|
||||
|
||||
#endif // defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
static void append(std::string& str, float value);
|
||||
/// Formats a float value in decimal floating-point notation,
|
||||
/// according to std::printf's %g format with a precision of 8 fractional digits.
|
||||
@@ -570,9 +562,6 @@ inline std::string NumberFormatter::formatHex(unsigned long value, int width, bo
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
|
||||
inline std::string NumberFormatter::format(Int64 value)
|
||||
{
|
||||
std::string result;
|
||||
@@ -653,9 +642,6 @@ inline std::string NumberFormatter::formatHex(UInt64 value, int width, bool pref
|
||||
}
|
||||
|
||||
|
||||
#endif // defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
|
||||
inline std::string NumberFormatter::format(float value)
|
||||
{
|
||||
char buffer[POCO_MAX_FLT_STRING_LEN];
|
||||
|
||||
@@ -131,9 +131,6 @@ BinaryReader& BinaryReader::operator >> (double& value)
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
|
||||
BinaryReader& BinaryReader::operator >> (Int64& value)
|
||||
{
|
||||
return read(value, _flipBytes);
|
||||
@@ -146,9 +143,6 @@ BinaryReader& BinaryReader::operator >> (UInt64& value)
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
BinaryReader& BinaryReader::operator >> (std::string& value)
|
||||
{
|
||||
if (!_istr.good()) return *this;
|
||||
|
||||
@@ -131,8 +131,6 @@ BinaryWriter& BinaryWriter::operator << (double value)
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
|
||||
BinaryWriter& BinaryWriter::operator << (Int64 value)
|
||||
{
|
||||
@@ -146,9 +144,6 @@ BinaryWriter& BinaryWriter::operator << (UInt64 value)
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
BinaryWriter& BinaryWriter::operator << (const std::string& value)
|
||||
{
|
||||
return write(value.c_str(), value.length());
|
||||
|
||||
@@ -234,9 +234,6 @@ void NumberFormatter::appendHex(std::string& str, unsigned long value, int width
|
||||
}
|
||||
|
||||
|
||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
|
||||
void NumberFormatter::append(std::string& str, Int64 value)
|
||||
{
|
||||
char result[NF_MAX_INT_STRING_LEN];
|
||||
@@ -327,9 +324,6 @@ void NumberFormatter::appendHex(std::string& str, UInt64 value, int width)
|
||||
}
|
||||
|
||||
|
||||
#endif // defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
|
||||
void NumberFormatter::append(std::string& str, float value)
|
||||
{
|
||||
char buffer[NF_MAX_FLT_STRING_LEN];
|
||||
@@ -381,7 +375,7 @@ void NumberFormatter::append(std::string& str, const void* ptr)
|
||||
char buffer[24];
|
||||
#if defined(POCO_PTR_IS_64_BIT)
|
||||
#if defined(POCO_LONG_IS_64_BIT)
|
||||
std::sprintf(buffer, "%016lX", (UIntPtr) ptr);
|
||||
std::sprintf(buffer, "%016lX", (long) ptr);
|
||||
#else
|
||||
std::sprintf(buffer, "%016" I64_FMT "X", (UIntPtr) ptr);
|
||||
#endif
|
||||
|
||||
@@ -87,11 +87,9 @@ void BinaryReaderWriterTest::write(BinaryWriter& writer)
|
||||
writer << (unsigned) 123456;
|
||||
writer << (long) -1234567890;
|
||||
writer << (unsigned long) 1234567890;
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
|
||||
writer << (Int64) -1234567890;
|
||||
writer << (UInt64) 1234567890;
|
||||
#endif
|
||||
|
||||
writer << (float) 1.5;
|
||||
writer << (double) -1.5;
|
||||
@@ -108,14 +106,12 @@ void BinaryReaderWriterTest::write(BinaryWriter& writer)
|
||||
writer.write7BitEncoded((UInt32) 100000);
|
||||
writer.write7BitEncoded((UInt32) 1000000);
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
writer.write7BitEncoded((UInt64) 100);
|
||||
writer.write7BitEncoded((UInt64) 1000);
|
||||
writer.write7BitEncoded((UInt64) 10000);
|
||||
writer.write7BitEncoded((UInt64) 100000);
|
||||
writer.write7BitEncoded((UInt64) 1000000);
|
||||
#endif
|
||||
|
||||
|
||||
std::vector<int> vec;
|
||||
vec.push_back(1);
|
||||
vec.push_back(2);
|
||||
@@ -133,7 +129,7 @@ void BinaryReaderWriterTest::read(BinaryReader& reader)
|
||||
assert (b);
|
||||
reader >> b;
|
||||
assert (!b);
|
||||
|
||||
|
||||
char c;
|
||||
reader >> c;
|
||||
assert (c == 'a');
|
||||
@@ -162,24 +158,22 @@ void BinaryReaderWriterTest::read(BinaryReader& reader)
|
||||
reader >> ulongv;
|
||||
assert (ulongv == 1234567890);
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
Int64 int64v;
|
||||
reader >> int64v;
|
||||
assert (int64v == -1234567890);
|
||||
|
||||
|
||||
UInt64 uint64v;
|
||||
reader >> uint64v;
|
||||
assert (uint64v == 1234567890);
|
||||
#endif
|
||||
|
||||
float floatv;
|
||||
reader >> floatv;
|
||||
assert (floatv == 1.5);
|
||||
|
||||
|
||||
double doublev;
|
||||
reader >> doublev;
|
||||
assert (doublev == -1.5);
|
||||
|
||||
|
||||
std::string str;
|
||||
reader >> str;
|
||||
assert (str == "foo");
|
||||
@@ -189,7 +183,7 @@ void BinaryReaderWriterTest::read(BinaryReader& reader)
|
||||
assert (str == "bar");
|
||||
reader >> str;
|
||||
assert (str == "");
|
||||
|
||||
|
||||
UInt32 uint32v;
|
||||
reader.read7BitEncoded(uint32v);
|
||||
assert (uint32v == 100);
|
||||
@@ -202,7 +196,6 @@ void BinaryReaderWriterTest::read(BinaryReader& reader)
|
||||
reader.read7BitEncoded(uint32v);
|
||||
assert (uint32v == 1000000);
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
reader.read7BitEncoded(uint64v);
|
||||
assert (uint64v == 100);
|
||||
reader.read7BitEncoded(uint64v);
|
||||
@@ -213,7 +206,6 @@ void BinaryReaderWriterTest::read(BinaryReader& reader)
|
||||
assert (uint64v == 100000);
|
||||
reader.read7BitEncoded(uint64v);
|
||||
assert (uint64v == 1000000);
|
||||
#endif
|
||||
|
||||
std::vector<int> vec;
|
||||
reader >> vec;
|
||||
|
||||
@@ -51,14 +51,12 @@ void NumberFormatterTest::testFormat()
|
||||
assert (NumberFormatter::format(-123) == "-123");
|
||||
assert (NumberFormatter::format(-123, 5) == " -123");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::format((Int64) 123) == "123");
|
||||
assert (NumberFormatter::format((Int64) -123) == "-123");
|
||||
assert (NumberFormatter::format((Int64) -123, 5) == " -123");
|
||||
|
||||
assert (NumberFormatter::format((UInt64) 123) == "123");
|
||||
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
|
||||
#endif
|
||||
assert (NumberFormatter::format((UInt64) 123, 5) == " 123");
|
||||
|
||||
if (sizeof(void*) == 4)
|
||||
{
|
||||
@@ -79,11 +77,9 @@ void NumberFormatterTest::testFormat0()
|
||||
assert (NumberFormatter::format0((long) -123, 5) == "-0123");
|
||||
assert (NumberFormatter::format0((unsigned long) 123, 5) == "00123");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::format0((Int64) 123, 5) == "00123");
|
||||
assert (NumberFormatter::format0((Int64) -123, 5) == "-0123");
|
||||
assert (NumberFormatter::format0((UInt64) 123, 5) == "00123");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +116,6 @@ void NumberFormatterTest::testFormatHex()
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0xab, 4) == "00AB");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert (NumberFormatter::formatHex((Int64) 0x12) == "12");
|
||||
assert (NumberFormatter::formatHex((Int64) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((Int64) 0x12, 4) == "0012");
|
||||
@@ -130,7 +125,6 @@ void NumberFormatterTest::testFormatHex()
|
||||
assert (NumberFormatter::formatHex((UInt64) 0xab) == "AB");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0x12, 4) == "0012");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0xab, 4) == "00AB");
|
||||
#endif
|
||||
|
||||
assert (NumberFormatter::formatHex(0x12, true) == "0x12");
|
||||
assert (NumberFormatter::formatHex(0xab, true) == "0xAB");
|
||||
@@ -146,6 +140,8 @@ void NumberFormatterTest::testFormatHex()
|
||||
assert (NumberFormatter::formatHex((unsigned) 0x12, 6, true) == "0x0012");
|
||||
assert (NumberFormatter::formatHex((unsigned) 0xab, 6, true) == "0x00AB");
|
||||
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
|
||||
assert (NumberFormatter::formatHex((long) 0x12, true) == "0x12");
|
||||
assert (NumberFormatter::formatHex((long) 0xab, true) == "0xAB");
|
||||
assert (NumberFormatter::formatHex((long) 0x12, 4, true) == "0x12");
|
||||
@@ -160,7 +156,8 @@ void NumberFormatterTest::testFormatHex()
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0x12, 6, true) == "0x0012");
|
||||
assert (NumberFormatter::formatHex((unsigned long) 0xab, 6, true) == "0x00AB");
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
#endif // POCO_LONG_IS_64_BIT
|
||||
|
||||
assert (NumberFormatter::formatHex((Int64) 0x12, true) == "0x12");
|
||||
assert (NumberFormatter::formatHex((Int64) 0xab, true) == "0xAB");
|
||||
assert (NumberFormatter::formatHex((Int64) 0x12, 4, true) == "0x12");
|
||||
@@ -174,7 +171,7 @@ void NumberFormatterTest::testFormatHex()
|
||||
assert (NumberFormatter::formatHex((UInt64) 0xab, 4, true) == "0xAB");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0x12, 6, true) == "0x0012");
|
||||
assert (NumberFormatter::formatHex((UInt64) 0xab, 6, true) == "0x00AB");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,10 +31,8 @@ using Poco::Int16;
|
||||
using Poco::UInt16;
|
||||
using Poco::Int32;
|
||||
using Poco::UInt32;
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
using Poco::Int64;
|
||||
using Poco::UInt64;
|
||||
#endif
|
||||
using Poco::format;
|
||||
using Poco::decimalSeparator;
|
||||
using Poco::thousandSeparator;
|
||||
@@ -182,12 +180,9 @@ void NumberParserTest::testLimits()
|
||||
assert(testUpperLimit<Int32>());
|
||||
assert(testLowerLimit<Int32>());
|
||||
assert(testUpperLimit<UInt32>());
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
assert(testUpperLimit64<Int64>());
|
||||
assert(testLowerLimit64<Int64>());
|
||||
assert(testUpperLimit64<UInt64>());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ private:
|
||||
return Poco::NumberParser::parse(s) == n;
|
||||
}
|
||||
|
||||
#if defined(POCO_HAVE_INT64)
|
||||
template <class T> bool testUpperLimit64()
|
||||
{
|
||||
T n = std::numeric_limits<T>::max();
|
||||
@@ -73,7 +72,6 @@ private:
|
||||
std::string s = Poco::NumberFormatter::format(n);
|
||||
return Poco::NumberParser::parse64(s) == n;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@ void VarTest::testInt8()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -187,8 +187,9 @@ void VarTest::testInt16()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -275,8 +276,9 @@ void VarTest::testInt32()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -363,8 +365,9 @@ void VarTest::testInt64()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -451,8 +454,9 @@ void VarTest::testUInt8()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -539,8 +543,8 @@ void VarTest::testUInt16()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -627,8 +631,8 @@ void VarTest::testUInt32()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -715,8 +719,8 @@ void VarTest::testUInt64()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -803,8 +807,8 @@ void VarTest::testBool()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 1);
|
||||
@@ -874,8 +878,8 @@ void VarTest::testChar()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -948,8 +952,8 @@ void VarTest::testFloat()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -1040,8 +1044,8 @@ void VarTest::testDouble()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -1128,8 +1132,8 @@ void VarTest::testString()
|
||||
a1.convert(s11);
|
||||
a1.convert(s12);
|
||||
a1.convert(s13);
|
||||
long s14;
|
||||
unsigned long s15;
|
||||
Int64 s14;
|
||||
UInt64 s15;
|
||||
a1.convert(s14);
|
||||
a1.convert(s15);
|
||||
assert (s14 == 32);
|
||||
@@ -1182,6 +1186,7 @@ void VarTest::testString()
|
||||
|
||||
void VarTest::testLong()
|
||||
{
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
long src = 32;
|
||||
Var a1 = src;
|
||||
|
||||
@@ -1265,11 +1270,13 @@ void VarTest::testLong()
|
||||
assert (a3 == 32);
|
||||
a3 *= 2;
|
||||
assert (a3 == 64);
|
||||
#endif // POCO_LONG_IS_64_BIT
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testULong()
|
||||
{
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
unsigned long src = 32;
|
||||
Var a1 = src;
|
||||
|
||||
@@ -1353,6 +1360,7 @@ void VarTest::testULong()
|
||||
assert (a3 == 32);
|
||||
a3 *= 2;
|
||||
assert (a3 == 64);
|
||||
#endif // POCO_LONG_IS_64_BIT
|
||||
}
|
||||
|
||||
|
||||
@@ -1436,6 +1444,8 @@ void VarTest::testComparisonOperators()
|
||||
assert (any1 >= 0);
|
||||
assert (0 <= any1);
|
||||
|
||||
#if !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
any1 = 1L;
|
||||
assert (any1 == any2);
|
||||
assert (any1 == 1L);
|
||||
@@ -1459,6 +1469,8 @@ void VarTest::testComparisonOperators()
|
||||
assert (any1 >= 0);
|
||||
assert (0 <= any1);
|
||||
|
||||
#endif // !defined(POCO_LONG_IS_64_BIT)
|
||||
|
||||
any1 = 0x31;
|
||||
assert (any1 == '1');
|
||||
assert ('1' == any1);
|
||||
@@ -1815,8 +1827,8 @@ void VarTest::testIsArray()
|
||||
double s11(13.555);
|
||||
bool s12(true);
|
||||
char s13('c');
|
||||
long s14(232323);
|
||||
unsigned long s15(21233232u);
|
||||
Int64 s14(232323);
|
||||
UInt64 s15(21233232u);
|
||||
std::vector<Var> s16;
|
||||
DynamicStruct s17;
|
||||
|
||||
@@ -2530,7 +2542,7 @@ void VarTest::testEmpty()
|
||||
testEmptyComparisons<Poco::Int32>();
|
||||
testEmptyComparisons<Poco::UInt64>();
|
||||
testEmptyComparisons<Poco::Int64>();
|
||||
#ifdef POCO_LONG_IS_64_BIT
|
||||
#ifndef POCO_LONG_IS_64_BIT
|
||||
testEmptyComparisons<unsigned long>();
|
||||
testEmptyComparisons<long>();
|
||||
#endif
|
||||
|
||||
@@ -239,7 +239,7 @@ void JSONTest::testNumber64Property()
|
||||
assert (!ds["test"].isEmpty());
|
||||
assert (ds["test"].isNumeric());
|
||||
assert (ds["test"].isInteger());
|
||||
assert (ds["test"] == -5000000000000000);
|
||||
assert (ds["test"] == static_cast<Poco::Int64>(-5000000000000000));
|
||||
value = ds["test"];
|
||||
assert(value == -5000000000000000);
|
||||
|
||||
@@ -247,7 +247,7 @@ void JSONTest::testNumber64Property()
|
||||
assert (!rds["test"].isEmpty());
|
||||
assert (rds["test"].isNumeric());
|
||||
assert (rds["test"].isInteger());
|
||||
assert (rds["test"] == -5000000000000000);
|
||||
assert (rds["test"] == static_cast<Poco::Int64>(-5000000000000000));
|
||||
value = rds["test"];
|
||||
assert(value == -5000000000000000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user