don't leak memory when throwing an exception

This commit is contained in:
Axel Kohlmeyer
2024-08-20 01:15:53 -04:00
parent 8cfd856296
commit 02752ddf6a
4 changed files with 22 additions and 1 deletions

View File

@ -87,6 +87,16 @@ TEST_F(TextFileReaderTest, nofp)
ASSERT_THROW({ TextFileReader reader(nullptr, "test"); }, FileReaderException);
}
TEST_F(TextFileReaderTest, buffer)
{
test_files();
auto *reader = new TextFileReader("text_reader_two.file", "test");
reader->set_bufsize(4096);
auto *line = reader->next_line();
ASSERT_THROW({ reader->set_bufsize(20); }, FileReaderException);
delete reader;
}
TEST_F(TextFileReaderTest, usefp)
{
test_files();