- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document
C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+
Build status: BUILD_RTI=OFF successful (0 errors, warnings only)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
176 lines
3.7 KiB
C++
Executable File
176 lines
3.7 KiB
C++
Executable File
|
|
|
|
#include "nglcomp_test.h"
|
|
|
|
#include "nglcomp_compress.h"
|
|
|
|
#include <ngltools/ngltools_filesystem.h>
|
|
|
|
#include <nglapplication/nglcoreapplication.h>
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
#include <QtTest/QtTest>
|
|
|
|
|
|
|
|
void nglcomp_test::initTestCase()
|
|
{
|
|
m_tempDirIn.setAutoRemove(true);
|
|
m_tempDirOut.setAutoRemove(true);
|
|
QVERIFY(m_tempDirIn.isValid());
|
|
QVERIFY(m_tempDirOut.isValid());
|
|
QVERIFY(m_tf.open());
|
|
m_tf.setAutoRemove(true);
|
|
|
|
m_fileContent[QLatin1String("1.txt")] = "111111111111111111111111";
|
|
m_fileContent[QLatin1String("sub1/s1.txt")] = "222222222222222222222222";
|
|
m_fileContent[QLatin1String("sub1/sub11/s11.txt")] = "333333333333333333333333";
|
|
m_fileContent[QLatin1String("sub1/sub12/s12.txt")] = "444444444444444444444444";
|
|
m_fileContent[QLatin1String("sub2/2.txt")] = "555555555555555555555555";
|
|
}
|
|
|
|
|
|
void nglcomp_test::testCompressFile()
|
|
{
|
|
QDir dir;
|
|
const auto directories = {
|
|
QLatin1String("sub1"),
|
|
QLatin1String("sub1/sub11"),
|
|
QLatin1String("sub1/sub12"),
|
|
QLatin1String("sub2")
|
|
};
|
|
for (const QLatin1String &directory : directories)
|
|
QVERIFY(dir.mkdir(subPathIn(directory)));
|
|
|
|
for (auto it = m_fileContent.cbegin(); it != m_fileContent.cend(); ++it)
|
|
writeTestFile(it.key(), it.value());
|
|
|
|
NGL::Compress c;
|
|
c.compress(&m_tf, subPathIn(QString()), QLatin1String("out"));
|
|
QVERIFY(c.waitForFinished());
|
|
}
|
|
|
|
|
|
void nglcomp_test::testCompressMemory()
|
|
{
|
|
QBuffer f(&m_ba);
|
|
QVERIFY(f.open(QIODevice::WriteOnly));
|
|
QVector<NGL::Compress::FileInformations> fi1;
|
|
QVector<NGL::Compress::FileInformations> fi2;
|
|
NGL::Compress::FileInformations fi;
|
|
|
|
fi.inputFileName = QLatin1String("chris.txt");
|
|
fi.fileData = QByteArray("dumdidum\n");
|
|
fi2 += fi;
|
|
|
|
fi.inputFileName = QLatin1String("blub/chris.txt");
|
|
fi.fileData = QByteArray("dumdidum im Verzeichnis blub\n");
|
|
fi2 += fi;
|
|
|
|
fi.inputFileName = QLatin1String("blub/blub/chris2.txt");
|
|
fi.fileData = QByteArray("dumdidum im Verzeichnis blub/blub\n");
|
|
fi2 += fi;
|
|
|
|
NGL::Compress c;
|
|
c.compress(&f, QString(), fi1, fi2, QLatin1String("blub"));
|
|
QVERIFY(c.waitForFinished());
|
|
f.close();
|
|
}
|
|
|
|
void nglcomp_test::testUncompressMemory()
|
|
{
|
|
QBuffer f(&m_ba);
|
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
|
NGL::Compress c;
|
|
c.uncompress(&f, subPathIn(QString()));
|
|
QVERIFY(c.waitForFinished());
|
|
f.close();
|
|
|
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
|
c.uncompress(&f);
|
|
QVERIFY(c.waitForFinished());
|
|
QVector<NGL::Compress::FileInformations> fi1 = c.getMemFiles();
|
|
QVERIFY(fi1.count() == 4);
|
|
f.close();
|
|
}
|
|
|
|
void nglcomp_test::testUncompressFile()
|
|
{
|
|
NGL::Compress c;
|
|
m_tf.seek(0);
|
|
c.uncompress(&m_tf, subPathOut(QString()));
|
|
QVERIFY(c.waitForFinished());
|
|
|
|
for (auto it = m_fileContent.cbegin(); it != m_fileContent.cend(); ++it)
|
|
checkContent(it.key(), it.value());
|
|
}
|
|
|
|
void nglcomp_test::cleanupTestCase()
|
|
{
|
|
m_tf.close();
|
|
m_tempDirIn.remove();
|
|
m_tempDirOut.remove();
|
|
}
|
|
|
|
|
|
|
|
void nglcomp_test::writeTestFile(const QString &fn, const QByteArray &content) const
|
|
{
|
|
QFile f(subPathIn(fn));
|
|
QVERIFY(f.open(QIODevice::WriteOnly));
|
|
QVERIFY(f.write(content) == content.size());
|
|
f.close();
|
|
}
|
|
|
|
void nglcomp_test::checkContent(const QString &fn, const QByteArray &content) const
|
|
{
|
|
QFile f(subPathOut(QLatin1String("out/") + fn));
|
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
|
QCOMPARE(f.readAll(), content);
|
|
}
|
|
|
|
QString nglcomp_test::subPathIn(const QString &p) const
|
|
{
|
|
return m_tempDirIn.path() + QLatin1Char('/') + p;
|
|
}
|
|
|
|
QString nglcomp_test::subPathOut(const QString &p) const
|
|
{
|
|
return m_tempDirOut.path() + QLatin1Char('/') + p;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
NGLCoreApplication app(argc, argv);
|
|
|
|
app.createLogger("nglcomp_test", "log4cxx_nglcomp_test.props");
|
|
nglcomp_test tc;
|
|
return QTest::qExec(&tc, argc, argv);
|
|
}
|