From 93e94bf4b27dd20ec848642ea3488bf9e362539b Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 13 Feb 2017 08:48:51 -0800 Subject: [PATCH] Add a happy path test for ts_document_set_input_string_with_length --- spec/runtime/document_spec.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/runtime/document_spec.cc b/spec/runtime/document_spec.cc index 52e65ffb..f80419dc 100644 --- a/spec/runtime/document_spec.cc +++ b/spec/runtime/document_spec.cc @@ -116,6 +116,17 @@ describe("Document", [&]() { AssertThat(spy_input->strings_read, Equals(vector({" [null, 2" }))); }); + it("allows setting input string with length", [&]() { + const char content[] = { '1' }; + ts_document_set_input_string_with_length(document, content, 1); + ts_document_parse(document); + TSNode new_root = ts_document_root_node(document); + AssertThat(ts_node_end_char(new_root), Equals(1)); + assert_node_string_equals( + new_root, + "(number)"); + }); + it("reads from the new input correctly when the old input was blank", [&]() { ts_document_set_input_string(document, ""); ts_document_parse(document);