diff options
Diffstat (limited to 'lib/jsoncpp/src/test_lib_json')
-rw-r--r-- | lib/jsoncpp/src/test_lib_json/jsontest.cpp | 10 | ||||
-rw-r--r-- | lib/jsoncpp/src/test_lib_json/jsontest.h | 9 | ||||
-rw-r--r-- | lib/jsoncpp/src/test_lib_json/main.cpp | 27 |
3 files changed, 45 insertions, 1 deletions
diff --git a/lib/jsoncpp/src/test_lib_json/jsontest.cpp b/lib/jsoncpp/src/test_lib_json/jsontest.cpp index dfd2b5c77d..02e7b21699 100644 --- a/lib/jsoncpp/src/test_lib_json/jsontest.cpp +++ b/lib/jsoncpp/src/test_lib_json/jsontest.cpp @@ -1,3 +1,8 @@ +// Copyright 2007-2010 Baptiste Lepilleur +// Distributed under MIT license, or public domain if desired and +// recognized in your jurisdiction. +// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE + #define _CRT_SECURE_NO_WARNINGS 1 // Prevents deprecation warning with MSVC #include "jsontest.h" #include <stdio.h> @@ -304,6 +309,11 @@ TestCase::TestCase() } +TestCase::~TestCase() +{ +} + + void TestCase::run( TestResult &result ) { diff --git a/lib/jsoncpp/src/test_lib_json/jsontest.h b/lib/jsoncpp/src/test_lib_json/jsontest.h index b2553baea1..0d072382e1 100644 --- a/lib/jsoncpp/src/test_lib_json/jsontest.h +++ b/lib/jsoncpp/src/test_lib_json/jsontest.h @@ -1,3 +1,8 @@ +// Copyright 2007-2010 Baptiste Lepilleur +// Distributed under MIT license, or public domain if desired and +// recognized in your jurisdiction. +// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE + #ifndef JSONTEST_H_INCLUDED # define JSONTEST_H_INCLUDED @@ -110,6 +115,8 @@ namespace JsonTest { public: TestCase(); + virtual ~TestCase(); + void run( TestResult &result ); virtual const char *testName() const = 0; @@ -192,7 +199,7 @@ namespace JsonTest { /// JSONTEST_ASSERT( x == y ) << "x=" << x << ", y=" << y; /// JSONTEST_ASSERT( x == y ); #define JSONTEST_ASSERT( expr ) \ - if ( condition ) \ + if ( expr ) \ { \ } \ else \ diff --git a/lib/jsoncpp/src/test_lib_json/main.cpp b/lib/jsoncpp/src/test_lib_json/main.cpp index b80776d630..de64200ce7 100644 --- a/lib/jsoncpp/src/test_lib_json/main.cpp +++ b/lib/jsoncpp/src/test_lib_json/main.cpp @@ -1,3 +1,8 @@ +// Copyright 2007-2010 Baptiste Lepilleur +// Distributed under MIT license, or public domain if desired and +// recognized in your jurisdiction. +// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE + #include <json/json.h> #include "jsontest.h" @@ -23,6 +28,7 @@ struct ValueTest : JsonTest::TestCase Json::Value unsignedInteger_; Json::Value smallUnsignedInteger_; Json::Value real_; + Json::Value float_; Json::Value array1_; Json::Value object1_; Json::Value emptyString_; @@ -38,6 +44,7 @@ struct ValueTest : JsonTest::TestCase , smallUnsignedInteger_( Json::Value::UInt( Json::Value::maxInt ) ) , unsignedInteger_( 34567890u ) , real_( 1234.56789 ) + , float_( 0.00390625f ) , emptyString_( "" ) , string1_( "a" ) , string_( "sometext with space" ) @@ -167,6 +174,23 @@ JSONTEST_FIXTURE( ValueTest, isUInt ) } +JSONTEST_FIXTURE( ValueTest, accessArray ) +{ + const unsigned int index0 = 0; + JSONTEST_ASSERT( Json::Value(1234) == array1_[index0] ) << "Json::Value::operator[ArrayIndex]"; + JSONTEST_ASSERT( Json::Value(1234) == array1_[0] ) << "Json::Value::operator[int]"; + + const Json::Value &constArray = array1_; + JSONTEST_ASSERT( Json::Value(1234) == constArray[index0] ) << "Json::Value::operator[ArrayIndex] const"; + JSONTEST_ASSERT( Json::Value(1234) == constArray[0] ) << "Json::Value::operator[int] const"; +} + + +JSONTEST_FIXTURE( ValueTest, asFloat ) +{ + JSONTEST_ASSERT_EQUAL( 0.00390625f, float_.asFloat() ) << "Json::Value::asFloat()"; +} + void ValueTest::checkConstMemberCount( const Json::Value &value, unsigned int expectedCount ) { @@ -240,5 +264,8 @@ int main( int argc, const char *argv[] ) JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isDouble ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isString ); JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isNull ); + JSONTEST_REGISTER_FIXTURE( runner, ValueTest, isNull ); + JSONTEST_REGISTER_FIXTURE( runner, ValueTest, accessArray ); + JSONTEST_REGISTER_FIXTURE( runner, ValueTest, asFloat ); return runner.runCommandLine( argc, argv ); } |