From a6fa326c26912f87fc1f34ee771a277e431d2ec7 Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Thu, 5 Oct 2017 14:02:36 -0500 Subject: [PATCH] Move to standard integer types #1147 --- Data/ODBC/src/Binder.cpp | 4 ++ Data/ODBC/testsuite/src/ODBCDB2Test.cpp | 13 ---- Data/ODBC/testsuite/src/ODBCSybaseTest.cpp | 3 - Data/ODBC/testsuite/src/ODBCTest.cpp | 1 - Data/include/Poco/Data/Binding.h | 24 +++++++ Data/include/Poco/Data/Extraction.h | 25 +++++++ Foundation/include/Poco/BinaryReader.h | 10 +-- Foundation/include/Poco/BinaryWriter.h | 16 ++--- Foundation/include/Poco/NumberFormatter.h | 14 ---- Foundation/src/BinaryReader.cpp | 6 -- Foundation/src/BinaryWriter.cpp | 5 -- Foundation/src/NumberFormatter.cpp | 8 +-- .../testsuite/src/BinaryReaderWriterTest.cpp | 22 ++---- .../testsuite/src/NumberFormatterTest.cpp | 15 ++-- Foundation/testsuite/src/NumberParserTest.cpp | 5 -- Foundation/testsuite/src/NumberParserTest.h | 2 - Foundation/testsuite/src/VarTest.cpp | 70 +++++++++++-------- JSON/testsuite/src/JSONTest.cpp | 4 +- 18 files changed, 117 insertions(+), 130 deletions(-) diff --git a/Data/ODBC/src/Binder.cpp b/Data/ODBC/src/Binder.cpp index ffb9c7533..53deaaa1d 100644 --- a/Data/ODBC/src/Binder.cpp +++ b/Data/ODBC/src/Binder.cpp @@ -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(); +#else + Poco::Int64 sz = r.convert(); +#endif // Postgres driver returns SQL_NO_TOTAL(-4) in some cases if (sz >= 0) val = static_cast(sz); diff --git a/Data/ODBC/testsuite/src/ODBCDB2Test.cpp b/Data/ODBC/testsuite/src/ODBCDB2Test.cpp index f2c5a1885..b66f239f2 100644 --- a/Data/ODBC/testsuite/src/ODBCDB2Test.cpp +++ b/Data/ODBC/testsuite/src/ODBCDB2Test.cpp @@ -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)"); diff --git a/Data/ODBC/testsuite/src/ODBCSybaseTest.cpp b/Data/ODBC/testsuite/src/ODBCSybaseTest.cpp index 87debf885..c65f7072d 100644 --- a/Data/ODBC/testsuite/src/ODBCSybaseTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCSybaseTest.cpp @@ -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 "); diff --git a/Data/ODBC/testsuite/src/ODBCTest.cpp b/Data/ODBC/testsuite/src/ODBCTest.cpp index ee1ab1406..d2bfea52e 100644 --- a/Data/ODBC/testsuite/src/ODBCTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCTest.cpp @@ -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) { diff --git a/Data/include/Poco/Data/Binding.h b/Data/include/Poco/Data/Binding.h index 2b3ff996e..68fab58c5 100644 --- a/Data/include/Poco/Data/Binding.h +++ b/Data/include/Poco/Data/Binding.h @@ -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(t, name, AbstractBinding::PD_IN); +#else + return new Binding(reinterpret_cast(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(t, name, AbstractBinding::PD_IN); +#else + return new Binding(reinterpret_cast(t), name, AbstractBinding::PD_IN); +#endif +} + + inline AbstractBinding::Ptr use(const NullData& t, const std::string& name = "") /// NullData overload. { diff --git a/Data/include/Poco/Data/Extraction.h b/Data/include/Poco/Data/Extraction.h index cae554d13..41bac2843 100644 --- a/Data/include/Poco/Data/Extraction.h +++ b/Data/include/Poco/Data/Extraction.h @@ -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(t); +#else + return new Extraction(reinterpret_cast(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(t); +#else + return new Extraction(reinterpret_cast(t)); +#endif +} + + template inline AbstractExtraction::Ptr into(T& t, const Position& pos) /// Convenience function to allow for a more compact creation of an extraction object diff --git a/Foundation/include/Poco/BinaryReader.h b/Foundation/include/Poco/BinaryReader.h index 3c2d2f8f1..c4c048c80 100644 --- a/Foundation/include/Poco/BinaryReader.h +++ b/Foundation/include/Poco/BinaryReader.h @@ -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 @@ -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) diff --git a/Foundation/include/Poco/BinaryWriter.h b/Foundation/include/Poco/BinaryWriter.h index dd636a275..2c20ee0a0 100644 --- a/Foundation/include/Poco/BinaryWriter.h +++ b/Foundation/include/Poco/BinaryWriter.h @@ -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. diff --git a/Foundation/include/Poco/NumberFormatter.h b/Foundation/include/Poco/NumberFormatter.h index 6b5389021..6127f88fc 100644 --- a/Foundation/include/Poco/NumberFormatter.h +++ b/Foundation/include/Poco/NumberFormatter.h @@ -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]; diff --git a/Foundation/src/BinaryReader.cpp b/Foundation/src/BinaryReader.cpp index 27c78e23a..1a2685001 100644 --- a/Foundation/src/BinaryReader.cpp +++ b/Foundation/src/BinaryReader.cpp @@ -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; diff --git a/Foundation/src/BinaryWriter.cpp b/Foundation/src/BinaryWriter.cpp index 0abcdf4b2..41dbd118e 100644 --- a/Foundation/src/BinaryWriter.cpp +++ b/Foundation/src/BinaryWriter.cpp @@ -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()); diff --git a/Foundation/src/NumberFormatter.cpp b/Foundation/src/NumberFormatter.cpp index 04188b985..fd6047669 100644 --- a/Foundation/src/NumberFormatter.cpp +++ b/Foundation/src/NumberFormatter.cpp @@ -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 diff --git a/Foundation/testsuite/src/BinaryReaderWriterTest.cpp b/Foundation/testsuite/src/BinaryReaderWriterTest.cpp index 53acf340f..88b9fc0f5 100644 --- a/Foundation/testsuite/src/BinaryReaderWriterTest.cpp +++ b/Foundation/testsuite/src/BinaryReaderWriterTest.cpp @@ -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 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 vec; reader >> vec; diff --git a/Foundation/testsuite/src/NumberFormatterTest.cpp b/Foundation/testsuite/src/NumberFormatterTest.cpp index 86ce6e239..f08fb4656 100644 --- a/Foundation/testsuite/src/NumberFormatterTest.cpp +++ b/Foundation/testsuite/src/NumberFormatterTest.cpp @@ -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 + } diff --git a/Foundation/testsuite/src/NumberParserTest.cpp b/Foundation/testsuite/src/NumberParserTest.cpp index d8a7741b4..3a3dbd48e 100644 --- a/Foundation/testsuite/src/NumberParserTest.cpp +++ b/Foundation/testsuite/src/NumberParserTest.cpp @@ -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()); assert(testLowerLimit()); assert(testUpperLimit()); - -#if defined(POCO_HAVE_INT64) assert(testUpperLimit64()); assert(testLowerLimit64()); assert(testUpperLimit64()); -#endif } diff --git a/Foundation/testsuite/src/NumberParserTest.h b/Foundation/testsuite/src/NumberParserTest.h index 50c432030..4f1dbabb0 100644 --- a/Foundation/testsuite/src/NumberParserTest.h +++ b/Foundation/testsuite/src/NumberParserTest.h @@ -56,7 +56,6 @@ private: return Poco::NumberParser::parse(s) == n; } -#if defined(POCO_HAVE_INT64) template bool testUpperLimit64() { T n = std::numeric_limits::max(); @@ -73,7 +72,6 @@ private: std::string s = Poco::NumberFormatter::format(n); return Poco::NumberParser::parse64(s) == n; } -#endif }; diff --git a/Foundation/testsuite/src/VarTest.cpp b/Foundation/testsuite/src/VarTest.cpp index 5856019d0..c9ccd850f 100644 --- a/Foundation/testsuite/src/VarTest.cpp +++ b/Foundation/testsuite/src/VarTest.cpp @@ -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 s16; DynamicStruct s17; @@ -2530,7 +2542,7 @@ void VarTest::testEmpty() testEmptyComparisons(); testEmptyComparisons(); testEmptyComparisons(); -#ifdef POCO_LONG_IS_64_BIT +#ifndef POCO_LONG_IS_64_BIT testEmptyComparisons(); testEmptyComparisons(); #endif diff --git a/JSON/testsuite/src/JSONTest.cpp b/JSON/testsuite/src/JSONTest.cpp index f276bccf8..08cc17f33 100644 --- a/JSON/testsuite/src/JSONTest.cpp +++ b/JSON/testsuite/src/JSONTest.cpp @@ -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(-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(-5000000000000000)); value = rds["test"]; assert(value == -5000000000000000); }