Add tests for the simple json parser.

This commit is contained in:
Todd C. Miller
2020-03-29 05:05:08 -06:00
parent cffda82e20
commit 3cd9cbbadf
10 changed files with 563 additions and 53 deletions

View File

@@ -274,9 +274,14 @@ sudo_json_open_array_v1(struct json_container *json, const char *name)
json_append_indent(json, json->indent_level);
json_append_string(json, name);
if (!json_append_buf(json, ": ["))
debug_return_bool(false);
if (name != NULL) {
json_append_string(json, name);
if (!json_append_buf(json, ": ["))
debug_return_bool(false);
} else {
if (!json_append_buf(json, "["))
debug_return_bool(false);
}
json->indent_level += json->indent_increment;
json->need_comma = false;
@@ -300,7 +305,7 @@ sudo_json_close_array_v1(struct json_container *json)
debug_return_bool(true);
}
bool
static bool
sudo_json_add_value_int(struct json_container *json, const char *name,
struct json_value *value, bool as_object)
{