mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T258, unit tests for 7zip compressing
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
//! \ingroup testblackmisc
|
||||
|
||||
#include "testaviation.h"
|
||||
#include "testcompress.h"
|
||||
#include "testblackmiscmain.h"
|
||||
#include "testcontainers.h"
|
||||
#include "testdbus.h"
|
||||
@@ -47,6 +48,10 @@ namespace BlackMiscTest
|
||||
BlackMisc::Test::CTest test(argc, argv);
|
||||
|
||||
int status = 0;
|
||||
{
|
||||
CTestCompress compressTest;
|
||||
status |= test.exec(&compressTest, "blackmisc_compress");
|
||||
}
|
||||
{
|
||||
CTestPhysicalQuantities pqBaseTests;
|
||||
status |= test.exec(&pqBaseTests, "blackmisc_physicalQuantities");
|
||||
|
||||
64
tests/blackmisc/testcompress.cpp
Normal file
64
tests/blackmisc/testcompress.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \cond PRIVATE_TESTS
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \ingroup testblackmisc
|
||||
*/
|
||||
|
||||
#include "testcompress.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackmisc/compressutils.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/fileutils.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QTemporaryDir>
|
||||
#include <QTest>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackConfig;
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
void CTestCompress::uncompressFile()
|
||||
{
|
||||
QTemporaryDir tempDir;
|
||||
tempDir.setAutoRemove(true);
|
||||
QVERIFY2(tempDir.isValid(), "Invalid directory");
|
||||
|
||||
const bool win = CBuildConfig::isRunningOnWindowsNtPlatform();
|
||||
const bool zip7Exists = CCompressUtils::hasZip7();
|
||||
if (!win && !zip7Exists)
|
||||
{
|
||||
QSKIP("No 7zip, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
QVERIFY2(zip7Exists, "No 7zip");
|
||||
|
||||
const QString td = tempDir.path();
|
||||
const QString compressedFile(CFileUtils::appendFilePaths(CDirectoryUtils::shareTestDirectory(), "countries.json.gz"));
|
||||
const QString unCompressedFile(CFileUtils::appendFilePaths(td, "countries.json"));
|
||||
const bool c = CCompressUtils::zip7Uncompress(compressedFile, td, true);
|
||||
|
||||
QVERIFY2(c, "Uncompressing failed");
|
||||
|
||||
const QFileInfo check(unCompressedFile);
|
||||
QVERIFY2(check.size() > 1000, "Uncompressing yielded not data");
|
||||
QVERIFY2(check.exists(), "Uncompressed file does not exist");
|
||||
QVERIFY2(check.isReadable(), "Not readable");
|
||||
|
||||
qDebug() << "Uncompressed" << compressedFile << "to" << unCompressedFile << "with size" << check.size();
|
||||
}
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
38
tests/blackmisc/testcompress.h
Normal file
38
tests/blackmisc/testcompress.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project community / contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef BLACKMISCTEST_TESTCOMPRESS_H
|
||||
#define BLACKMISCTEST_TESTCOMPRESS_H
|
||||
|
||||
//! \cond PRIVATE_TESTS
|
||||
//! \file
|
||||
//! \ingroup testblackmisc
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackMiscTest
|
||||
{
|
||||
//! Testing process tools
|
||||
class CTestCompress : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CTestCompress(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
//! Uncompress file
|
||||
void uncompressFile();
|
||||
};
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user