test commentBefore

for issue #203
This commit is contained in:
Christopher Dunn 2015-03-06 05:52:22 -06:00
parent 2fc08b4ebd
commit 80ca11bb41

View File

@ -1541,6 +1541,22 @@ JSONTEST_FIXTURE(ValueTest, StaticString) {
}
}
JSONTEST_FIXTURE(ValueTest, CommentBefore) {
Json::Value val; // fill val
val.setComment("// this comment should appear before", Json::CommentPlacement::commentBefore);
// Configure the Builder, then ...
Json::StreamWriterBuilder wbuilder;
wbuilder.settings_["commentStyle"] = "All";
char const expected[] = "// this comment should appear before\nnull";
std::string result = Json::writeString(wbuilder, val);
JSONTEST_ASSERT_STRING_EQUAL(expected, result);
std::string res2 = val.toStyledString();
std::string exp2 = "\n";
exp2 += expected;
exp2 += "\n";
JSONTEST_ASSERT_STRING_EQUAL(exp2, res2);
}
JSONTEST_FIXTURE(ValueTest, zeroes) {
std::string binary("hi", 3); // include trailing 0
JSONTEST_ASSERT_EQUAL(3, binary.length());
@ -2239,6 +2255,7 @@ int main(int argc, const char* argv[]) {
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, offsetAccessors);
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, typeChecksThrowExceptions);
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, StaticString);
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, CommentBefore);
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroes);
JSONTEST_REGISTER_FIXTURE(runner, ValueTest, zeroesInKeys);