diff options
author | ZyX <kp-pav@yandex.ru> | 2017-10-16 00:39:48 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-10-16 00:39:48 +0300 |
commit | ed253b5fe6515840fe6dd9df83855a0316de8bad (patch) | |
tree | c9bf36d8973b8ec248430d04b0a64b9b20ffb99f | |
parent | fe81380bf5d4d161187998088aa9cff948b7c891 (diff) | |
download | rneovim-ed253b5fe6515840fe6dd9df83855a0316de8bad.tar.gz rneovim-ed253b5fe6515840fe6dd9df83855a0316de8bad.tar.bz2 rneovim-ed253b5fe6515840fe6dd9df83855a0316de8bad.zip |
klee: Include colors in test
-rw-r--r-- | src/nvim/viml/parser/parser.h | 5 | ||||
-rw-r--r-- | test/symbolic/klee/viml_expressions_parser.c | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index 10ced57977..fbc5ba5f07 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -176,8 +176,9 @@ static inline void viml_parser_highlight(ParserState *const pstate, if (pstate->colors == NULL || len == 0) { return; } - // TODO(ZyX-I): May do some assert() sanitizing here. - // TODO(ZyX-I): May join chunks. + assert(kv_size(*pstate->colors) == 0 + || kv_Z(*pstate->colors, 0).start.line < start.line + || kv_Z(*pstate->colors, 0).end_col <= start.col); kvi_push(*pstate->colors, ((ParserHighlightChunk) { .start = start, .end_col = start.col + len, diff --git a/test/symbolic/klee/viml_expressions_parser.c b/test/symbolic/klee/viml_expressions_parser.c index ed280adb22..8f015ae9a7 100644 --- a/test/symbolic/klee/viml_expressions_parser.c +++ b/test/symbolic/klee/viml_expressions_parser.c @@ -75,6 +75,9 @@ int main(const int argc, const char *const *const argv, #endif ParserLine *cur_pline = &plines[0]; + ParserHighlight colors; + kvi_init(colors); + ParserState pstate = { .reader = { .get_line = simple_get_line, @@ -83,13 +86,18 @@ int main(const int argc, const char *const *const argv, .conv.vc_type = CONV_NONE, }, .pos = { 0, 0 }, - .colors = NULL, + .colors = &colors, .can_continuate = false, }; kvi_init(pstate.reader.lines); const ExprAST ast = viml_pexpr_parse(&pstate, flags); assert(ast.root != NULL || ast.err.msg); + // Can’t possibly have more highlight tokens then there are bytes in string. + assert(kv_size(colors) <= INPUT_SIZE - shift); + kvi_destroy(colors); + // Not destroying pstate.reader.lines because there is no way it could exceed + // its limits in the current circumstances. viml_pexpr_free_ast(ast); assert(allocated_memory == 0); } |