mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-12 10:03:51 +01:00
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:
parent
aa650c5b9d
commit
4d23492d11
@ -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,
|
||||
|
@ -1,2 +1,3 @@
|
||||
// C++ style comment
|
||||
.=null
|
||||
|
||||
|
@ -1,2 +1,4 @@
|
||||
/* C style comment
|
||||
*/
|
||||
.=null
|
||||
|
||||
|
@ -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
|
||||
|
@ -1 +1,2 @@
|
||||
// Max signed integer
|
||||
.=2147483647
|
||||
|
@ -1 +1,2 @@
|
||||
// Min signed integer
|
||||
.=-2147483648
|
||||
|
@ -1 +1,2 @@
|
||||
// Max unsigned integer
|
||||
.=4294967295
|
||||
|
@ -1,2 +1,3 @@
|
||||
// Min unsigned integer
|
||||
.=0
|
||||
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -1,2 +1,3 @@
|
||||
// 2^33 => out of integer range, switch to double
|
||||
.=8589934592
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
// -2^32 => out of signed integer range, switch to double
|
||||
.=-4294967295
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
// -2^32 => out of signed integer range, switch to double
|
||||
.=-4294967295
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
// 1.2345678
|
||||
.=1.2345678
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// 1234567.8
|
||||
.=1234567.8
|
||||
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// -1.2345678
|
||||
.=-1.2345678
|
||||
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// -1234567.8
|
||||
.=-1234567.8
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1 +1,2 @@
|
||||
// 2^64 -> switch to double.
|
||||
.=1.844674407370955e+19
|
||||
|
Loading…
Reference in New Issue
Block a user