Add spec for inserting text w/ unicode characters

This commit is contained in:
Max Brunsfeld 2014-10-02 11:54:00 -07:00
parent 8bee9d8fb9
commit a69dfa08f3
2 changed files with 29 additions and 2 deletions

View file

@ -12,6 +12,13 @@ x
---
(variable)
====================================
parses variables with greek letters
====================================
φ1
---
(variable)
===================
parses products
===================

View file

@ -33,13 +33,13 @@ describe("Parser", [&]() {
};
auto insert_text = [&](size_t position, string text) {
reader->content.insert(position, text);
AssertThat(reader->insert(position, text), IsTrue());
ts_document_edit(doc, { position, 0, text.length() });
root = ts_document_root_node(doc);
};
auto delete_text = [&](size_t position, size_t length) {
reader->content.erase(position, length);
AssertThat(reader->erase(position, length), IsTrue());
ts_document_edit(doc, { position, length, 0 });
root = ts_document_root_node(doc);
};
@ -284,6 +284,26 @@ describe("Parser", [&]() {
ts_node_release(node);
});
});
describe("with non-ascii characters", [&]() {
before_each([&]() {
chunk_size = 50;
// αβδ + 1
set_text("\u03b1\u03b2\u03b4 + 1");
AssertThat(ts_node_string(root), Equals(
"(DOCUMENT (sum (variable) (number)))"));
// αβδ + ψ1
insert_text(strlen("abd + "), "\u03c8");
});
it("inserts the text according to the UTF8 character index", [&]() {
AssertThat(ts_node_string(root), Equals(
"(DOCUMENT (sum (variable) (variable)))"));
});
});
});
describe("deleting text", [&]() {