klee: Include colors in test

This commit is contained in:
ZyX 2017-10-16 00:39:48 +03:00
parent fe81380bf5
commit ed253b5fe6
2 changed files with 12 additions and 3 deletions

View File

@ -176,8 +176,9 @@ static inline void viml_parser_highlight(ParserState *const pstate,
if (pstate->colors == NULL || len == 0) { if (pstate->colors == NULL || len == 0) {
return; return;
} }
// TODO(ZyX-I): May do some assert() sanitizing here. assert(kv_size(*pstate->colors) == 0
// TODO(ZyX-I): May join chunks. || kv_Z(*pstate->colors, 0).start.line < start.line
|| kv_Z(*pstate->colors, 0).end_col <= start.col);
kvi_push(*pstate->colors, ((ParserHighlightChunk) { kvi_push(*pstate->colors, ((ParserHighlightChunk) {
.start = start, .start = start,
.end_col = start.col + len, .end_col = start.col + len,

View File

@ -75,6 +75,9 @@ int main(const int argc, const char *const *const argv,
#endif #endif
ParserLine *cur_pline = &plines[0]; ParserLine *cur_pline = &plines[0];
ParserHighlight colors;
kvi_init(colors);
ParserState pstate = { ParserState pstate = {
.reader = { .reader = {
.get_line = simple_get_line, .get_line = simple_get_line,
@ -83,13 +86,18 @@ int main(const int argc, const char *const *const argv,
.conv.vc_type = CONV_NONE, .conv.vc_type = CONV_NONE,
}, },
.pos = { 0, 0 }, .pos = { 0, 0 },
.colors = NULL, .colors = &colors,
.can_continuate = false, .can_continuate = false,
}; };
kvi_init(pstate.reader.lines); kvi_init(pstate.reader.lines);
const ExprAST ast = viml_pexpr_parse(&pstate, flags); const ExprAST ast = viml_pexpr_parse(&pstate, flags);
assert(ast.root != NULL || ast.err.msg); assert(ast.root != NULL || ast.err.msg);
// Cant 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); viml_pexpr_free_ast(ast);
assert(allocated_memory == 0); assert(allocated_memory == 0);
} }