Major rework of 64 integer support: 64 bits integer are only returned when explicitly request via Json::Value::asInt64(), unlike previous implementation where Json::Value::asInt() returned a 64 bits integer.
This eases porting portable code and does not break compatibility with the previous release.
Json::Value::asLargestInt() has also be added to ease writing portable code independent of 64 bits integer support. It is typically used to implement writers.
diff --git a/src/jsontestrunner/main.cpp b/src/jsontestrunner/main.cpp
index 67344e0..2da3ede 100644
--- a/src/jsontestrunner/main.cpp
+++ b/src/jsontestrunner/main.cpp
@@ -44,10 +44,10 @@
fprintf( fout, "%s=null\n", path.c_str() );
break;
case Json::intValue:
- fprintf( fout, "%s=%s\n", path.c_str(), Json::valueToString( value.asInt() ).c_str() );
+ fprintf( fout, "%s=%s\n", path.c_str(), Json::valueToString( value.asLargestInt() ).c_str() );
break;
case Json::uintValue:
- fprintf( fout, "%s=%s\n", path.c_str(), Json::valueToString( value.asUInt() ).c_str() );
+ fprintf( fout, "%s=%s\n", path.c_str(), Json::valueToString( value.asLargestUInt() ).c_str() );
break;
case Json::realValue:
fprintf( fout, "%s=%.16g\n", path.c_str(), value.asDouble() );
@@ -224,36 +224,44 @@
return exitCode;
}
- std::string input = readInputTestFile( path.c_str() );
- if ( input.empty() )
+ try
{
- printf( "Failed to read input or empty input: %s\n", path.c_str() );
- return 3;
- }
-
- std::string basePath = removeSuffix( argv[1], ".json" );
- if ( !parseOnly && basePath.empty() )
- {
- printf( "Bad input path. Path does not end with '.expected':\n%s\n", path.c_str() );
- return 3;
- }
-
- std::string actualPath = basePath + ".actual";
- std::string rewritePath = basePath + ".rewrite";
- std::string rewriteActualPath = basePath + ".actual-rewrite";
-
- Json::Value root;
- exitCode = parseAndSaveValueTree( input, actualPath, "input", root, features, parseOnly );
- if ( exitCode == 0 && !parseOnly )
- {
- std::string rewrite;
- exitCode = rewriteValueTree( rewritePath, root, rewrite );
- if ( exitCode == 0 )
+ std::string input = readInputTestFile( path.c_str() );
+ if ( input.empty() )
{
- Json::Value rewriteRoot;
- exitCode = parseAndSaveValueTree( rewrite, rewriteActualPath,
- "rewrite", rewriteRoot, features, parseOnly );
+ printf( "Failed to read input or empty input: %s\n", path.c_str() );
+ return 3;
}
+
+ std::string basePath = removeSuffix( argv[1], ".json" );
+ if ( !parseOnly && basePath.empty() )
+ {
+ printf( "Bad input path. Path does not end with '.expected':\n%s\n", path.c_str() );
+ return 3;
+ }
+
+ std::string actualPath = basePath + ".actual";
+ std::string rewritePath = basePath + ".rewrite";
+ std::string rewriteActualPath = basePath + ".actual-rewrite";
+
+ Json::Value root;
+ exitCode = parseAndSaveValueTree( input, actualPath, "input", root, features, parseOnly );
+ if ( exitCode == 0 && !parseOnly )
+ {
+ std::string rewrite;
+ exitCode = rewriteValueTree( rewritePath, root, rewrite );
+ if ( exitCode == 0 )
+ {
+ Json::Value rewriteRoot;
+ exitCode = parseAndSaveValueTree( rewrite, rewriteActualPath,
+ "rewrite", rewriteRoot, features, parseOnly );
+ }
+ }
+ }
+ catch ( const std::exception &e )
+ {
+ printf( "Unhandled exception:\n%s\n", e.what() );
+ exitCode = 1;
}
return exitCode;