Skip to content

Commit

Permalink
tidy: Fix a couple of potential memory leaks in testing code.
Browse files Browse the repository at this point in the history
Replace manual memory management with a c++ unique pointer.

https://clang.llvm.org/docs/analyzer/checkers.html#cplusplus-newdeleteleaks
  • Loading branch information
linuxdude42 committed Oct 5, 2023
1 parent 3bd91b0 commit d21f826
Showing 1 changed file with 3 additions and 7 deletions.
Expand Up @@ -564,7 +564,7 @@ void TestRecordingExtender::test_parseProgramInfo(void)
void TestRecordingExtender::test_parseJson(void)
{
m_nowForTest = QDateTime::fromString("2021-09-22T23:59:00Z", Qt::ISODate);
auto* source = new TestRecExtMlbDataSource(this);
auto source = std::make_unique<TestRecExtMlbDataSource>(this);

SportInfo info {"MLB Baseball", AutoExtendType::MLB, "", ""};
ActiveGame game(0, "MLB Baseball", info);
Expand Down Expand Up @@ -689,7 +689,7 @@ void TestRecordingExtender::test_parseEspn(void)
QFETCH(QString, expectedTextState);

m_nowForTest = QDateTime::fromString(nowForTest, Qt::ISODate);
auto* source = new TestRecExtEspnDataSource(this);
auto source = std::make_unique<TestRecExtEspnDataSource>(this);

SportInfo info {"MLB Baseball", AutoExtendType::ESPN, sport, league};
ActiveGame game(0, "MLB Baseball", info);
Expand Down Expand Up @@ -731,8 +731,6 @@ void TestRecordingExtender::test_parseEspn(void)
QCOMPARE(gameState.getPeriod(), expectedPeriod);
QCOMPARE(gameState.isFinished(), expectedFinished);
QCOMPARE(gameState.getTextState(), expectedTextState);

delete source;
}

void TestRecordingExtender::test_parseMlb_data(void)
Expand Down Expand Up @@ -788,7 +786,7 @@ void TestRecordingExtender::test_parseMlb(void)
QFETCH(QString, expectedTextState);

m_nowForTest = QDateTime::fromString(nowForTest, Qt::ISODate);
auto* source = new TestRecExtMlbDataSource(this);
auto source = std::make_unique<TestRecExtMlbDataSource>(this);

SportInfo info {"MLB Baseball", AutoExtendType::MLB, "sport", "league"};
ActiveGame game(0, "MLB Baseball", info);
Expand Down Expand Up @@ -832,8 +830,6 @@ void TestRecordingExtender::test_parseMlb(void)
QCOMPARE(gameState.getPeriod(), expectedPeriod);
QCOMPARE(gameState.isFinished(), expectedFinished);
QCOMPARE(gameState.getTextState(), expectedTextState);

delete source;
}

void TestRecordingExtender::test_processNewRecordings_data(void)
Expand Down

0 comments on commit d21f826

Please sign in to comment.