aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-07-03 20:04:24 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-07-03 20:28:03 -0700
commit3c96d5e0d568408e0505841af39aa2d539ebaf36 (patch)
tree9487ae8bd6556f81e634193158d101d3f81dfc98 /tests
parentc5705705d5b40e8157a88612c8a7e83f32f6745b (diff)
downloadPrismLauncher-3c96d5e0d568408e0505841af39aa2d539ebaf36.tar.gz
PrismLauncher-3c96d5e0d568408e0505841af39aa2d539ebaf36.tar.bz2
PrismLauncher-3c96d5e0d568408e0505841af39aa2d539ebaf36.zip
fix: memory leaks in tests
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Task_test.cpp1
-rw-r--r--tests/Version_test.cpp25
2 files changed, 16 insertions, 10 deletions
diff --git a/tests/Task_test.cpp b/tests/Task_test.cpp
index dabe5da2..a57102d6 100644
--- a/tests/Task_test.cpp
+++ b/tests/Task_test.cpp
@@ -80,6 +80,7 @@ class BigConcurrentTaskThread : public QThread {
QCoreApplication::processEvents();
emit finished();
+ delete[] sub_tasks;
}
public:
diff --git a/tests/Version_test.cpp b/tests/Version_test.cpp
index afb4c610..0f8c1652 100644
--- a/tests/Version_test.cpp
+++ b/tests/Version_test.cpp
@@ -20,6 +20,8 @@
class VersionTest : public QObject {
Q_OBJECT
+ QStringList m_flex_test_names = {};
+
void addDataColumns()
{
QTest::addColumn<QString>("first");
@@ -101,8 +103,9 @@ class VersionTest : public QObject {
QString first{split_line.first().simplified()};
QString second{split_line.last().simplified()};
- auto new_test_name = test_name_template.arg(QString::number(test_number), "lessThan").toLatin1().data();
- QTest::newRow(new_test_name) << first << second << true << false;
+ auto new_test_name = test_name_template.arg(QString::number(test_number), "lessThan");
+ m_flex_test_names.append(new_test_name);
+ QTest::newRow(m_flex_test_names.last().toLatin1().data()) << first << second << true << false;
continue;
}
@@ -112,8 +115,9 @@ class VersionTest : public QObject {
QString first{split_line.first().simplified()};
QString second{split_line.last().simplified()};
- auto new_test_name = test_name_template.arg(QString::number(test_number), "equals").toLatin1().data();
- QTest::newRow(new_test_name) << first << second << false << true;
+ auto new_test_name = test_name_template.arg(QString::number(test_number), "equals");
+ m_flex_test_names.append(new_test_name);
+ QTest::newRow(m_flex_test_names.last().toLatin1().data()) << first << second << false << true;
continue;
}
@@ -123,8 +127,9 @@ class VersionTest : public QObject {
QString first{split_line.first().simplified()};
QString second{split_line.last().simplified()};
- auto new_test_name = test_name_template.arg(QString::number(test_number), "greaterThan").toLatin1().data();
- QTest::newRow(new_test_name) << first << second << false << false;
+ auto new_test_name = test_name_template.arg(QString::number(test_number), "greaterThan");
+ m_flex_test_names.append(new_test_name);
+ QTest::newRow(m_flex_test_names.last().toLatin1().data()) << first << second << false << false;
continue;
}
@@ -140,10 +145,10 @@ class VersionTest : public QObject {
void test_flexVerTestVector()
{
- QFETCH(QString, first);
- QFETCH(QString, second);
- QFETCH(bool, lessThan);
- QFETCH(bool, equal);
+ QString first = *static_cast<QString*>(QTest ::qData("first", ::qMetaTypeId<typename std ::remove_cv<QString>::type>()));
+ QString second = *static_cast<QString*>(QTest ::qData("second", ::qMetaTypeId<typename std ::remove_cv<QString>::type>()));
+ bool lessThan = *static_cast<bool*>(QTest ::qData("lessThan", ::qMetaTypeId<typename std ::remove_cv<bool>::type>()));
+ bool equal = *static_cast<bool*>(QTest ::qData("equal", ::qMetaTypeId<typename std ::remove_cv<bool>::type>()));
const auto v1 = Version(first);
const auto v2 = Version(second);