D25767: KAutoSaveFile: add a unit test to check max. filename length

David Faure noreply at phabricator.kde.org
Thu Dec 5 22:50:01 GMT 2019


dfaure accepted this revision.
dfaure added inline comments.
This revision is now accepted and ready to land.

INLINE COMMENTS

> kautosavefiletest.cpp:84
> +    // In KAutoSaveFilePrivate::tempFile() the name of the kautosavefile that's going to be created
> +    // is concatinated in the form:
> +    // fileName + junk.truncated + protocol + _ + path.truncated + junk

typo: concatenated

> kautosavefiletest.cpp:95
> +    QString s;
> +    s = s.fill(QLatin1Char('b'), 80);
> +    // create a long path that:

`fill` modifies the string, no need for `s = `

> kautosavefiletest.cpp:98
> +    // - exceeds NAME_MAX (255)
> +    // - is less than the maximum allowed path length, PATH_MAX (4096)
> +    //   see e.g. /usr/include/linux/limits.h

Let's hope none of the supported OSes have a smaller PATH_MAX :)
FreeBSD, Windows, macOS, who knows what limits they have.

> kautosavefiletest.cpp:108
> +    QFile file;
> +    file.setFileName(path + QLatin1Char('/') + QLatin1String("testFile.txt"));
> +

merge with previous line using the QFile(QString) constructor

> kautosavefiletest.cpp:110
> +
> +    qInfo() << "The lenght of the whole path to the file:" << file.fileName().size();
> +

Doesn't belong in unittests

> kautosavefiletest.cpp:112
> +
> +    QUrl normalFile = QUrl::fromLocalFile(QFileInfo(file).absoluteFilePath());
> +

Why the QFileInfo::absoluteFilePath call? It's already an absolute path.

REPOSITORY
  R244 KCoreAddons

BRANCH
  l-kautosave-unittest (branched from master)

REVISION DETAIL
  https://phabricator.kde.org/D25767

To: ahmadsamir, #frameworks, mpyne, dfaure
Cc: dfaure, kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20191205/76b31602/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list