Fix memory leaks in tests
This commit is contained in:
parent
21c259df9c
commit
1b1f53a5e7
2 changed files with 11 additions and 4 deletions
|
|
@ -24,11 +24,13 @@ describe("Languages", [&]() {
|
|||
before_each([&]() {
|
||||
ts_document_set_parser(doc, parser_constructor());
|
||||
});
|
||||
|
||||
|
||||
for (auto &entry : test_entries_for_language(language)) {
|
||||
it(entry.description.c_str(), [&]() {
|
||||
ts_document_set_input_string(doc, entry.input.c_str());
|
||||
AssertThat(ts_document_string(doc), Equals(entry.tree_string.c_str()));
|
||||
auto doc_string = ts_document_string(doc);
|
||||
AssertThat(doc_string, Equals(entry.tree_string.c_str()));
|
||||
free((void *)doc_string);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -79,8 +79,13 @@ describe("trees", []() {
|
|||
|
||||
describe("serialization", [&]() {
|
||||
it("returns a readable string", [&]() {
|
||||
AssertThat(string(ts_tree_string(tree1, names)), Equals("(cat)"));
|
||||
AssertThat(string(ts_tree_string(parent1, names)), Equals("(dog (cat) (cat))"));
|
||||
auto string1 = ts_tree_string(tree1, names);
|
||||
AssertThat(string(string1), Equals("(cat)"));
|
||||
free(string1);
|
||||
|
||||
auto string2 = ts_tree_string(parent1, names);
|
||||
AssertThat(string(string2), Equals("(dog (cat) (cat))"));
|
||||
free(string2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue