feat: add debug printing for Version
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
730f714e97
commit
9934537e19
@ -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;
|
||||
}
|
@ -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();
|
||||
};
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user