Skip to content

Commit d3cd9a7

Browse files
committed
- Fixed unit test compilation on MSVS 2003, 2005 and 2008.
- Worked-around unit test failure with MSVS* by "forcing" all floating-point numbers to be loaded from memory instead of FPU registers.
1 parent a2fb7fb commit d3cd9a7

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

src/test_lib_json/main.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@
33
// recognized in your jurisdiction.
44
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
55

6-
#include <stdint.h>
76
#include <limits>
87

98
#include <json/config.h>
109
#include <json/json.h>
1110
#include "jsontest.h"
1211

1312
// Make numeric limits more convenient to talk about.
14-
#define kint32max std::numeric_limits<int32_t>::max()
15-
#define kint32min std::numeric_limits<int32_t>::min()
16-
#define kuint32max std::numeric_limits<uint32_t>::max()
17-
#define kint64max std::numeric_limits<int64_t>::max()
18-
#define kint64min std::numeric_limits<int64_t>::min()
19-
#define kuint64max std::numeric_limits<uint64_t>::max()
13+
// Assumes int type in 32 bits.
14+
#define kint32max std::numeric_limits<int>::max()
15+
#define kint32min std::numeric_limits<int>::min()
16+
#define kuint32max std::numeric_limits<unsigned int>::max()
17+
#define kint64max std::numeric_limits<Json::Int64>::max()
18+
#define kint64min std::numeric_limits<Json::Int64>::min()
19+
#define kuint64max std::numeric_limits<Json::UInt64>::max()
20+
21+
static const double kdint64max = double(kint64max);
22+
static const float kfint64max = float(kint64max);
23+
static const float kfint32max = float(kint32max);
24+
static const float kfuint32max = float(kuint32max);
25+
2026

2127
// //////////////////////////////////////////////////////////////////
2228
// //////////////////////////////////////////////////////////////////
@@ -623,7 +629,7 @@ JSONTEST_FIXTURE( ValueTest, integers )
623629
JSONTEST_ASSERT_EQUAL(kint32max, val.asUInt());
624630
JSONTEST_ASSERT_EQUAL(kint32max, val.asLargestUInt());
625631
JSONTEST_ASSERT_EQUAL(kint32max, val.asDouble());
626-
JSONTEST_ASSERT_EQUAL(kint32max, val.asFloat());
632+
JSONTEST_ASSERT_EQUAL(kfint32max, val.asFloat());
627633
JSONTEST_ASSERT_EQUAL(true, val.asBool());
628634
JSONTEST_ASSERT_STRING_EQUAL("2147483647", val.asString());
629635

@@ -675,7 +681,7 @@ JSONTEST_FIXTURE( ValueTest, integers )
675681
JSONTEST_ASSERT_EQUAL(kuint32max, val.asUInt());
676682
JSONTEST_ASSERT_EQUAL(kuint32max, val.asLargestUInt());
677683
JSONTEST_ASSERT_EQUAL(kuint32max, val.asDouble());
678-
JSONTEST_ASSERT_EQUAL(kuint32max, val.asFloat());
684+
JSONTEST_ASSERT_EQUAL(kfuint32max, val.asFloat());
679685
JSONTEST_ASSERT_EQUAL(true, val.asBool());
680686
JSONTEST_ASSERT_STRING_EQUAL("4294967295", val.asString());
681687

0 commit comments

Comments
 (0)