Fix memory leaks in tests

This commit is contained in:
Max Brunsfeld 2014-06-09 21:16:33 -07:00
parent 21c259df9c
commit 1b1f53a5e7
2 changed files with 11 additions and 4 deletions

View file

@ -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);
});
}
});

View file

@ -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);
});
});
});