From 22eede44c116df47caa097d17c12e6ca564810fd Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Wed, 25 May 2011 01:23:08 +0000 Subject: [PATCH] Added tests for 64-bit integers. --- src/test_lib_json/main.cpp | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 38d9658..bd36229 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include "jsontest.h" @@ -17,6 +18,9 @@ #define kint32max std::numeric_limits::max() #define kint32min std::numeric_limits::min() #define kuint32max std::numeric_limits::max() +#define kint64max std::numeric_limits::max() +#define kint64min std::numeric_limits::min() +#define kuint64max std::numeric_limits::max() // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// @@ -216,6 +220,47 @@ JSONTEST_FIXTURE( ValueTest, integerTypes ) checks.isNumeric_ = true; checks.isIntegral_ = true; JSONTEST_ASSERT_PRED( checkIs( Json::Value(kuint32max), checks ) ); + +#ifdef JSON_NO_INT64 + // int64 max + checks = IsCheck(); + checks.isDouble_ = true; + checks.isNumeric_ = true; + JSONTEST_ASSERT_PRED( checkIs( Json::Value(double(kint64max)), checks ) ); + + // int64 min + checks = IsCheck(); + checks.isDouble_ = true; + checks.isNumeric_ = true; + JSONTEST_ASSERT_PRED( checkIs( Json::Value(double(kint64min)), checks ) ); + + // uint64 max + checks = IsCheck(); + checks.isDouble_ = true; + checks.isNumeric_ = true; + JSONTEST_ASSERT_PRED( checkIs( Json::Value(double(kuint64max)), checks ) ); +#else // ifdef JSON_NO_INT64 + // int64 max + checks = IsCheck(); + checks.isInt_ = true; + checks.isNumeric_ = true; + checks.isIntegral_ = true; + JSONTEST_ASSERT_PRED( checkIs( Json::Value(Json::Int64(kint64max)), checks ) ); + + // int64 min + checks = IsCheck(); + checks.isInt_ = true; + checks.isNumeric_ = true; + checks.isIntegral_ = true; + JSONTEST_ASSERT_PRED( checkIs( Json::Value(Json::Int64(kint64min)), checks ) ); + + // uint64 max + checks = IsCheck(); + checks.isUInt_ = true; + checks.isNumeric_ = true; + checks.isIntegral_ = true; + JSONTEST_ASSERT_PRED( checkIs( Json::Value(Json::UInt64(kuint64max)), checks ) ); +#endif }