From 0858cd52a7430a8be1cf20acc3e0b7ef2f284c45 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Nov 2017 17:30:46 +0100 Subject: [PATCH] Don't unnecessarily use heap-allocated objects in a test Just use local stack variables instead. --- tests/streams/textstreamtest.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/streams/textstreamtest.cpp b/tests/streams/textstreamtest.cpp index e91cc5a1cf..0975e7526e 100644 --- a/tests/streams/textstreamtest.cpp +++ b/tests/streams/textstreamtest.cpp @@ -109,23 +109,20 @@ void TextStreamTestCase::Endline() { TempFile f("test.txt"); - wxFileOutputStream* pOutFile = new wxFileOutputStream(f.GetName()); - wxTextOutputStream* pOutText = new wxTextOutputStream(*pOutFile); - *pOutText << wxT("Test text") << endl - << wxT("More Testing Text (There should be newline before this)"); + { + wxFileOutputStream pOutFile(f.GetName()); + wxTextOutputStream pOutText(pOutFile); + pOutText << wxT("Test text") << endl + << wxT("More Testing Text (There should be newline before this)"); + } - delete pOutText; - delete pOutFile; - - wxFileInputStream* pInFile = new wxFileInputStream(f.GetName()); + wxFileInputStream pInFile(f.GetName()); char szIn[9 + NEWLINELEN]; - pInFile->Read(szIn, 9 + NEWLINELEN); + pInFile.Read(szIn, 9 + NEWLINELEN); CPPUNIT_ASSERT( memcmp(&szIn[9], NEWLINE, NEWLINELEN) == 0 ); - - delete pInFile; } void TextStreamTestCase::MiscTests()