Skip to content

Commit f121986

Browse files
committed
Implements #208 and testcase
1 parent 5a517f1 commit f121986

5 files changed

Lines changed: 75 additions & 7 deletions

File tree

src/pegasus.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,14 @@ void Pegasus::replaceColon(QString &value, const QString &gameTitle) {
365365
// PENDING: use sliced() instead of mid() when Qt5
366366
// is no longer supported (ie. RetroPie moved away from Buster)
367367
ctxStr = ctxStr % value.mid(begin, end - begin) % endStr;
368-
value.replace(idx, 1, ".");
369-
qWarning() << QString(
370-
"Description of '%1' contains a colon (:) at '%2', "
371-
"Skyscraper replaced it with '.'. Consider "
372-
"editing the description to remediate this warning.")
373-
.arg(gameTitle)
374-
.arg(ctxStr);
368+
const QChar modColon = QChar(0xa789);
369+
value.replace(idx, 1, modColon);
370+
qInfo() << QString("Description of '%1' contains a colon (:) at '%2', "
371+
"Skyscraper replaced it with '%3' (UTF-8 Modified "
372+
"Letter Colon).")
373+
.arg(gameTitle)
374+
.arg(ctxStr)
375+
.arg(modColon);
375376
idx = value.indexOf(':');
376377
}
377378
}

src/pegasus.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class Pegasus : public AbstractFrontend {
5858
GameEntry::MARQUEE | GameEntry::SCREENSHOT | GameEntry::TEXTURE |
5959
GameEntry::VIDEO | GameEntry::WHEEL);
6060
}
61+
#ifdef TESTING
62+
void replaceColon(QString &value, const QString &gameTitle);
63+
#endif
6164

6265
private:
6366
QString makeAbsolute(const QString &filePath, const QString &inputFolder);
@@ -66,7 +69,9 @@ class Pegasus : public AbstractFrontend {
6669
QString toPegasusFormat(const QString &key, const QString &value);
6770
QString addMediaFile(const QString &asset, bool useRelativePath,
6871
QString mediaFile);
72+
#ifndef TESTING
6973
void replaceColon(QString &value, const QString &gameTitle);
74+
#endif
7075
QString getFilename(const QString &path);
7176

7277
QMap<QString, QString> headerPairs;

test/pegasus/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Makefile
2+
test_pegasus
3+
*.o
4+
*.moc

test/pegasus/test_pegasus.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "pegasus.h"
2+
3+
#include <QDebug>
4+
#include <QTest>
5+
6+
class TestPegasus : public QObject {
7+
Q_OBJECT
8+
9+
private:
10+
Settings settings;
11+
Pegasus *frontend;
12+
13+
private slots:
14+
void initTestCase(){};
15+
16+
void testReplaceColon() {
17+
frontend = new Pegasus();
18+
QString in = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
19+
"sed do eiusmod tempor incididunt ut labore et dolore "
20+
"magna aliqua: Ut enim ad minim veniam.";
21+
QString exp = QString(in).replace(":", QChar(0xa789));
22+
frontend->replaceColon(in, "Didelum");
23+
QCOMPARE(in, exp);
24+
}
25+
};
26+
27+
QTEST_MAIN(TestPegasus)
28+
#include "test_pegasus.moc"

test/pegasus/test_pegasus.pro

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
QT += core network testlib
2+
TEMPLATE = app
3+
TARGET = test_pegasus
4+
DEPENDPATH += .
5+
INCLUDEPATH += ../../src
6+
CONFIG += debug
7+
QT += core network xml
8+
QMAKE_CXXFLAGS += -std=c++17
9+
10+
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT
11+
PREFIX = /usr/local
12+
DEFINES+=PREFIX=\\\"$$PREFIX\\\"
13+
14+
include(../../VERSION.ini)
15+
DEFINES+=TESTING
16+
DEFINES+=VERSION=\\\"$$VERSION\\\"
17+
18+
HEADERS += ../../src/pegasus.h \
19+
../../src/abstractfrontend.h \
20+
../../src/config.h \
21+
../../src/gameentry.h \
22+
../../src/platform.h
23+
24+
SOURCES += test_pegasus.cpp \
25+
../../src/pegasus.cpp \
26+
../../src/abstractfrontend.cpp \
27+
../../src/config.cpp \
28+
../../src/gameentry.cpp \
29+
../../src/platform.cpp
30+

0 commit comments

Comments
 (0)