Ref T258, unit tests for 7zip compressing

This commit is contained in:
Klaus Basan
2018-02-22 13:53:54 +01:00
parent e53260a817
commit 2fcc47e2d6
3 changed files with 107 additions and 0 deletions

View File

@@ -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");

View 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

View 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