Prevent string assertion failures from creating later memory leak errors

This commit is contained in:
Max Brunsfeld 2016-03-02 20:40:13 -08:00
parent e0c24e3be6
commit e7abfdd373
2 changed files with 6 additions and 4 deletions

View file

@ -26,9 +26,10 @@ describe("Document", [&]() {
});
auto assert_node_string_equals = [&](TSNode node, const string &expected) {
char *actual = ts_node_string(node, doc);
char *str = ts_node_string(node, doc);
string actual(str);
ts_free(str);
AssertThat(actual, Equals(expected));
ts_free(actual);
};
describe("set_input(input)", [&]() {

View file

@ -77,9 +77,10 @@ describe("Parser", [&]() {
auto assert_root_node = [&](const string &expected) {
TSNode node = ts_document_root_node(doc);
char *actual = ts_node_string(node, doc);
char *str = ts_node_string(node, doc);
string actual(str);
ts_free(str);
AssertThat(actual, Equals(expected));
ts_free(actual);
};
describe("handling errors", [&]() {