mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-06-07 09:04:57 +02:00
Fixed unit tests execution on MSVC 6 by removing usage of std::numeric_limits. It was returning 0 value in some max cases. Fixed Value::asFloat() to use integerToDouble().
This commit is contained in:
parent
f587e6a420
commit
d496e044b1
@ -56,7 +56,7 @@ static inline bool InRange(double d, T min, U max) {
|
|||||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
static inline double integerToDouble( Json::UInt64 value )
|
static inline double integerToDouble( Json::UInt64 value )
|
||||||
{
|
{
|
||||||
return static_cast<double>( UInt(value >> 32) ) * (UInt64(1)<<32) + UInt(value & 0xffffffff);
|
return static_cast<double>( Int64(value/2) ) * 2.0 + Int64(value & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -878,7 +878,7 @@ Value::asFloat() const
|
|||||||
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
return static_cast<float>( value_.uint_ );
|
return static_cast<float>( value_.uint_ );
|
||||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
return static_cast<float>( Int(value_.uint_/2) ) * 2 + Int(value_.uint_ & 1);
|
return integerToDouble( value_.uint_ );
|
||||||
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
case realValue:
|
case realValue:
|
||||||
return static_cast<float>( value_.real_ );
|
return static_cast<float>( value_.real_ );
|
||||||
|
@ -3,20 +3,18 @@
|
|||||||
// recognized in your jurisdiction.
|
// recognized in your jurisdiction.
|
||||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
#include <json/config.h>
|
#include <json/config.h>
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
#include "jsontest.h"
|
#include "jsontest.h"
|
||||||
|
|
||||||
// Make numeric limits more convenient to talk about.
|
// Make numeric limits more convenient to talk about.
|
||||||
// Assumes int type in 32 bits.
|
// Assumes int type in 32 bits.
|
||||||
#define kint32max std::numeric_limits<int>::max()
|
#define kint32max Json::Value::maxInt
|
||||||
#define kint32min std::numeric_limits<int>::min()
|
#define kint32min Json::Value::minInt
|
||||||
#define kuint32max std::numeric_limits<unsigned int>::max()
|
#define kuint32max Json::Value::maxUInt
|
||||||
#define kint64max std::numeric_limits<Json::Int64>::max()
|
#define kint64max Json::Value::maxInt64
|
||||||
#define kint64min std::numeric_limits<Json::Int64>::min()
|
#define kint64min Json::Value::minInt64
|
||||||
#define kuint64max std::numeric_limits<Json::UInt64>::max()
|
#define kuint64max Json::Value::maxUInt64
|
||||||
|
|
||||||
static const double kdint64max = double(kint64max);
|
static const double kdint64max = double(kint64max);
|
||||||
static const float kfint64max = float(kint64max);
|
static const float kfint64max = float(kint64max);
|
||||||
@ -38,7 +36,7 @@ static inline double uint64ToDouble( Json::UInt64 value )
|
|||||||
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
static inline double uint64ToDouble( Json::UInt64 value )
|
static inline double uint64ToDouble( Json::UInt64 value )
|
||||||
{
|
{
|
||||||
return static_cast<double>( Json::UInt(value >> 32) ) * (Json::UInt64(1)<<32) + Json::UInt(value & 0xffffffff);
|
return static_cast<double>( Json::Int64(value/2) ) * 2.0 + Json::Int64(value & 1);
|
||||||
}
|
}
|
||||||
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user