|
3 | 3 | // recognized in your jurisdiction. |
4 | 4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE |
5 | 5 |
|
6 | | -#include <stdint.h> |
7 | 6 | #include <limits> |
8 | 7 |
|
9 | 8 | #include <json/config.h> |
10 | 9 | #include <json/json.h> |
11 | 10 | #include "jsontest.h" |
12 | 11 |
|
13 | 12 | // 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 | + |
20 | 26 |
|
21 | 27 | // ////////////////////////////////////////////////////////////////// |
22 | 28 | // ////////////////////////////////////////////////////////////////// |
@@ -623,7 +629,7 @@ JSONTEST_FIXTURE( ValueTest, integers ) |
623 | 629 | JSONTEST_ASSERT_EQUAL(kint32max, val.asUInt()); |
624 | 630 | JSONTEST_ASSERT_EQUAL(kint32max, val.asLargestUInt()); |
625 | 631 | JSONTEST_ASSERT_EQUAL(kint32max, val.asDouble()); |
626 | | - JSONTEST_ASSERT_EQUAL(kint32max, val.asFloat()); |
| 632 | + JSONTEST_ASSERT_EQUAL(kfint32max, val.asFloat()); |
627 | 633 | JSONTEST_ASSERT_EQUAL(true, val.asBool()); |
628 | 634 | JSONTEST_ASSERT_STRING_EQUAL("2147483647", val.asString()); |
629 | 635 |
|
@@ -675,7 +681,7 @@ JSONTEST_FIXTURE( ValueTest, integers ) |
675 | 681 | JSONTEST_ASSERT_EQUAL(kuint32max, val.asUInt()); |
676 | 682 | JSONTEST_ASSERT_EQUAL(kuint32max, val.asLargestUInt()); |
677 | 683 | JSONTEST_ASSERT_EQUAL(kuint32max, val.asDouble()); |
678 | | - JSONTEST_ASSERT_EQUAL(kuint32max, val.asFloat()); |
| 684 | + JSONTEST_ASSERT_EQUAL(kfuint32max, val.asFloat()); |
679 | 685 | JSONTEST_ASSERT_EQUAL(true, val.asBool()); |
680 | 686 | JSONTEST_ASSERT_STRING_EQUAL("4294967295", val.asString()); |
681 | 687 |
|
|
0 commit comments