diff --git a/tests/blackmisc/testblackmiscmain.cpp b/tests/blackmisc/testblackmiscmain.cpp index d5f48d410..353d97a5d 100644 --- a/tests/blackmisc/testblackmiscmain.cpp +++ b/tests/blackmisc/testblackmiscmain.cpp @@ -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"); diff --git a/tests/blackmisc/testcompress.cpp b/tests/blackmisc/testcompress.cpp new file mode 100644 index 000000000..a0be21b74 --- /dev/null +++ b/tests/blackmisc/testcompress.cpp @@ -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 +#include +#include + +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 diff --git a/tests/blackmisc/testcompress.h b/tests/blackmisc/testcompress.h new file mode 100644 index 000000000..e72b24046 --- /dev/null +++ b/tests/blackmisc/testcompress.h @@ -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 + +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