mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-06-08 17:30:13 +02:00
parent
2e33c218cb
commit
7329223f58
@ -2054,16 +2054,16 @@ JSONTEST_FIXTURE(StyledWriterTest, multiLineArray) {
|
|||||||
{
|
{
|
||||||
// Array member has more than 20 print effect rendering lines
|
// Array member has more than 20 print effect rendering lines
|
||||||
const Json::String expected("[\n "
|
const Json::String expected("[\n "
|
||||||
"0,\n 1,\n 2,\n "
|
"0,\n 1,\n 2,\n "
|
||||||
"3,\n 4,\n 5,\n "
|
"3,\n 4,\n 5,\n "
|
||||||
"6,\n 7,\n 8,\n "
|
"6,\n 7,\n 8,\n "
|
||||||
"9,\n 10,\n 11,\n "
|
"9,\n 10,\n 11,\n "
|
||||||
"12,\n 13,\n 14,\n "
|
"12,\n 13,\n 14,\n "
|
||||||
"15,\n 16,\n 17,\n "
|
"15,\n 16,\n 17,\n "
|
||||||
"18,\n 19,\n 20\n]\n");
|
"18,\n 19,\n 20\n]\n");
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
for (int i = 0; i < 21; i++)
|
for (int i = 0; i < 21; i++)
|
||||||
root[i] = i;
|
root[i] = i;
|
||||||
const Json::String result = writer.write(root);
|
const Json::String result = writer.write(root);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
}
|
}
|
||||||
@ -2072,7 +2072,7 @@ JSONTEST_FIXTURE(StyledWriterTest, multiLineArray) {
|
|||||||
const Json::String expected("[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]\n");
|
const Json::String expected("[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]\n");
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
root[i] = i;
|
root[i] = i;
|
||||||
const Json::String result = writer.write(root);
|
const Json::String result = writer.write(root);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
}
|
}
|
||||||
@ -2083,8 +2083,7 @@ JSONTEST_FIXTURE(StyledWriterTest, writeValueWithComment) {
|
|||||||
{
|
{
|
||||||
const Json::String expected("\n//commentBeforeValue\n\"hello\"\n");
|
const Json::String expected("\n//commentBeforeValue\n\"hello\"\n");
|
||||||
Json::Value root = "hello";
|
Json::Value root = "hello";
|
||||||
root.setComment(Json::String("//commentBeforeValue"),
|
root.setComment(Json::String("//commentBeforeValue"), Json::commentBefore);
|
||||||
Json::commentBefore);
|
|
||||||
const Json::String result = writer.write(root);
|
const Json::String result = writer.write(root);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
}
|
}
|
||||||
@ -2099,8 +2098,7 @@ JSONTEST_FIXTURE(StyledWriterTest, writeValueWithComment) {
|
|||||||
{
|
{
|
||||||
const Json::String expected("\"hello\"\n//commentAfter\n\n");
|
const Json::String expected("\"hello\"\n//commentAfter\n\n");
|
||||||
Json::Value root = "hello";
|
Json::Value root = "hello";
|
||||||
root.setComment(Json::String("//commentAfter"),
|
root.setComment(Json::String("//commentAfter"), Json::commentAfter);
|
||||||
Json::commentAfter);
|
|
||||||
const Json::String result = writer.write(root);
|
const Json::String result = writer.write(root);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
}
|
}
|
||||||
@ -2177,44 +2175,42 @@ JSONTEST_FIXTURE(StyledStreamWriterTest, multiLineArray) {
|
|||||||
Json::StyledStreamWriter writer;
|
Json::StyledStreamWriter writer;
|
||||||
{
|
{
|
||||||
// Array member has more than 20 print effect rendering lines
|
// Array member has more than 20 print effect rendering lines
|
||||||
const Json::String expected(
|
const Json::String expected("[\n\t0,"
|
||||||
"["
|
"\n\t1,"
|
||||||
"\n\t0,"
|
"\n\t2,"
|
||||||
"\n\t1,"
|
"\n\t3,"
|
||||||
"\n\t2,"
|
"\n\t4,"
|
||||||
"\n\t3,"
|
"\n\t5,"
|
||||||
"\n\t4,"
|
"\n\t6,"
|
||||||
"\n\t5,"
|
"\n\t7,"
|
||||||
"\n\t6,"
|
"\n\t8,"
|
||||||
"\n\t7,"
|
"\n\t9,"
|
||||||
"\n\t8,"
|
"\n\t10,"
|
||||||
"\n\t9,"
|
"\n\t11,"
|
||||||
"\n\t10,"
|
"\n\t12,"
|
||||||
"\n\t11,"
|
"\n\t13,"
|
||||||
"\n\t12,"
|
"\n\t14,"
|
||||||
"\n\t13,"
|
"\n\t15,"
|
||||||
"\n\t14,"
|
"\n\t16,"
|
||||||
"\n\t15,"
|
"\n\t17,"
|
||||||
"\n\t16,"
|
"\n\t18,"
|
||||||
"\n\t17,"
|
"\n\t19,"
|
||||||
"\n\t18,"
|
"\n\t20\n]\n");
|
||||||
"\n\t19,"
|
|
||||||
"\n\t20\n]\n");
|
|
||||||
Json::StyledStreamWriter writer;
|
Json::StyledStreamWriter writer;
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
for (int i = 0; i < 21; i++)
|
for (int i = 0; i < 21; i++)
|
||||||
root[i] = i;
|
root[i] = i;
|
||||||
Json::OStringStream sout;
|
Json::OStringStream sout;
|
||||||
writer.write(sout, root);
|
writer.write(sout, root);
|
||||||
const Json::String result = sout.str();
|
const Json::String result = sout.str();
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// Array members do not exceed 21 print effects to render a single line
|
// Array members do not exceed 21 print effects to render a single line
|
||||||
const Json::String expected("[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]\n");
|
const Json::String expected("[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]\n");
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
root[i] = i;
|
root[i] = i;
|
||||||
Json::OStringStream sout;
|
Json::OStringStream sout;
|
||||||
writer.write(sout, root);
|
writer.write(sout, root);
|
||||||
const Json::String result = sout.str();
|
const Json::String result = sout.str();
|
||||||
@ -2228,8 +2224,7 @@ JSONTEST_FIXTURE(StyledStreamWriterTest, writeValueWithComment) {
|
|||||||
const Json::String expected("//commentBeforeValue\n\"hello\"\n");
|
const Json::String expected("//commentBeforeValue\n\"hello\"\n");
|
||||||
Json::Value root = "hello";
|
Json::Value root = "hello";
|
||||||
Json::OStringStream sout;
|
Json::OStringStream sout;
|
||||||
root.setComment(Json::String("//commentBeforeValue"),
|
root.setComment(Json::String("//commentBeforeValue"), Json::commentBefore);
|
||||||
Json::commentBefore);
|
|
||||||
writer.write(sout, root);
|
writer.write(sout, root);
|
||||||
const Json::String result = sout.str();
|
const Json::String result = sout.str();
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
@ -2248,8 +2243,7 @@ JSONTEST_FIXTURE(StyledStreamWriterTest, writeValueWithComment) {
|
|||||||
const Json::String expected("\"hello\"\n//commentAfter\n");
|
const Json::String expected("\"hello\"\n//commentAfter\n");
|
||||||
Json::Value root = "hello";
|
Json::Value root = "hello";
|
||||||
Json::OStringStream sout;
|
Json::OStringStream sout;
|
||||||
root.setComment(Json::String("//commentAfter"),
|
root.setComment(Json::String("//commentAfter"), Json::commentAfter);
|
||||||
Json::commentAfter);
|
|
||||||
writer.write(sout, root);
|
writer.write(sout, root);
|
||||||
const Json::String result = sout.str();
|
const Json::String result = sout.str();
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
@ -2326,42 +2320,41 @@ JSONTEST_FIXTURE(StreamWriterTest, multiLineArray) {
|
|||||||
wb.settings_["commentStyle"] = "None";
|
wb.settings_["commentStyle"] = "None";
|
||||||
{
|
{
|
||||||
// When wb.settings_["commentStyle"] = "None", the effect of
|
// When wb.settings_["commentStyle"] = "None", the effect of
|
||||||
// printing multiple lines will be displayed when there are
|
// printing multiple lines will be displayed when there are
|
||||||
// more than 20 array members.
|
// more than 20 array members.
|
||||||
const Json::String expected(
|
const Json::String expected("[\n\t0,"
|
||||||
"[\n\t0,"
|
"\n\t1,"
|
||||||
"\n\t1,"
|
"\n\t2,"
|
||||||
"\n\t2,"
|
"\n\t3,"
|
||||||
"\n\t3,"
|
"\n\t4,"
|
||||||
"\n\t4,"
|
"\n\t5,"
|
||||||
"\n\t5,"
|
"\n\t6,"
|
||||||
"\n\t6,"
|
"\n\t7,"
|
||||||
"\n\t7,"
|
"\n\t8,"
|
||||||
"\n\t8,"
|
"\n\t9,"
|
||||||
"\n\t9,"
|
"\n\t10,"
|
||||||
"\n\t10,"
|
"\n\t11,"
|
||||||
"\n\t11,"
|
"\n\t12,"
|
||||||
"\n\t12,"
|
"\n\t13,"
|
||||||
"\n\t13,"
|
"\n\t14,"
|
||||||
"\n\t14,"
|
"\n\t15,"
|
||||||
"\n\t15,"
|
"\n\t16,"
|
||||||
"\n\t16,"
|
"\n\t17,"
|
||||||
"\n\t17,"
|
"\n\t18,"
|
||||||
"\n\t18,"
|
"\n\t19,"
|
||||||
"\n\t19,"
|
"\n\t20\n]");
|
||||||
"\n\t20\n]");
|
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
for (int i = 0; i < 21; i++)
|
for (int i = 0; i < 21; i++)
|
||||||
root[i] = i;
|
root[i] = i;
|
||||||
const Json::String result = Json::writeString(wb, root);
|
const Json::String result = Json::writeString(wb, root);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
//Array members do not exceed 21 print effects to render a single line
|
// Array members do not exceed 21 print effects to render a single line
|
||||||
const Json::String expected("[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]");
|
const Json::String expected("[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]");
|
||||||
Json::Value root;
|
Json::Value root;
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
root[i] = i;
|
root[i] = i;
|
||||||
const Json::String result = Json::writeString(wb, root);
|
const Json::String result = Json::writeString(wb, root);
|
||||||
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
|
||||||
}
|
}
|
||||||
@ -3169,7 +3162,8 @@ int main(int argc, const char* argv[]) {
|
|||||||
JSONTEST_REGISTER_FIXTURE(runner, StyledStreamWriterTest, writeArrays);
|
JSONTEST_REGISTER_FIXTURE(runner, StyledStreamWriterTest, writeArrays);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, StyledStreamWriterTest, writeNestedObjects);
|
JSONTEST_REGISTER_FIXTURE(runner, StyledStreamWriterTest, writeNestedObjects);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, StyledStreamWriterTest, multiLineArray);
|
JSONTEST_REGISTER_FIXTURE(runner, StyledStreamWriterTest, multiLineArray);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, StyledStreamWriterTest, writeValueWithComment);
|
JSONTEST_REGISTER_FIXTURE(runner, StyledStreamWriterTest,
|
||||||
|
writeValueWithComment);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeNumericValue);
|
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeNumericValue);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeArrays);
|
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeArrays);
|
||||||
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeNestedObjects);
|
JSONTEST_REGISTER_FIXTURE(runner, StreamWriterTest, writeNestedObjects);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user