aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--launcher/Version.cpp18
-rw-r--r--launcher/Version.h7
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/Version_test.cpp3
4 files changed, 30 insertions, 1 deletions
diff --git a/launcher/Version.cpp b/launcher/Version.cpp
index 9fdd955b..2129ebfd 100644
--- a/launcher/Version.cpp
+++ b/launcher/Version.cpp
@@ -1,5 +1,6 @@
#include "Version.h"
+#include <QDebug>
#include <QUrl>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
@@ -93,3 +94,20 @@ void Version::parse()
m_sections.append(Section(currentSection));
}
}
+
+
+/// qDebug print support for the BlockedMod struct
+QDebug operator<<(QDebug debug, const Version& v)
+{
+ QDebugStateSaver saver(debug);
+
+ debug.nospace() << "Version{ string: " << v.toString() << ", sections: [ ";
+
+ for (auto s : v.m_sections) {
+ debug.nospace() << s.m_fullString << ", ";
+ }
+
+ debug.nospace() << " ]" << " }";
+
+ return debug;
+} \ No newline at end of file
diff --git a/launcher/Version.h b/launcher/Version.h
index aceb7a07..c0927374 100644
--- a/launcher/Version.h
+++ b/launcher/Version.h
@@ -35,6 +35,7 @@
#pragma once
+#include <QDebug>
#include <QString>
#include <QStringView>
#include <QList>
@@ -59,6 +60,8 @@ public:
return m_string;
}
+ friend QDebug operator<<(QDebug debug, const Version& v);
+
private:
QString m_string;
struct Section
@@ -143,7 +146,11 @@ private:
}
}
};
+
+
QList<Section> m_sections;
void parse();
};
+
+
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 9f84a9a7..0f716a75 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -53,3 +53,6 @@ ecm_add_test(Packwiz_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR
ecm_add_test(Index_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
TEST_NAME Index)
+
+ecm_add_test(Version_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
+ TEST_NAME Version)
diff --git a/tests/Version_test.cpp b/tests/Version_test.cpp
index 734528b7..6836b6fa 100644
--- a/tests/Version_test.cpp
+++ b/tests/Version_test.cpp
@@ -15,7 +15,6 @@
#include <QTest>
-#include <TestUtil.h>
#include <Version.h>
class ModUtilsTest : public QObject
@@ -74,6 +73,8 @@ private slots:
const auto v1 = Version(first);
const auto v2 = Version(second);
+ qDebug() << v1 << "vs" << v2;
+
QCOMPARE(v1 < v2, lessThan);
QCOMPARE(v1 > v2, !lessThan && !equal);
QCOMPARE(v1 == v2, equal);