Added printing of comments to *.actual test files

This enables testing of comment-handling code. Updated *.expected test
result files to account for printing of comments.
This commit is contained in:
Cory Quammen 2014-10-09 16:29:47 -04:00
parent aa650c5b9d
commit 4d23492d11
21 changed files with 49 additions and 0 deletions

View File

@ -61,6 +61,9 @@ static std::string readInputTestFile(const char* path) {
static void
printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") {
if (value.hasComment(Json::commentBefore)) {
fprintf(fout, "%s\n", value.getComment(Json::commentBefore).c_str());
}
switch (value.type()) {
case Json::nullValue:
fprintf(fout, "%s=null\n", path.c_str());
@ -117,6 +120,10 @@ printValueTree(FILE* fout, Json::Value& value, const std::string& path = ".") {
default:
break;
}
if (value.hasComment(Json::commentAfter)) {
fprintf(fout, "%s\n", value.getComment(Json::commentAfter).c_str());
}
}
static int parseAndSaveValueTree(const std::string& input,

View File

@ -1,2 +1,3 @@
// C++ style comment
.=null

View File

@ -1,2 +1,4 @@
/* C style comment
*/
.=null

View File

@ -1,7 +1,14 @@
.={}
/* C-style comment
C-style-2 comment */
.c-test={}
.c-test.a=1
/* Internal comment c-style */
.c-test.b=2
// C++-style comment
.cpp-test={}
// Multiline comment cpp-style
// Second line
.cpp-test.c=3
.cpp-test.d=4

View File

@ -1 +1,2 @@
// Max signed integer
.=2147483647

View File

@ -1 +1,2 @@
// Min signed integer
.=-2147483648

View File

@ -1 +1,2 @@
// Max unsigned integer
.=4294967295

View File

@ -1,2 +1,3 @@
// Min unsigned integer
.=0

View File

@ -1,3 +1,11 @@
/* A comment
at the beginning of the file.
*/
.={}
.first=1
/* Comment before 'second'
*/
.second=2
/* A comment at
the end of the file.
*/

View File

@ -1,2 +1,3 @@
// 2^33 => out of integer range, switch to double
.=8589934592

View File

@ -1,2 +1,3 @@
// -2^32 => out of signed integer range, switch to double
.=-4294967295

View File

@ -1,2 +1,3 @@
// -2^32 => out of signed integer range, switch to double
.=-4294967295

View File

@ -1,2 +1,3 @@
// 1.2345678
.=1.2345678

View File

@ -1,3 +1,4 @@
// 1234567.8
.=1234567.8

View File

@ -1,3 +1,4 @@
// -1.2345678
.=-1.2345678

View File

@ -1,3 +1,4 @@
// -1234567.8
.=-1234567.8

View File

@ -1 +1,4 @@
// Out of 32-bit integer range, switch to double in 32-bit mode. Length the
// same as UINT_MAX in base 10 and digit less than UINT_MAX's last digit in
// order to catch a bug in the parsing code.
.=4300000001

View File

@ -1 +1,4 @@
// Out of 64-bit integer range, switch to double in all modes. Length the same
// as ULONG_MAX in base 10 and digit less than ULONG_MAX's last digit in order
// to catch a bug in the parsing code.
.=1.9e+19

View File

@ -1 +1,4 @@
// Out of 32-bit signed integer range, switch to double in all modes. Length
// the same as INT_MIN in base 10 and digit less than INT_MIN's last digit in
// order to catch a bug in the parsing code.
.=-2200000001

View File

@ -1 +1,4 @@
// Out of 64-bit signed integer range, switch to double in all modes. Length
// the same as LONG_MIN in base 10 and digit less than LONG_MIN's last digit in
// order to catch a bug in the parsing code.
.=-9.3e+18

View File

@ -1 +1,2 @@
// 2^64 -> switch to double.
.=1.844674407370955e+19