mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-04-19 23:50:38 +02:00
Compare commits
2 Commits
master
...
svn-releas
Author | SHA1 | Date | |
---|---|---|---|
![]() |
678d65e7ad | ||
![]() |
88292c9516 |
7
NEWS.txt
7
NEWS.txt
@ -13,8 +13,8 @@
|
||||
Notes: you need to setup the environment by running vcvars32.bat
|
||||
(e.g. MSVC 2008 command prompt in start menu) before running scons.
|
||||
|
||||
- Added support for amalgated source and header generation (a la sqlite).
|
||||
Refer to README.txt section "Generating amalgated source and header"
|
||||
- Added support for amalgamated source and header generation (a la sqlite).
|
||||
Refer to README.txt section "Generating amalgamated source and header"
|
||||
for detail.
|
||||
|
||||
* Value
|
||||
@ -90,6 +90,9 @@
|
||||
- Fixed Value::operator <= implementation (had the semantic of operator >=).
|
||||
Found when addigin unit tests for comparison operators.
|
||||
|
||||
- Value::compare() is now const and has an actual implementation with
|
||||
unit tests.
|
||||
|
||||
* License
|
||||
|
||||
- See file LICENSE for details. Basically JsonCpp is now licensed under
|
||||
|
16
README.txt
16
README.txt
@ -90,30 +90,30 @@ Notes that the documentation is also available for download as a tarball.
|
||||
The documentation of the latest release is available online at:
|
||||
http://jsoncpp.sourceforge.net/
|
||||
|
||||
* Generating amalgated source and header
|
||||
======================================
|
||||
* Generating amalgamated source and header
|
||||
========================================
|
||||
|
||||
JsonCpp is provided with a script to generate a single header and a single
|
||||
source file to ease inclusion in an existing project.
|
||||
|
||||
The amalgated source can be generated at any time by running the following
|
||||
The amalgamated source can be generated at any time by running the following
|
||||
command from the top-directory (requires python 2.6):
|
||||
|
||||
python amalgate.py
|
||||
python amalgamate.py
|
||||
|
||||
It is possible to specify header name. See -h options for detail. By default,
|
||||
the following files are generated:
|
||||
- dist/jsoncpp.cpp: source file that need to be added to your project
|
||||
- dist/json/json.h: header file corresponding to use in your project. It is
|
||||
equivalent to including json/json.h in non-amalgated source. This header
|
||||
equivalent to including json/json.h in non-amalgamated source. This header
|
||||
only depends on standard headers.
|
||||
- dist/json/json-forwards.h: header the provides forward declaration
|
||||
of all JsonCpp types. This typically what should be included in headers to
|
||||
speed-up compilation.
|
||||
|
||||
The amalgated sources are generated by concatenating JsonCpp source in the
|
||||
correct order and defining macro JSON_IS_AMALGATED to prevent inclusion of
|
||||
other headers.
|
||||
The amalgamated sources are generated by concatenating JsonCpp source in the
|
||||
correct order and defining macro JSON_IS_AMALGAMATION to prevent inclusion
|
||||
of other headers.
|
||||
|
||||
* Using json-cpp in your project:
|
||||
===============================
|
||||
|
@ -9,7 +9,7 @@ import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
class AmalagatedFile:
|
||||
class AmalgamationFile:
|
||||
def __init__( self, top_dir ):
|
||||
self.top_dir = top_dir
|
||||
self.blocks = []
|
||||
@ -47,9 +47,9 @@ class AmalagatedFile:
|
||||
f.write( self.get_value() )
|
||||
f.close()
|
||||
|
||||
def amalgate_source( source_top_dir=None,
|
||||
target_source_path=None,
|
||||
header_include_path=None ):
|
||||
def amalgamate_source( source_top_dir=None,
|
||||
target_source_path=None,
|
||||
header_include_path=None ):
|
||||
"""Produces amalgated source.
|
||||
Parameters:
|
||||
source_top_dir: top-directory
|
||||
@ -57,7 +57,7 @@ def amalgate_source( source_top_dir=None,
|
||||
header_include_path: generated header path relative to target_source_path.
|
||||
"""
|
||||
print 'Amalgating header...'
|
||||
header = AmalagatedFile( source_top_dir )
|
||||
header = AmalgamationFile( source_top_dir )
|
||||
header.add_text( '/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).' )
|
||||
header.add_text( '/// It is intented to be used with #include <%s>' % header_include_path )
|
||||
header.add_file( 'LICENSE', wrap_in_comment=True )
|
||||
@ -81,7 +81,7 @@ def amalgate_source( source_top_dir=None,
|
||||
base, ext = os.path.splitext( header_include_path )
|
||||
forward_header_include_path = base + '-forwards' + ext
|
||||
print 'Amalgating forward header...'
|
||||
header = AmalagatedFile( source_top_dir )
|
||||
header = AmalgamationFile( source_top_dir )
|
||||
header.add_text( '/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).' )
|
||||
header.add_text( '/// It is intented to be used with #include <%s>' % forward_header_include_path )
|
||||
header.add_text( '/// This header provides forward declaration for all JsonCpp types.' )
|
||||
@ -101,7 +101,7 @@ def amalgate_source( source_top_dir=None,
|
||||
header.write_to( target_forward_header_path )
|
||||
|
||||
print 'Amalgating source...'
|
||||
source = AmalagatedFile( source_top_dir )
|
||||
source = AmalgamationFile( source_top_dir )
|
||||
source.add_text( '/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).' )
|
||||
source.add_text( '/// It is intented to be used with #include <%s>' % header_include_path )
|
||||
source.add_file( 'LICENSE', wrap_in_comment=True )
|
||||
@ -134,9 +134,9 @@ Generate a single amalgated source and header file from the sources.
|
||||
parser.enable_interspersed_args()
|
||||
options, args = parser.parse_args()
|
||||
|
||||
msg = amalgate_source( source_top_dir=options.top_dir,
|
||||
target_source_path=options.target_source_path,
|
||||
header_include_path=options.header_include_path )
|
||||
msg = amalgamate_source( source_top_dir=options.top_dir,
|
||||
target_source_path=options.target_source_path,
|
||||
header_include_path=options.header_include_path )
|
||||
if msg:
|
||||
sys.stderr.write( msg + '\n' )
|
||||
sys.exit( 1 )
|
@ -31,7 +31,7 @@
|
||||
/// If defined, indicates that the source file is amalgated
|
||||
/// to prevent private header inclusion.
|
||||
/// Remarks: it is automatically defined in the generated amalgated header.
|
||||
// #define JSON_IS_AMALGATED
|
||||
// #define JSON_IS_AMALGAMATION
|
||||
|
||||
|
||||
# ifdef JSON_IN_CPPTL
|
||||
|
@ -6,9 +6,9 @@
|
||||
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
# define CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||
# define JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
#ifndef CPPTL_JSON_READER_H_INCLUDED
|
||||
# define CPPTL_JSON_READER_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "features.h"
|
||||
# include "value.h"
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <deque>
|
||||
# include <stack>
|
||||
# include <string>
|
||||
@ -197,11 +197,11 @@ namespace Json {
|
||||
Result:
|
||||
\verbatim
|
||||
{
|
||||
"dir": {
|
||||
"file": {
|
||||
// The input stream JSON would be nested here.
|
||||
}
|
||||
}
|
||||
"dir": {
|
||||
"file": {
|
||||
// The input stream JSON would be nested here.
|
||||
}
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
\throw std::exception on parse error.
|
||||
|
@ -6,9 +6,9 @@
|
||||
#ifndef CPPTL_JSON_H_INCLUDED
|
||||
# define CPPTL_JSON_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <string>
|
||||
# include <vector>
|
||||
|
||||
@ -132,30 +132,30 @@ namespace Json {
|
||||
typedef Json::UInt64 UInt64;
|
||||
typedef Json::Int64 Int64;
|
||||
#endif // defined(JSON_HAS_INT64)
|
||||
typedef Json::LargestInt LargestInt;
|
||||
typedef Json::LargestUInt LargestUInt;
|
||||
typedef Json::LargestInt LargestInt;
|
||||
typedef Json::LargestUInt LargestUInt;
|
||||
typedef Json::ArrayIndex ArrayIndex;
|
||||
|
||||
static const Value null;
|
||||
/// Minimum signed integer value that can be stored in a Json::Value.
|
||||
static const LargestInt minLargestInt;
|
||||
/// Maximum signed integer value that can be stored in a Json::Value.
|
||||
/// Minimum signed integer value that can be stored in a Json::Value.
|
||||
static const LargestInt minLargestInt;
|
||||
/// Maximum signed integer value that can be stored in a Json::Value.
|
||||
static const LargestInt maxLargestInt;
|
||||
/// Maximum unsigned integer value that can be stored in a Json::Value.
|
||||
/// Maximum unsigned integer value that can be stored in a Json::Value.
|
||||
static const LargestUInt maxLargestUInt;
|
||||
|
||||
/// Minimum signed int value that can be stored in a Json::Value.
|
||||
static const Int minInt;
|
||||
/// Maximum signed int value that can be stored in a Json::Value.
|
||||
/// Minimum signed int value that can be stored in a Json::Value.
|
||||
static const Int minInt;
|
||||
/// Maximum signed int value that can be stored in a Json::Value.
|
||||
static const Int maxInt;
|
||||
/// Maximum unsigned int value that can be stored in a Json::Value.
|
||||
/// Maximum unsigned int value that can be stored in a Json::Value.
|
||||
static const UInt maxUInt;
|
||||
|
||||
/// Minimum signed 64 bits int value that can be stored in a Json::Value.
|
||||
static const Int64 minInt64;
|
||||
/// Maximum signed 64 bits int value that can be stored in a Json::Value.
|
||||
/// Minimum signed 64 bits int value that can be stored in a Json::Value.
|
||||
static const Int64 minInt64;
|
||||
/// Maximum signed 64 bits int value that can be stored in a Json::Value.
|
||||
static const Int64 maxInt64;
|
||||
/// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
|
||||
/// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
|
||||
static const UInt64 maxUInt64;
|
||||
|
||||
private:
|
||||
@ -202,14 +202,14 @@ namespace Json {
|
||||
To create an empty array, pass arrayValue.
|
||||
To create an empty object, pass objectValue.
|
||||
Another Value can then be set to this one by assignment.
|
||||
This is useful since clear() and resize() will not alter types.
|
||||
This is useful since clear() and resize() will not alter types.
|
||||
|
||||
Examples:
|
||||
\code
|
||||
Json::Value null_value; // null
|
||||
Json::Value arr_value(Json::arrayValue); // []
|
||||
Json::Value obj_value(Json::objectValue); // {}
|
||||
\endcode
|
||||
\code
|
||||
Json::Value null_value; // null
|
||||
Json::Value arr_value(Json::arrayValue); // []
|
||||
Json::Value obj_value(Json::objectValue); // {}
|
||||
\endcode
|
||||
*/
|
||||
Value( ValueType type = nullValue );
|
||||
Value( Int value );
|
||||
@ -256,7 +256,7 @@ namespace Json {
|
||||
bool operator ==( const Value &other ) const;
|
||||
bool operator !=( const Value &other ) const;
|
||||
|
||||
int compare( const Value &other );
|
||||
int compare( const Value &other ) const;
|
||||
|
||||
const char *asCString() const;
|
||||
std::string asString() const;
|
||||
@ -315,24 +315,24 @@ namespace Json {
|
||||
/// this from the operator[] which takes a string.)
|
||||
Value &operator[]( ArrayIndex index );
|
||||
|
||||
/// Access an array element (zero based index ).
|
||||
/// Access an array element (zero based index ).
|
||||
/// If the array contains less than index element, then null value are inserted
|
||||
/// in the array so that its size is index+1.
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
Value &operator[]( int index );
|
||||
|
||||
/// Access an array element (zero based index )
|
||||
/// Access an array element (zero based index )
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
const Value &operator[]( ArrayIndex index ) const;
|
||||
|
||||
/// Access an array element (zero based index )
|
||||
/// Access an array element (zero based index )
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
const Value &operator[]( int index ) const;
|
||||
|
||||
/// If the array contains at least index+1 elements, returns the element value,
|
||||
/// If the array contains at least index+1 elements, returns the element value,
|
||||
/// otherwise returns defaultValue.
|
||||
Value get( ArrayIndex index,
|
||||
const Value &defaultValue ) const;
|
||||
|
@ -6,9 +6,9 @@
|
||||
#ifndef JSON_WRITER_H_INCLUDED
|
||||
# define JSON_WRITER_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "value.h"
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <vector>
|
||||
# include <string>
|
||||
# include <iostream>
|
||||
|
@ -23,7 +23,7 @@ import tempfile
|
||||
import os
|
||||
import time
|
||||
from devtools import antglob, fixeol, tarball
|
||||
import amalgate
|
||||
import amalgamate
|
||||
|
||||
SVN_ROOT = 'https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/'
|
||||
SVN_TAG_ROOT = SVN_ROOT + 'tags/jsoncpp'
|
||||
@ -323,13 +323,13 @@ Warning: --force should only be used when developping/testing the release script
|
||||
print 'Generating source tarball to', source_tarball_path
|
||||
tarball.make_tarball( source_tarball_path, [export_dir], export_dir, prefix_dir=source_dir )
|
||||
|
||||
amalgated_tarball_path = 'dist/%s-amalgated.tar.gz' % source_dir
|
||||
print 'Generating amalgated source tarball to', amalgated_tarball_path
|
||||
amalgated_dir = 'dist/amalgated'
|
||||
amalgate.amalgate_source( export_dir, '%s/jsoncpp.cpp' % amalgated_dir, 'json/json.h' )
|
||||
amalgated_source_dir = 'jsoncpp-src-amalgated' + release_version
|
||||
tarball.make_tarball( amalgated_tarball_path, [amalgated_dir],
|
||||
amalgated_dir, prefix_dir=amalgated_source_dir )
|
||||
amalgamation_tarball_path = 'dist/%s-amalgamation.tar.gz' % source_dir
|
||||
print 'Generating amalgamation source tarball to', amalgamation_tarball_path
|
||||
amalgamation_dir = 'dist/amalgamation'
|
||||
amalgamate.amalgamate_source( export_dir, '%s/jsoncpp.cpp' % amalgamation_dir, 'json/json.h' )
|
||||
amalgamation_source_dir = 'jsoncpp-src-amalgamation' + release_version
|
||||
tarball.make_tarball( amalgamation_tarball_path, [amalgamation_dir],
|
||||
amalgamation_dir, prefix_dir=amalgamation_source_dir )
|
||||
|
||||
# Decompress source tarball, download and install scons-local
|
||||
distcheck_dir = 'dist/distcheck'
|
||||
|
@ -3,11 +3,11 @@
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <json/reader.h>
|
||||
# include <json/value.h>
|
||||
# include "json_tool.h"
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <utility>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
@ -488,7 +488,7 @@ Reader::readObject( Token &/*tokenStart*/ )
|
||||
if ( !readToken( comma )
|
||||
|| ( comma.type_ != tokenObjectEnd &&
|
||||
comma.type_ != tokenArraySeparator &&
|
||||
comma.type_ != tokenComment ) )
|
||||
comma.type_ != tokenComment ) )
|
||||
{
|
||||
return addErrorAndRecover( "Missing ',' or '}' in object declaration",
|
||||
comma,
|
||||
|
@ -3,13 +3,13 @@
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <json/value.h>
|
||||
# include <json/writer.h>
|
||||
# ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||
# include "json_batchallocator.h"
|
||||
# endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
@ -83,14 +83,14 @@ releaseStringValue( char *value )
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||
# include "json_internalarray.inl"
|
||||
# include "json_internalmap.inl"
|
||||
# endif // JSON_VALUE_USE_INTERNAL_MAP
|
||||
|
||||
# include "json_valueiterator.inl"
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
@ -524,35 +524,16 @@ Value::type() const
|
||||
|
||||
|
||||
int
|
||||
Value::compare( const Value &other )
|
||||
Value::compare( const Value &other ) const
|
||||
{
|
||||
/*
|
||||
int typeDelta = other.type_ - type_;
|
||||
switch ( type_ )
|
||||
{
|
||||
case nullValue:
|
||||
|
||||
return other.type_ == type_;
|
||||
case intValue:
|
||||
if ( other.type_.isNumeric()
|
||||
case uintValue:
|
||||
case realValue:
|
||||
case booleanValue:
|
||||
break;
|
||||
case stringValue,
|
||||
break;
|
||||
case arrayValue:
|
||||
delete value_.array_;
|
||||
break;
|
||||
case objectValue:
|
||||
delete value_.map_;
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
*/
|
||||
return 0; // unreachable
|
||||
if ( *this < other )
|
||||
return -1;
|
||||
if ( *this > other )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Value::operator <( const Value &other ) const
|
||||
{
|
||||
@ -594,7 +575,7 @@ Value::operator <( const Value &other ) const
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
return 0; // unreachable
|
||||
return false; // unreachable
|
||||
}
|
||||
|
||||
bool
|
||||
@ -656,7 +637,7 @@ Value::operator ==( const Value &other ) const
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
return 0; // unreachable
|
||||
return false; // unreachable
|
||||
}
|
||||
|
||||
bool
|
||||
@ -827,9 +808,9 @@ LargestInt
|
||||
Value::asLargestInt() const
|
||||
{
|
||||
#if defined(JSON_NO_INT64)
|
||||
return asInt();
|
||||
return asInt();
|
||||
#else
|
||||
return asInt64();
|
||||
return asInt64();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -838,9 +819,9 @@ LargestUInt
|
||||
Value::asLargestUInt() const
|
||||
{
|
||||
#if defined(JSON_NO_INT64)
|
||||
return asUInt();
|
||||
return asUInt();
|
||||
#else
|
||||
return asUInt64();
|
||||
return asUInt64();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#if !defined(JSON_IS_AMALGATED)
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <json/writer.h>
|
||||
# include "json_tool.h"
|
||||
#endif // if !defined(JSON_IS_AMALGATED)
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <utility>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
@ -656,7 +656,7 @@ StyledStreamWriter::writeArrayValue( const Value &value )
|
||||
writeWithIndent( childValues_[index] );
|
||||
else
|
||||
{
|
||||
writeIndent();
|
||||
writeIndent();
|
||||
writeValue( childValue );
|
||||
}
|
||||
if ( ++index == size )
|
||||
|
@ -256,6 +256,12 @@ ValueTest::checkIs( const Json::Value &value, const IsCheck &check )
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareNull )
|
||||
{
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( Json::Value(), Json::Value() ) );
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareInt )
|
||||
{
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( 0, 10 ) );
|
||||
@ -347,6 +353,19 @@ JSONTEST_FIXTURE( ValueTest, compareObject )
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareType )
|
||||
{
|
||||
// object of different type are ordered according to their type
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(), Json::Value(1) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(1), Json::Value(1u) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(1u), Json::Value(1.0) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(1.0), Json::Value("a") ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value("a"), Json::Value(true) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(true), Json::Value(Json::arrayValue) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( Json::Value(Json::arrayValue), Json::Value(Json::objectValue) ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueTest::checkIsLess( const Json::Value &x, const Json::Value &y )
|
||||
{
|
||||
@ -360,6 +379,8 @@ ValueTest::checkIsLess( const Json::Value &x, const Json::Value &y )
|
||||
JSONTEST_ASSERT( !(y <= x) );
|
||||
JSONTEST_ASSERT( !(x > y) );
|
||||
JSONTEST_ASSERT( !(y < x) );
|
||||
JSONTEST_ASSERT( x.compare( y ) < 0 );
|
||||
JSONTEST_ASSERT( y.compare( x ) >= 0 );
|
||||
}
|
||||
|
||||
|
||||
@ -376,6 +397,8 @@ ValueTest::checkIsEqual( const Json::Value &x, const Json::Value &y )
|
||||
JSONTEST_ASSERT( !(y < x) );
|
||||
JSONTEST_ASSERT( !(x > y) );
|
||||
JSONTEST_ASSERT( !(y > x) );
|
||||
JSONTEST_ASSERT( x.compare( y ) == 0 );
|
||||
JSONTEST_ASSERT( y.compare( x ) == 0 );
|
||||
}
|
||||
|
||||
|
||||
@ -394,6 +417,7 @@ int main( int argc, const char *argv[] )
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isNull );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, accessArray );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, asFloat );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareNull );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareInt );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareUInt );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareDouble );
|
||||
@ -401,5 +425,6 @@ int main( int argc, const char *argv[] )
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareBoolean );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareArray );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareObject );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareType );
|
||||
return runner.runCommandLine( argc, argv );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user