In parser, read chunked input correctly
This commit is contained in:
parent
3aaa08b948
commit
42e9a264f3
6 changed files with 134 additions and 18 deletions
36
spec/runtime/parser_spec.cc
Normal file
36
spec/runtime/parser_spec.cc
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "runtime_spec_helper.h"
|
||||
#include "helpers/spy_reader.h"
|
||||
|
||||
extern ts_parse_config ts_parse_config_json;
|
||||
|
||||
START_TEST
|
||||
|
||||
describe("reading from an input", [&]() {
|
||||
ts_document *doc;
|
||||
|
||||
before_each([&]() {
|
||||
doc = ts_document_make();
|
||||
ts_document_set_parser(doc, ts_parse_config_json);
|
||||
});
|
||||
|
||||
after_each([&]() {
|
||||
ts_document_free(doc);
|
||||
});
|
||||
|
||||
it("reads the entire input", [&]() {
|
||||
SpyReader reader("\"ok go do it!\"", 3);
|
||||
ts_document_set_input(doc, reader.input);
|
||||
|
||||
AssertThat(string(ts_document_string(doc)), Equals("(value (string))"));
|
||||
AssertThat(reader.chunks_read, Equals(vector<string>({
|
||||
"\"ok",
|
||||
" go",
|
||||
" do",
|
||||
" it",
|
||||
"!\"",
|
||||
""
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
||||
END_TEST
|
||||
Loading…
Add table
Add a link
Reference in a new issue