mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 23:20:05 +02:00
Compare commits
14 Commits
svn-releas
...
svn-releas
Author | SHA1 | Date | |
---|---|---|---|
![]() |
678d65e7ad | ||
![]() |
88292c9516 | ||
![]() |
fb17080142 | ||
![]() |
e0e1fd37cd | ||
![]() |
d0a9f3d98d | ||
![]() |
7953a801c1 | ||
![]() |
df4de558c3 | ||
![]() |
62d7bc75db | ||
![]() |
224a1aee72 | ||
![]() |
40388494bd | ||
![]() |
bafb43c203 | ||
![]() |
64e40aafe5 | ||
![]() |
91923f2cbc | ||
![]() |
13698b5835 |
10
NEWS.txt
10
NEWS.txt
@@ -13,6 +13,10 @@
|
||||
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 amalgamated source and header generation (a la sqlite).
|
||||
Refer to README.txt section "Generating amalgamated source and header"
|
||||
for detail.
|
||||
|
||||
* Value
|
||||
|
||||
- Removed experimental ValueAllocator, it caused static
|
||||
@@ -82,6 +86,12 @@
|
||||
|
||||
- Bug #3139678: stack buffer overflow when parsing a double with a
|
||||
length of 32 characters.
|
||||
|
||||
- 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
|
||||
|
||||
|
37
README.txt
37
README.txt
@@ -5,8 +5,8 @@ JSON (JavaScript Object Notation) is a lightweight data-interchange format.
|
||||
It can represent integer, real number, string, an ordered sequence of
|
||||
value, and a collection of name/value pairs.
|
||||
|
||||
JsonCpp is a simple API to manipulate JSON value, handle serialization
|
||||
and unserialization to string.
|
||||
JsonCpp (http://jsoncpp.sourceforge.net/) is a simple API to manipulate
|
||||
JSON value, handle serialization and unserialization to string.
|
||||
|
||||
It can also preserve existing comment in unserialization/serialization steps,
|
||||
making it a convenient format to store user input files.
|
||||
@@ -90,6 +90,39 @@ 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 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 amalgamated source can be generated at any time by running the following
|
||||
command from the top-directory (requires python 2.6):
|
||||
|
||||
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-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 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:
|
||||
===============================
|
||||
|
||||
include/ should be added to your compiler include path. jsoncpp headers
|
||||
should be included as follow:
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
|
||||
* Adding a reader/writer test:
|
||||
============================
|
||||
|
147
amalgamate.py
Normal file
147
amalgamate.py
Normal file
@@ -0,0 +1,147 @@
|
||||
"""Amalgate json-cpp library sources into a single source and header file.
|
||||
|
||||
Requires Python 2.6
|
||||
|
||||
Example of invocation (must be invoked from json-cpp top directory):
|
||||
python amalgate.py
|
||||
"""
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
class AmalgamationFile:
|
||||
def __init__( self, top_dir ):
|
||||
self.top_dir = top_dir
|
||||
self.blocks = []
|
||||
|
||||
def add_text( self, text ):
|
||||
if not text.endswith( '\n' ):
|
||||
text += '\n'
|
||||
self.blocks.append( text )
|
||||
|
||||
def add_file( self, relative_input_path, wrap_in_comment=False ):
|
||||
def add_marker( prefix ):
|
||||
self.add_text( '' )
|
||||
self.add_text( '// ' + '/'*70 )
|
||||
self.add_text( '// %s of content of file: %s' % (prefix, relative_input_path.replace('\\','/')) )
|
||||
self.add_text( '// ' + '/'*70 )
|
||||
self.add_text( '' )
|
||||
add_marker( 'Beginning' )
|
||||
f = open( os.path.join( self.top_dir, relative_input_path ), 'rt' )
|
||||
content = f.read()
|
||||
if wrap_in_comment:
|
||||
content = '/*\n' + content + '\n*/'
|
||||
self.add_text( content )
|
||||
f.close()
|
||||
add_marker( 'End' )
|
||||
self.add_text( '\n\n\n\n' )
|
||||
|
||||
def get_value( self ):
|
||||
return ''.join( self.blocks ).replace('\r\n','\n')
|
||||
|
||||
def write_to( self, output_path ):
|
||||
output_dir = os.path.dirname( output_path )
|
||||
if output_dir and not os.path.isdir( output_dir ):
|
||||
os.makedirs( output_dir )
|
||||
f = open( output_path, 'wb' )
|
||||
f.write( self.get_value() )
|
||||
f.close()
|
||||
|
||||
def amalgamate_source( source_top_dir=None,
|
||||
target_source_path=None,
|
||||
header_include_path=None ):
|
||||
"""Produces amalgated source.
|
||||
Parameters:
|
||||
source_top_dir: top-directory
|
||||
target_source_path: output .cpp path
|
||||
header_include_path: generated header path relative to target_source_path.
|
||||
"""
|
||||
print 'Amalgating header...'
|
||||
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 )
|
||||
header.add_text( '#ifndef JSON_AMALGATED_H_INCLUDED' )
|
||||
header.add_text( '# define JSON_AMALGATED_H_INCLUDED' )
|
||||
header.add_text( '/// If defined, indicates that the source file is amalgated' )
|
||||
header.add_text( '/// to prevent private header inclusion.' )
|
||||
header.add_text( '#define JSON_IS_AMALGATED' )
|
||||
header.add_file( 'include/json/config.h' )
|
||||
header.add_file( 'include/json/forwards.h' )
|
||||
header.add_file( 'include/json/features.h' )
|
||||
header.add_file( 'include/json/value.h' )
|
||||
header.add_file( 'include/json/reader.h' )
|
||||
header.add_file( 'include/json/writer.h' )
|
||||
header.add_text( '#endif //ifndef JSON_AMALGATED_H_INCLUDED' )
|
||||
|
||||
target_header_path = os.path.join( os.path.dirname(target_source_path), header_include_path )
|
||||
print 'Writing amalgated header to %r' % target_header_path
|
||||
header.write_to( target_header_path )
|
||||
|
||||
base, ext = os.path.splitext( header_include_path )
|
||||
forward_header_include_path = base + '-forwards' + ext
|
||||
print 'Amalgating forward header...'
|
||||
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.' )
|
||||
header.add_file( 'LICENSE', wrap_in_comment=True )
|
||||
header.add_text( '#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED' )
|
||||
header.add_text( '# define JSON_FORWARD_AMALGATED_H_INCLUDED' )
|
||||
header.add_text( '/// If defined, indicates that the source file is amalgated' )
|
||||
header.add_text( '/// to prevent private header inclusion.' )
|
||||
header.add_text( '#define JSON_IS_AMALGATED' )
|
||||
header.add_file( 'include/json/config.h' )
|
||||
header.add_file( 'include/json/forwards.h' )
|
||||
header.add_text( '#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED' )
|
||||
|
||||
target_forward_header_path = os.path.join( os.path.dirname(target_source_path),
|
||||
forward_header_include_path )
|
||||
print 'Writing amalgated forward header to %r' % target_forward_header_path
|
||||
header.write_to( target_forward_header_path )
|
||||
|
||||
print 'Amalgating source...'
|
||||
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 )
|
||||
source.add_text( '' )
|
||||
source.add_text( '#include <%s>' % header_include_path )
|
||||
source.add_text( '' )
|
||||
source.add_file( 'src/lib_json\json_tool.h' )
|
||||
source.add_file( 'src/lib_json\json_reader.cpp' )
|
||||
source.add_file( 'src/lib_json\json_batchallocator.h' )
|
||||
source.add_file( 'src/lib_json\json_valueiterator.inl' )
|
||||
source.add_file( 'src/lib_json\json_value.cpp' )
|
||||
source.add_file( 'src/lib_json\json_writer.cpp' )
|
||||
|
||||
print 'Writing amalgated source to %r' % target_source_path
|
||||
source.write_to( target_source_path )
|
||||
|
||||
def main():
|
||||
usage = """%prog [options]
|
||||
Generate a single amalgated source and header file from the sources.
|
||||
"""
|
||||
from optparse import OptionParser
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.allow_interspersed_args = False
|
||||
parser.add_option('-s', '--source', dest="target_source_path", action='store', default='dist/jsoncpp.cpp',
|
||||
help="""Output .cpp source path. [Default: %default]""")
|
||||
parser.add_option('-i', '--include', dest="header_include_path", action='store', default='json/json.h',
|
||||
help="""Header include path. Used to include the header from the amalgated source file. [Default: %default]""")
|
||||
parser.add_option('-t', '--top-dir', dest="top_dir", action='store', default=os.getcwd(),
|
||||
help="""Source top-directory. [Default: %default]""")
|
||||
parser.enable_interspersed_args()
|
||||
options, args = parser.parse_args()
|
||||
|
||||
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 )
|
||||
else:
|
||||
print 'Source succesfully amalagated'
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -1,14 +1,4 @@
|
||||
/*! \page roadmap JsonCpp roadmap
|
||||
\section ms_64bits Adds support for 64 bits integer
|
||||
There has been many request to add support for 64 bits integer. Use case for this are:
|
||||
- time is nowdays commonly represented with a 64 bits integer
|
||||
- 64 bits integer are frequently used as primary key id in many systems
|
||||
|
||||
Plans to add support is:
|
||||
- must be optional, a configuration option since not all platforms provides 64 bits integer types.
|
||||
- move definition of Int and UInt from forwards.h to config.h, with the required platform magic.
|
||||
- C++ defines no standard to define 64 bits integer. Rely on msvc extension, and long long type that
|
||||
is widely supported.
|
||||
\section ms_release Makes JsonCpp ready for release
|
||||
- Build system clean-up:
|
||||
- Fix build on Windows (shared-library build is broken)
|
||||
@@ -34,7 +24,7 @@
|
||||
Some typical use-case involve an application specific structure to/from a JSON document.
|
||||
- Event base parser to allow unserializing a Json document directly in datastructure instead of
|
||||
using the intermediate Json::Value.
|
||||
- "Stream" based parser to serialized a Json document without using Json::Value as input.
|
||||
- Stream based parser to serialized a Json document without using Json::Value as input.
|
||||
- Performance oriented parser/writer:
|
||||
- Provides an event based parser. Should allow pulling & skipping events for ease of use.
|
||||
- Provides a JSON document builder: fast only.
|
||||
@@ -42,4 +32,6 @@
|
||||
- Provides support for static property name definition avoiding allocation
|
||||
- Static property dictionnary can be provided to JSON reader
|
||||
- Performance scenario & benchmarking
|
||||
\section testing Testing
|
||||
- Adds more tests for unicode parsing (e.g. including surrogate and error detection).
|
||||
*/
|
||||
|
@@ -28,6 +28,12 @@
|
||||
/// instead of C assert macro.
|
||||
# define JSON_USE_EXCEPTION 1
|
||||
|
||||
/// 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_AMALGAMATION
|
||||
|
||||
|
||||
# ifdef JSON_IN_CPPTL
|
||||
# include <cpptl/config.h>
|
||||
# ifndef JSON_USE_CPPTL
|
||||
|
@@ -6,7 +6,9 @@
|
||||
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
# define CPPTL_JSON_FEATURES_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
|
@@ -6,7 +6,9 @@
|
||||
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||
# define JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
|
@@ -6,8 +6,10 @@
|
||||
#ifndef CPPTL_JSON_READER_H_INCLUDED
|
||||
# define CPPTL_JSON_READER_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "features.h"
|
||||
# include "value.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <deque>
|
||||
# include <stack>
|
||||
# include <string>
|
||||
@@ -49,7 +51,9 @@ namespace Json {
|
||||
bool collectComments = true );
|
||||
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
|
||||
* \param document UTF-8 encoded string containing the document to read.
|
||||
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the document to read.
|
||||
* \param endDoc Pointer on the end of the UTF-8 encoded string of the document to read.
|
||||
\ Must be >= beginDoc.
|
||||
* \param root [out] Contains the root value of the document if it was
|
||||
* successfully parsed.
|
||||
* \param collectComments \c true to collect comment and allow writing them back during
|
||||
@@ -193,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,7 +6,9 @@
|
||||
#ifndef CPPTL_JSON_H_INCLUDED
|
||||
# define CPPTL_JSON_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <string>
|
||||
# include <vector>
|
||||
|
||||
@@ -130,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:
|
||||
@@ -200,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 );
|
||||
@@ -254,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;
|
||||
@@ -313,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,7 +6,9 @@
|
||||
#ifndef JSON_WRITER_H_INCLUDED
|
||||
# define JSON_WRITER_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include "value.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <vector>
|
||||
# include <string>
|
||||
# include <iostream>
|
||||
|
@@ -6,7 +6,7 @@ Example of invocation (use to test the script):
|
||||
python makerelease.py --platform=msvc6,msvc71,msvc80,msvc90,mingw -ublep 0.6.0 0.7.0-dev
|
||||
|
||||
When testing this script:
|
||||
python makerelease.py --force --retag --platform=msvc6,msvc71,msvc80,mingw -ublep test-0.5.0 test-0.6.0-dev
|
||||
python makerelease.py --force --retag --platform=msvc6,msvc71,msvc80,mingw -ublep test-0.6.0 test-0.6.1-dev
|
||||
|
||||
Example of invocation when doing a release:
|
||||
python makerelease.py 0.5.0 0.6.0-dev
|
||||
@@ -23,6 +23,7 @@ import tempfile
|
||||
import os
|
||||
import time
|
||||
from devtools import antglob, fixeol, tarball
|
||||
import amalgamate
|
||||
|
||||
SVN_ROOT = 'https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/'
|
||||
SVN_TAG_ROOT = SVN_ROOT + 'tags/jsoncpp'
|
||||
@@ -322,6 +323,14 @@ 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 )
|
||||
|
||||
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'
|
||||
distcheck_top_dir = distcheck_dir + '/' + source_dir
|
||||
|
@@ -4,7 +4,8 @@
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
// included by json_value.cpp
|
||||
// everything is within Json namespace
|
||||
|
||||
namespace Json {
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
@@ -451,3 +452,5 @@ ValueInternalArray::compare( const ValueInternalArray &other ) const
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
|
@@ -4,7 +4,8 @@
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
// included by json_value.cpp
|
||||
// everything is within Json namespace
|
||||
|
||||
namespace Json {
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
@@ -610,3 +611,5 @@ ValueInternalMap::distance( const IteratorState &x, const IteratorState &y )
|
||||
increment( it );
|
||||
return offset;
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
|
@@ -3,9 +3,11 @@
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#include <json/reader.h>
|
||||
#include <json/value.h>
|
||||
#include "json_tool.h"
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <json/reader.h>
|
||||
# include <json/value.h>
|
||||
# include "json_tool.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <utility>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
@@ -447,7 +449,7 @@ Reader::readString()
|
||||
|
||||
|
||||
bool
|
||||
Reader::readObject( Token &tokenStart )
|
||||
Reader::readObject( Token &/*tokenStart*/ )
|
||||
{
|
||||
Token tokenName;
|
||||
std::string name;
|
||||
@@ -486,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,
|
||||
@@ -506,7 +508,7 @@ Reader::readObject( Token &tokenStart )
|
||||
|
||||
|
||||
bool
|
||||
Reader::readArray( Token &tokenStart )
|
||||
Reader::readArray( Token &/*tokenStart*/ )
|
||||
{
|
||||
currentValue() = Value( arrayValue );
|
||||
skipSpaces();
|
||||
@@ -517,7 +519,7 @@ Reader::readArray( Token &tokenStart )
|
||||
return true;
|
||||
}
|
||||
int index = 0;
|
||||
while ( true )
|
||||
for (;;)
|
||||
{
|
||||
Value &value = currentValue()[ index++ ];
|
||||
nodes_.push( &value );
|
||||
@@ -760,7 +762,7 @@ Reader::recoverFromError( TokenType skipUntilToken )
|
||||
{
|
||||
int errorCount = int(errors_.size());
|
||||
Token skip;
|
||||
while ( true )
|
||||
for (;;)
|
||||
{
|
||||
if ( !readToken(skip) )
|
||||
errors_.resize( errorCount ); // discard errors caused by recovery
|
||||
|
@@ -3,9 +3,14 @@
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#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_AMALGAMATION)
|
||||
#include <iostream>
|
||||
#include <json/value.h>
|
||||
#include <json/writer.h>
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
@@ -14,13 +19,11 @@
|
||||
# include <cpptl/conststring.h>
|
||||
#endif
|
||||
#include <cstddef> // size_t
|
||||
#ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||
# include "json_batchallocator.h"
|
||||
#endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
|
||||
|
||||
#define JSON_ASSERT_UNREACHABLE assert( false )
|
||||
#define JSON_ASSERT( condition ) assert( condition ); // @todo <= change this into an exception throw
|
||||
#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) throw std::runtime_error( message );
|
||||
#define JSON_FAIL_MESSAGE( message ) throw std::runtime_error( message );
|
||||
#define JSON_ASSERT_MESSAGE( condition, message ) if (!( condition )) JSON_FAIL_MESSAGE( message )
|
||||
|
||||
namespace Json {
|
||||
|
||||
@@ -37,7 +40,7 @@ const LargestUInt Value::maxLargestUInt = LargestUInt(-1);
|
||||
|
||||
|
||||
/// Unknown size marker
|
||||
enum { unknown = (unsigned)-1 };
|
||||
static const unsigned int unknown = (unsigned)-1;
|
||||
|
||||
|
||||
/** Duplicates the specified string value.
|
||||
@@ -70,6 +73,7 @@ releaseStringValue( char *value )
|
||||
free( value );
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
@@ -79,13 +83,16 @@ releaseStringValue( char *value )
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
#ifdef JSON_VALUE_USE_INTERNAL_MAP
|
||||
# include "json_internalarray.inl"
|
||||
# include "json_internalmap.inl"
|
||||
#endif // JSON_VALUE_USE_INTERNAL_MAP
|
||||
#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_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
@@ -517,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
|
||||
{
|
||||
@@ -587,13 +575,13 @@ Value::operator <( const Value &other ) const
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
return 0; // unreachable
|
||||
return false; // unreachable
|
||||
}
|
||||
|
||||
bool
|
||||
Value::operator <=( const Value &other ) const
|
||||
{
|
||||
return !(other > *this);
|
||||
return !(other < *this);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -649,7 +637,7 @@ Value::operator ==( const Value &other ) const
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
return 0; // unreachable
|
||||
return false; // unreachable
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -682,7 +670,7 @@ Value::asString() const
|
||||
case realValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to string" );
|
||||
JSON_FAIL_MESSAGE( "Type is not convertible to string" );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@@ -719,7 +707,7 @@ Value::asInt() const
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to int" );
|
||||
JSON_FAIL_MESSAGE( "Type is not convertible to int" );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@@ -749,7 +737,7 @@ Value::asUInt() const
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to uint" );
|
||||
JSON_FAIL_MESSAGE( "Type is not convertible to uint" );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@@ -779,7 +767,7 @@ Value::asInt64() const
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to Int64" );
|
||||
JSON_FAIL_MESSAGE( "Type is not convertible to Int64" );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@@ -807,7 +795,7 @@ Value::asUInt64() const
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to UInt64" );
|
||||
JSON_FAIL_MESSAGE( "Type is not convertible to UInt64" );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@@ -820,9 +808,9 @@ LargestInt
|
||||
Value::asLargestInt() const
|
||||
{
|
||||
#if defined(JSON_NO_INT64)
|
||||
return asInt();
|
||||
return asInt();
|
||||
#else
|
||||
return asInt64();
|
||||
return asInt64();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -831,9 +819,9 @@ LargestUInt
|
||||
Value::asLargestUInt() const
|
||||
{
|
||||
#if defined(JSON_NO_INT64)
|
||||
return asUInt();
|
||||
return asUInt();
|
||||
#else
|
||||
return asUInt64();
|
||||
return asUInt64();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -860,7 +848,7 @@ Value::asDouble() const
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to double" );
|
||||
JSON_FAIL_MESSAGE( "Type is not convertible to double" );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
@@ -889,7 +877,7 @@ Value::asFloat() const
|
||||
case stringValue:
|
||||
case arrayValue:
|
||||
case objectValue:
|
||||
JSON_ASSERT_MESSAGE( false, "Type is not convertible to float" );
|
||||
JSON_FAIL_MESSAGE( "Type is not convertible to float" );
|
||||
default:
|
||||
JSON_ASSERT_UNREACHABLE;
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
// included by json_value.cpp
|
||||
// everything is within Json namespace
|
||||
|
||||
namespace Json {
|
||||
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
// //////////////////////////////////////////////////////////////////
|
||||
@@ -295,3 +295,5 @@ ValueIterator::operator =( const SelfType &other )
|
||||
copy( other );
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
|
@@ -3,8 +3,10 @@
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#include <json/writer.h>
|
||||
#include "json_tool.h"
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
# include <json/writer.h>
|
||||
# include "json_tool.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <utility>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
@@ -330,7 +332,7 @@ StyledWriter::writeValue( const Value &value )
|
||||
writeWithIndent( "{" );
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
while ( true )
|
||||
for (;;)
|
||||
{
|
||||
const std::string &name = *it;
|
||||
const Value &childValue = value[name];
|
||||
@@ -370,7 +372,7 @@ StyledWriter::writeArrayValue( const Value &value )
|
||||
indent();
|
||||
bool hasChildValue = !childValues_.empty();
|
||||
unsigned index =0;
|
||||
while ( true )
|
||||
for (;;)
|
||||
{
|
||||
const Value &childValue = value[index];
|
||||
writeCommentBeforeValue( childValue );
|
||||
@@ -606,7 +608,7 @@ StyledStreamWriter::writeValue( const Value &value )
|
||||
writeWithIndent( "{" );
|
||||
indent();
|
||||
Value::Members::iterator it = members.begin();
|
||||
while ( true )
|
||||
for (;;)
|
||||
{
|
||||
const std::string &name = *it;
|
||||
const Value &childValue = value[name];
|
||||
@@ -646,7 +648,7 @@ StyledStreamWriter::writeArrayValue( const Value &value )
|
||||
indent();
|
||||
bool hasChildValue = !childValues_.empty();
|
||||
unsigned index =0;
|
||||
while ( true )
|
||||
for (;;)
|
||||
{
|
||||
const Value &childValue = value[index];
|
||||
writeCommentBeforeValue( childValue );
|
||||
@@ -654,7 +656,7 @@ StyledStreamWriter::writeArrayValue( const Value &value )
|
||||
writeWithIndent( childValues_[index] );
|
||||
else
|
||||
{
|
||||
writeIndent();
|
||||
writeIndent();
|
||||
writeValue( childValue );
|
||||
}
|
||||
if ( ++index == size )
|
||||
|
@@ -37,6 +37,7 @@ struct ValueTest : JsonTest::TestCase
|
||||
Json::Value true_;
|
||||
Json::Value false_;
|
||||
|
||||
|
||||
ValueTest()
|
||||
: emptyArray_( Json::arrayValue )
|
||||
, emptyObject_( Json::objectValue )
|
||||
@@ -77,6 +78,10 @@ struct ValueTest : JsonTest::TestCase
|
||||
void checkMemberCount( Json::Value &value, unsigned int expectedCount );
|
||||
|
||||
void checkIs( const Json::Value &value, const IsCheck &check );
|
||||
|
||||
void checkIsLess( const Json::Value &x, const Json::Value &y );
|
||||
|
||||
void checkIsEqual( const Json::Value &x, const Json::Value &y );
|
||||
};
|
||||
|
||||
|
||||
@@ -251,6 +256,151 @@ 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 ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( 10, 10 ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( -10, -10 ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( -10, 0 ) );
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareUInt )
|
||||
{
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( 0u, 10u ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( 0u, Json::Value::maxUInt ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( 10u, 10u ) );
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareDouble )
|
||||
{
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( 0.0, 10.0 ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( 10.0, 10.0 ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( -10.0, -10.0 ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( -10.0, 0.0 ) );
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareString )
|
||||
{
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( "", " " ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( "", "a" ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( "abcd", "zyui" ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( "abc", "abcd" ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( "abcd", "abcd" ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( " ", " " ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( "ABCD", "abcd" ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( "ABCD", "ABCD" ) );
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareBoolean )
|
||||
{
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( false, true ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( false, false ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( true, true ) );
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareArray )
|
||||
{
|
||||
// array compare size then content
|
||||
Json::Value emptyArray(Json::arrayValue);
|
||||
Json::Value l1aArray;
|
||||
l1aArray.append( 0 );
|
||||
Json::Value l1bArray;
|
||||
l1bArray.append( 10 );
|
||||
Json::Value l2aArray;
|
||||
l2aArray.append( 0 );
|
||||
l2aArray.append( 0 );
|
||||
Json::Value l2bArray;
|
||||
l2bArray.append( 0 );
|
||||
l2bArray.append( 10 );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( emptyArray, l1aArray ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( emptyArray, l2aArray ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( l1aArray, l2aArray ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( l2aArray, l2bArray ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( emptyArray, Json::Value( emptyArray ) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( l1aArray, Json::Value( l1aArray) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( l2bArray, Json::Value( l2bArray) ) );
|
||||
}
|
||||
|
||||
|
||||
JSONTEST_FIXTURE( ValueTest, compareObject )
|
||||
{
|
||||
// object compare size then content
|
||||
Json::Value emptyObject(Json::objectValue);
|
||||
Json::Value l1aObject;
|
||||
l1aObject["key1"] = 0;
|
||||
Json::Value l1bObject;
|
||||
l1aObject["key1"] = 10;
|
||||
Json::Value l2aObject;
|
||||
l2aObject["key1"] = 0;
|
||||
l2aObject["key2"] = 0;
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( emptyObject, l1aObject ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( emptyObject, l2aObject ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsLess( l1aObject, l2aObject ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( emptyObject, Json::Value( emptyObject ) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( l1aObject, Json::Value( l1aObject ) ) );
|
||||
JSONTEST_ASSERT_PRED( checkIsEqual( l2aObject, Json::Value( l2aObject ) ) );
|
||||
}
|
||||
|
||||
|
||||
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 )
|
||||
{
|
||||
JSONTEST_ASSERT( x < y );
|
||||
JSONTEST_ASSERT( y > x );
|
||||
JSONTEST_ASSERT( x <= y );
|
||||
JSONTEST_ASSERT( y >= x );
|
||||
JSONTEST_ASSERT( !(x == y) );
|
||||
JSONTEST_ASSERT( !(y == x) );
|
||||
JSONTEST_ASSERT( !(x >= 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 );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ValueTest::checkIsEqual( const Json::Value &x, const Json::Value &y )
|
||||
{
|
||||
JSONTEST_ASSERT( x == y );
|
||||
JSONTEST_ASSERT( y == x );
|
||||
JSONTEST_ASSERT( x <= y );
|
||||
JSONTEST_ASSERT( y <= x );
|
||||
JSONTEST_ASSERT( x >= y );
|
||||
JSONTEST_ASSERT( y >= x );
|
||||
JSONTEST_ASSERT( !(x < 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 );
|
||||
}
|
||||
|
||||
|
||||
int main( int argc, const char *argv[] )
|
||||
{
|
||||
@@ -267,5 +417,14 @@ 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 );
|
||||
JSONTEST_REGISTER_FIXTURE( runner, ValueTest, compareString );
|
||||
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 );
|
||||
}
|
||||
|
Reference in New Issue
Block a user