mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-27 11:21:02 +08:00
Merge pull request #201 from open-source-parsers/vs
* Copy .dll for running unit-tests in VisualStudio. * Stop using `do{}while(0)` idiom b/c VisualStudio warns. * Fix a warning in a test.
This commit is contained in:
commit
f50145fbda
@ -16,11 +16,15 @@
|
|||||||
#if JSON_USE_EXCEPTION
|
#if JSON_USE_EXCEPTION
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#define JSON_ASSERT(condition) \
|
#define JSON_ASSERT(condition) \
|
||||||
if (!(condition)) {throw std::logic_error( "assert json failed" );} // @todo <= add detail about condition in exception
|
{if (!(condition)) {throw std::logic_error( "assert json failed" );}} // @todo <= add detail about condition in exception
|
||||||
#define JSON_FAIL_MESSAGE(message) do{std::ostringstream oss; oss << message; throw std::logic_error(oss.str());}while(0)
|
#define JSON_FAIL_MESSAGE(message) \
|
||||||
|
{ \
|
||||||
|
std::ostringstream oss; oss << message; \
|
||||||
|
throw std::logic_error(oss.str()); \
|
||||||
|
}
|
||||||
//#define JSON_FAIL_MESSAGE(message) throw std::logic_error(message)
|
//#define JSON_FAIL_MESSAGE(message) throw std::logic_error(message)
|
||||||
#else // JSON_USE_EXCEPTION
|
#else // JSON_USE_EXCEPTION
|
||||||
#define JSON_ASSERT(condition) assert(condition);
|
#define JSON_ASSERT(condition) assert(condition)
|
||||||
|
|
||||||
// The call to assert() will show the failure message in debug builds. In
|
// The call to assert() will show the failure message in debug builds. In
|
||||||
// release bugs we abort, for a core-dump or debugger.
|
// release bugs we abort, for a core-dump or debugger.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# vim: et ts=4 sts=4 sw=4 tw=0
|
||||||
|
|
||||||
IF(JSONCPP_LIB_BUILD_SHARED)
|
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
ADD_DEFINITIONS( -DJSON_DLL )
|
ADD_DEFINITIONS( -DJSON_DLL )
|
||||||
@ -22,9 +23,19 @@ ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
|||||||
# Run unit tests in post-build
|
# Run unit tests in post-build
|
||||||
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
|
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
|
||||||
IF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
IF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
||||||
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
|
IF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
POST_BUILD
|
# First, copy the shared lib, for Microsoft.
|
||||||
COMMAND $<TARGET_FILE:jsoncpp_test>)
|
# Then, run the test executable.
|
||||||
|
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:jsoncpp_lib> $<TARGET_FILE_DIR:jsoncpp_test>
|
||||||
|
COMMAND $<TARGET_FILE:jsoncpp_test>)
|
||||||
|
ELSE(JSONCPP_LIB_BUILD_SHARED)
|
||||||
|
# Just run the test executable.
|
||||||
|
ADD_CUSTOM_COMMAND( TARGET jsoncpp_test
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND $<TARGET_FILE:jsoncpp_test>)
|
||||||
|
ENDIF(JSONCPP_LIB_BUILD_SHARED)
|
||||||
ENDIF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
ENDIF(JSONCPP_WITH_POST_BUILD_UNITTEST)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
|
SET_TARGET_PROPERTIES(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
|
||||||
|
@ -2203,7 +2203,7 @@ JSONTEST_FIXTURE(IteratorTest, distance) {
|
|||||||
Json::Value json;
|
Json::Value json;
|
||||||
json["k1"] = "a";
|
json["k1"] = "a";
|
||||||
json["k2"] = "b";
|
json["k2"] = "b";
|
||||||
int dist;
|
int dist = 0;
|
||||||
std::string str;
|
std::string str;
|
||||||
for (Json::ValueIterator it = json.begin(); it != json.end(); ++it) {
|
for (Json::ValueIterator it = json.begin(); it != json.end(); ++it) {
|
||||||
dist = it - json.begin();
|
dist = it - json.begin();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user