Handle input chunks that end within multi-byte characters

This commit is contained in:
Max Brunsfeld 2018-08-02 15:30:40 -07:00
parent 126f84aa73
commit acc937b7d7
10 changed files with 64 additions and 116 deletions

View file

@ -544,6 +544,21 @@ describe("Parser", [&]() {
root = ts_tree_root_node(tree);
AssertThat(ts_node_end_point(root), Equals<TSPoint>({0, 28}));
});
it("handles input chunks that end in the middle of multi-byte characters", [&]() {
ts_parser_set_language(parser, load_real_language("c"));
spy_input->content = "A b = {'👍','👍'};";
spy_input->chars_per_chunk = 4;
tree = ts_parser_parse(parser, nullptr, spy_input->input());
root = ts_tree_root_node(tree);
assert_root_node(
"(translation_unit (declaration "
"(type_identifier) "
"(init_declarator "
"(identifier) "
"(initializer_list (char_literal) (char_literal)))))");
});
});
describe("set_language(language)", [&]() {