mirror of
https://github.com/dropbox/json11.git
synced 2024-11-27 07:59:50 +08:00
add malformed comment tests.
add 3 testes for: - unended multi-line comment, - malformed single-line comment, - trailing slash
This commit is contained in:
parent
d292fce9f2
commit
f21b8c360e
39
test.cpp
39
test.cpp
@ -80,6 +80,45 @@ int main(int argc, char **argv) {
|
|||||||
printf("Result: %s\n", json_comment.dump().c_str());
|
printf("Result: %s\n", json_comment.dump().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string failing_comment_test = R"({
|
||||||
|
/* bad comment
|
||||||
|
"a": 1,
|
||||||
|
})";
|
||||||
|
|
||||||
|
string err_failing_comment;
|
||||||
|
auto json_failing_comment = Json::parse(
|
||||||
|
failing_comment_test, err_failing_comment, /*detect_comments=*/ true);
|
||||||
|
if (!err_failing_comment.empty()) {
|
||||||
|
printf("Failed: %s\n", err_failing_comment.c_str());
|
||||||
|
} else {
|
||||||
|
printf("Result: %s\n", json_failing_comment.dump().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
failing_comment_test = R"({
|
||||||
|
/ / bad comment
|
||||||
|
"a": 1,
|
||||||
|
})";
|
||||||
|
|
||||||
|
json_failing_comment = Json::parse(
|
||||||
|
failing_comment_test, err_failing_comment, /*detect_comments=*/ true);
|
||||||
|
if (!err_failing_comment.empty()) {
|
||||||
|
printf("Failed: %s\n", err_failing_comment.c_str());
|
||||||
|
} else {
|
||||||
|
printf("Result: %s\n", json_failing_comment.dump().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
failing_comment_test = R"({
|
||||||
|
"a": 1,
|
||||||
|
}/)";
|
||||||
|
|
||||||
|
json_failing_comment = Json::parse(
|
||||||
|
failing_comment_test, err_failing_comment, /*detect_comments=*/ true);
|
||||||
|
if (!err_failing_comment.empty()) {
|
||||||
|
printf("Failed: %s\n", err_failing_comment.c_str());
|
||||||
|
} else {
|
||||||
|
printf("Result: %s\n", json_failing_comment.dump().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
std::list<int> l1 { 1, 2, 3 };
|
std::list<int> l1 { 1, 2, 3 };
|
||||||
std::vector<int> l2 { 1, 2, 3 };
|
std::vector<int> l2 { 1, 2, 3 };
|
||||||
std::set<int> l3 { 1, 2, 3 };
|
std::set<int> l3 { 1, 2, 3 };
|
||||||
|
Loading…
Reference in New Issue
Block a user