diff options
author | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-10 21:52:58 +0300 |
---|---|---|
committer | Kevin Ottens <kevin.ottens@nextcloud.com> | 2020-12-15 13:01:53 +0300 |
commit | c57eff6fd80b1685237f1e782ed1c640c2350a9f (patch) | |
tree | 1845a1e5ca665b09add42fab6151030fad960600 /test | |
parent | c03a5da6709a57c0456ca9d83158fe839ab7a3c1 (diff) |
Please the clang-tidy overlord
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/csync/vio_tests/check_vio_ext.cpp | 26 | ||||
-rw-r--r-- | test/mockserver/httpserver.h | 2 | ||||
-rw-r--r-- | test/syncenginetestutils.cpp | 19 | ||||
-rw-r--r-- | test/testasyncop.cpp | 4 | ||||
-rw-r--r-- | test/testdownload.cpp | 2 | ||||
-rw-r--r-- | test/testexcludedfiles.cpp | 2 | ||||
-rw-r--r-- | test/testoauth.cpp | 4 |
7 files changed, 31 insertions, 28 deletions
diff --git a/test/csync/vio_tests/check_vio_ext.cpp b/test/csync/vio_tests/check_vio_ext.cpp index 209798988..193a9be47 100644 --- a/test/csync/vio_tests/check_vio_ext.cpp +++ b/test/csync/vio_tests/check_vio_ext.cpp @@ -61,7 +61,7 @@ static int wipe_testdir() } static int setup_testenv(void **state) { - int rc; + int rc = 0; rc = wipe_testdir(); assert_int_equal(rc, 0); @@ -80,7 +80,7 @@ static int setup_testenv(void **state) { assert_int_equal(rc, 0); /* --- initialize csync */ - statevar *mystate = new statevar; + auto mystate = new statevar; *state = mystate; return 0; } @@ -91,7 +91,7 @@ static void output( const char *text ) } static int teardown(void **state) { - int rc; + int rc = -1; output("================== Tearing down!\n"); @@ -110,7 +110,7 @@ static int teardown(void **state) { */ static void create_dirs( const char *path ) { - int rc; + int rc = -1; auto _mypath = QStringLiteral("%1/%2").arg(CSYNC_TEST_DIR, QString::fromUtf8(path)).toUtf8(); char *mypath = _mypath.data(); @@ -149,13 +149,13 @@ static void create_dirs( const char *path ) */ static void traverse_dir(void **state, const QString &dir, int *cnt) { - csync_vio_handle_t *dh; + csync_vio_handle_t *dh = nullptr; std::unique_ptr<csync_file_stat_t> dirent; - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; QByteArray subdir; QByteArray subdir_out; - int rc; - int is_dir; + int rc = -1; + int is_dir = 0; dh = csync_vio_local_opendir(dir); assert_non_null(dh); @@ -208,7 +208,7 @@ static void create_file( const char *path, const char *name, const char *content static void check_readdir_shorttree(void **state) { - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; const char *t1 = "alibaba/und/die/vierzig/räuber/"; create_dirs( t1 ); @@ -230,7 +230,7 @@ static void check_readdir_shorttree(void **state) static void check_readdir_with_content(void **state) { - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; int files_cnt = 0; const char *t1 = "warum/nur/40/Räuber/"; @@ -257,7 +257,7 @@ static void check_readdir_with_content(void **state) static void check_readdir_longtree(void **state) { - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; /* Strange things here: Compilers only support strings with length of 4k max. * The expected result string is longer, so it needs to be split up in r1, r2 and r3 @@ -327,7 +327,7 @@ static void check_readdir_longtree(void **state) // https://github.com/owncloud/client/issues/3128 https://github.com/owncloud/client/issues/2777 static void check_readdir_bigunicode(void **state) { - statevar *sv = (statevar*) *state; + auto sv = (statevar*) *state; // 1: ? ASCII: 239 - EF // 2: ? ASCII: 187 - BB // 3: ? ASCII: 191 - BF @@ -362,5 +362,5 @@ int torture_run_tests(void) cmocka_unit_test_setup_teardown(check_readdir_bigunicode, setup_testenv, teardown), }; - return cmocka_run_group_tests(tests, NULL, NULL); + return cmocka_run_group_tests(tests, nullptr, nullptr); } diff --git a/test/mockserver/httpserver.h b/test/mockserver/httpserver.h index b408e4233..91bd5899e 100644 --- a/test/mockserver/httpserver.h +++ b/test/mockserver/httpserver.h @@ -18,7 +18,7 @@ class HttpServer : public QTcpServer { Q_OBJECT public: - HttpServer(qint16 port, QObject* parent = 0); + HttpServer(qint16 port, QObject* parent = nullptr); void incomingConnection(int socket); private slots: diff --git a/test/syncenginetestutils.cpp b/test/syncenginetestutils.cpp index 640cadf8d..aba75d6c4 100644 --- a/test/syncenginetestutils.cpp +++ b/test/syncenginetestutils.cpp @@ -8,6 +8,10 @@ #include "syncenginetestutils.h" +#include <memory> + + + PathComponents::PathComponents(const char *path) : PathComponents { QString::fromUtf8(path) } { @@ -374,7 +378,7 @@ FileInfo *FakePutReply::perform(FileInfo &remoteRootFileInfo, const QNetworkRequ fileInfo = remoteRootFileInfo.create(fileName, putPayload.size(), putPayload.at(0)); } fileInfo->lastModified = OCC::Utility::qDateTimeFromTime_t(request.rawHeader("X-OC-Mtime").toLongLong()); - remoteRootFileInfo.find(fileName, /*invalidate_etags=*/true); + remoteRootFileInfo.find(fileName, /*invalidateEtags=*/true); return fileInfo; } @@ -612,7 +616,7 @@ FileInfo *FakeChunkMoveReply::perform(FileInfo &uploadsFileInfo, FileInfo &remot QString source = getFilePathFromUrl(request.url()); Q_ASSERT(!source.isEmpty()); Q_ASSERT(source.endsWith(QLatin1String("/.file"))); - source = source.left(source.length() - qstrlen("/.file")); + source = source.left(source.length() - static_cast<int>(qstrlen("/.file"))); auto sourceFolder = uploadsFileInfo.find(source); Q_ASSERT(sourceFolder); @@ -657,7 +661,7 @@ FileInfo *FakeChunkMoveReply::perform(FileInfo &uploadsFileInfo, FileInfo &remot fileInfo = remoteRootFileInfo.create(fileName, size, payload); } fileInfo->lastModified = OCC::Utility::qDateTimeFromTime_t(request.rawHeader("X-OC-Mtime").toLongLong()); - remoteRootFileInfo.find(fileName, /*invalidate_etags=*/true); + remoteRootFileInfo.find(fileName, /*invalidateEtags=*/true); return fileInfo; } @@ -800,7 +804,7 @@ QNetworkReply *FakeQNAM::createRequest(QNetworkAccessManager::Operation op, cons FileInfo &info = isUpload ? _uploadFileInfo : _remoteRootFileInfo; auto verb = request.attribute(QNetworkRequest::CustomVerbAttribute); - FakeReply *reply; + FakeReply *reply = nullptr; if (verb == QLatin1String("PROPFIND")) // Ignore outgoingData always returning somethign good enough, works for now. reply = new FakePropfindReply { info, op, request, this }; @@ -841,8 +845,8 @@ FakeFolder::FakeFolder(const FileInfo &fileTemplate) _account->setDavDisplayName(QStringLiteral("fakename")); _account->setServerVersion(QStringLiteral("10.0.0")); - _journalDb.reset(new OCC::SyncJournalDb(localPath() + QStringLiteral(".sync_test.db"))); - _syncEngine.reset(new OCC::SyncEngine(_account, localPath(), QString(), _journalDb.get())); + _journalDb = std::make_unique<OCC::SyncJournalDb>(localPath() + QStringLiteral(".sync_test.db")); + _syncEngine = std::make_unique<OCC::SyncEngine>(_account, localPath(), QString(), _journalDb.get()); // Ignore temporary files from the download. (This is in the default exclude list, but we don't load it) _syncEngine->excludedFiles().addManualExclude(QStringLiteral("]*.~*")); @@ -1026,5 +1030,4 @@ FakeReply::FakeReply(QObject *parent) } FakeReply::~FakeReply() -{ -} += default; diff --git a/test/testasyncop.cpp b/test/testasyncop.cpp index 29cfa1457..22b5c57f9 100644 --- a/test/testasyncop.cpp +++ b/test/testasyncop.cpp @@ -113,7 +113,7 @@ private slots: auto successCallback = [](TestCase *tc, const QNetworkRequest &request) { tc->pollRequest = [](TestCase *, const QNetworkRequest &) -> QNetworkReply * { std::abort(); }; // shall no longer be called FileInfo *info = tc->perform(); - QByteArray body = "{ \"status\":\"finished\", \"ETag\":\"\\\"" + info->etag + "\\\"\", \"fileId\":\"" + info->fileId + "\"}\n"; + QByteArray body = R"({ "status":"finished", "ETag":"\")" + info->etag + R"(\"", "fileId":")" + info->fileId + "\"}\n"; return new FakePayloadReply(QNetworkAccessManager::GetOperation, request, body, nullptr); }; // Callback that never finishes @@ -139,7 +139,7 @@ private slots: }; // Create a testcase by creating a file of a given size locally and assigning it a callback - auto insertFile = [&](const QString &file, int size, TestCase::PollRequest_t cb) { + auto insertFile = [&](const QString &file, qint64 size, TestCase::PollRequest_t cb) { fakeFolder.localModifier().insert(file, size); testCases[file] = { std::move(cb) }; }; diff --git a/test/testdownload.cpp b/test/testdownload.cpp index ec451e07b..80d85e4bd 100644 --- a/test/testdownload.cpp +++ b/test/testdownload.cpp @@ -26,7 +26,7 @@ public: { if (aborted) return 0; - return std::min(size, fakeSize) + QIODevice::bytesAvailable(); + return std::min(size, fakeSize) + QIODevice::bytesAvailable(); // NOLINT: This is intended to simulare the brokeness } qint64 readData(char *data, qint64 maxlen) override diff --git a/test/testexcludedfiles.cpp b/test/testexcludedfiles.cpp index f00683e88..c91b918fc 100644 --- a/test/testexcludedfiles.cpp +++ b/test/testexcludedfiles.cpp @@ -666,7 +666,7 @@ private slots: { extern void csync_exclude_expand_escapes(QByteArray &input); - QByteArray line = "keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z \\#"; + QByteArray line = R"(keep \' \" \? \\ \a \b \f \n \r \t \v \z \#)"; csync_exclude_expand_escapes(line); QVERIFY(0 == strcmp(line.constData(), "keep ' \" ? \\\\ \a \b \f \n \r \t \v \\z #")); diff --git a/test/testoauth.cpp b/test/testoauth.cpp index 506156a76..a366407db 100644 --- a/test/testoauth.cpp +++ b/test/testoauth.cpp @@ -310,14 +310,14 @@ private slots: if (redirectsDone == 0) { std::unique_ptr<QBuffer> payload(new QBuffer()); payload->setData(""); - SlowFakePostReply *reply = new SlowFakePostReply(op, request, std::move(payload), this); + auto *reply = new SlowFakePostReply(op, request, std::move(payload), this); reply->redirectToPolicy = true; redirectsDone++; return reply; } else if (redirectsDone == 1) { std::unique_ptr<QBuffer> payload(new QBuffer()); payload->setData(""); - SlowFakePostReply *reply = new SlowFakePostReply(op, request, std::move(payload), this); + auto *reply = new SlowFakePostReply(op, request, std::move(payload), this); reply->redirectToToken = true; redirectsDone++; return reply; |