Code style fixes in tests project

This commit is contained in:
Bionus 2021-01-28 16:41:02 +01:00
parent 80e41662e5
commit c6fb4dc86b
No known key found for this signature in database
GPG Key ID: 54B0B2DE713AE915
14 changed files with 208 additions and 193 deletions

View File

@ -2,8 +2,8 @@
set -e
# "src/gui/src/" "src/tests/src/"
find "src/lib/src/" "src/cli/src/" "src/e2e/src/" -name '*.cpp' -o -name '*.h' \
# "src/gui/src/"
find "src/lib/src/" "src/cli/src/" "src/e2e/src/" "src/tests/src/" -name '*.cpp' -o -name '*.h' \
| grep -v "vendor" \
| grep -v "crashhandler" \
| grep -v "backports" \

View File

@ -44,7 +44,7 @@ SearchSyntaxHighlighter::SearchSyntaxHighlighter(QTextDocument *parent)
void SearchSyntaxHighlighter::highlightBlock(const QString &text)
{
foreach(const HighlightingRule &rule, highlightingRules) {
for (const HighlightingRule &rule : highlightingRules) {
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
while (matchIterator.hasNext()) {
QRegularExpressionMatch match = matchIterator.next();

View File

@ -9,7 +9,7 @@
namespace Catch
{
template<>
template <>
struct StringMaker<QLatin1String>
{
static std::string convert(QLatin1String const& value)
@ -18,7 +18,7 @@ namespace Catch
}
};
template<>
template <>
struct StringMaker<QString>
{
static std::string convert(QString const& value)
@ -27,7 +27,7 @@ namespace Catch
}
};
template<>
template <>
struct StringMaker<QChar>
{
static std::string convert(QChar const& value)
@ -36,7 +36,7 @@ namespace Catch
}
};
template<>
template <>
struct StringMaker<QUrl>
{
static std::string convert(QUrl const &value)
@ -45,24 +45,26 @@ namespace Catch
}
};
template<>
template <>
struct StringMaker<QSize>
{
static std::string convert(QSize const &value)
{
if (!value.isValid())
if (!value.isValid()) {
return "{invalid size}";
}
return QString("(%1 x %2)").arg(value.width()).arg(value.height()).toStdString();
}
};
template<>
template <>
struct StringMaker<QDateTime>
{
static std::string convert(QDateTime const &value)
{
if (!value.isValid())
if (!value.isValid()) {
return "{invalid date}";
}
return value.toString(Qt::ISODate).toStdString();
}
};

View File

@ -65,8 +65,9 @@ TEST_CASE("BatchDownloader")
SECTION("Image not found")
{
// More than once because of the extension rotator
for (int i = 0; i < 7; ++i)
for (int i = 0; i < 7; ++i) {
CustomNetworkAccessManager::NextFiles.append("404");
}
BatchDownloader downloader(&query, profile);
waitForFinished(&downloader);

View File

@ -92,9 +92,9 @@ TEST_CASE("FilenameExecutionVisitor")
{
QMap<QString, Token> gallery {{ "name", Token("some gallery") }};
QMap<QString, Token> tokens {
{ "gallery", Token(QVariant::fromValue(gallery)) },
{ "md5", Token("1bc29b36f623ba82aaf6724fd3b16718") },
{ "ext", Token("jpg") }
{ "gallery", Token(QVariant::fromValue(gallery)) },
{ "md5", Token("1bc29b36f623ba82aaf6724fd3b16718") },
{ "ext", Token("jpg") }
};
FilenameParser parser("<galleries/%gallery.name%/>%md5%.%ext%");
@ -114,9 +114,9 @@ TEST_CASE("FilenameExecutionVisitor")
{
QMap<QString, Token> gallery {{ "name", Token("some gallery") }};
QMap<QString, Token> tokens {
{ "gallery", Token(QVariant::fromValue(gallery)) },
{ "md5", Token("1bc29b36f623ba82aaf6724fd3b16718") },
{ "ext", Token("jpg") }
{ "gallery", Token(QVariant::fromValue(gallery)) },
{ "md5", Token("1bc29b36f623ba82aaf6724fd3b16718") },
{ "ext", Token("jpg") }
};
FilenameParser parser("<galleries/%gallery.id%/>%md5%.%ext%");

View File

@ -48,7 +48,9 @@ QList<QSharedPointer<Image>> getImages(const QString &source, const QString &sit
sites.append(ste);
QList<QSharedPointer<Image>> result;
Downloader downloader(profile, nullptr,
Downloader downloader(
profile,
nullptr,
tags.split(' '),
QStringList(),
sites,
@ -64,7 +66,8 @@ QList<QSharedPointer<Image>> getImages(const QString &source, const QString &sit
false,
0,
false,
false);
false
);
downloader.setQuit(false);
// Wait for downloader
@ -119,7 +122,9 @@ QList<Tag> getPageTags(const QString &source, const QString &site, const QString
sites.append(ste);
QList<Tag> result;
Downloader downloader(profile, nullptr,
Downloader downloader(
profile,
nullptr,
tags.split(' '),
QStringList(),
sites,
@ -133,7 +138,8 @@ QList<Tag> getPageTags(const QString &source, const QString &site, const QString
false,
Blacklist(),
false,
0);
0
);
downloader.setQuit(false);
// Wait for downloader

View File

@ -32,7 +32,7 @@ TEST_CASE("PackLoader")
{
const QScopedPointer<Profile> pProfile(makeProfile());
auto profile = pProfile.data();
SECTION("GetQuery")
{
DownloadQueryGroup query(QStringList() << "search", 1, 10, 20, QStringList(), false, nullptr, "%md5%.%ext%", "");

View File

@ -133,79 +133,84 @@ TEST_CASE("Favorite")
}
#ifndef HEADLESS
SECTION("SetImageFirst")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists())
file.remove();
SECTION("SetImageFirst")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists()) {
file.remove();
}
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date);
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date);
QPixmap img(QDir::currentPath() + "/tests/resources/image_200x200.png");
fav.setImage(img);
QPixmap img(QDir::currentPath() + "/tests/resources/image_200x200.png");
fav.setImage(img);
REQUIRE(file.exists() == true);
}
SECTION("GetImageNotExists")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists())
file.remove();
REQUIRE(file.exists() == true);
}
SECTION("GetImageNotExists")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists()) {
file.remove();
}
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date);
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date);
QPixmap img = fav.getImage();
QPixmap img = fav.getImage();
REQUIRE(img.isNull() == true);
}
SECTION("GetImageBig")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists())
file.remove();
REQUIRE(img.isNull() == true);
}
SECTION("GetImageBig")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists()) {
file.remove();
}
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date);
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date);
QPixmap img(QDir::currentPath() + "/tests/resources/image_200x200.png");
fav.setImage(img);
QPixmap actual = fav.getImage();
QPixmap img(QDir::currentPath() + "/tests/resources/image_200x200.png");
fav.setImage(img);
QPixmap actual = fav.getImage();
REQUIRE(actual.isNull() == false);
REQUIRE(actual.size() == QSize(150, 150));
}
SECTION("GetImageSmall")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists())
file.remove();
REQUIRE(actual.isNull() == false);
REQUIRE(actual.size() == QSize(150, 150));
}
SECTION("GetImageSmall")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists()) {
file.remove();
}
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date);
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date);
QPixmap img(QDir::currentPath() + "/tests/resources/image_1x1.png");
fav.setImage(img);
QPixmap actual = fav.getImage();
QPixmap img(QDir::currentPath() + "/tests/resources/image_1x1.png");
fav.setImage(img);
QPixmap actual = fav.getImage();
REQUIRE(actual.isNull() == false);
REQUIRE(actual.size() == QSize(150, 150));
}
SECTION("GetImageResize")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists())
file.remove();
REQUIRE(actual.isNull() == false);
REQUIRE(actual.size() == QSize(150, 150));
}
SECTION("GetImageResize")
{
QFile file(savePath("thumbs/tag1.png"));
if (file.exists()) {
file.remove();
}
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date, QDir::currentPath() + "/tests/resources/image_200x200.png");
QPixmap actual = fav.getImage();
QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
Favorite fav("tag1", 50, date, QDir::currentPath() + "/tests/resources/image_200x200.png");
QPixmap actual = fav.getImage();
REQUIRE(file.exists() == true);
REQUIRE(actual.isNull() == false);
REQUIRE(actual.size() == QSize(150, 150));
}
REQUIRE(file.exists() == true);
REQUIRE(actual.isNull() == false);
REQUIRE(actual.size() == QSize(150, 150));
}
#endif
SECTION("ToString")

View File

@ -154,16 +154,16 @@ TEST_CASE("Filename")
SECTION("PathComplex")
{
assertPath(profile, img,
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/group/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/group/1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("PathKeepAll")
{
settings->setValue("Save/character_multiple", "keepAll");
assertPath(profile, img,
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character1 character2/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character1 character2/1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("PathKeepN")
{
@ -171,8 +171,8 @@ TEST_CASE("Filename")
settings->setValue("Save/character_multiple_keepN", 1);
assertPath(profile, img,
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character1/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character1/1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("PathSort")
{
@ -189,75 +189,75 @@ TEST_CASE("Filename")
settings->setValue("Save/character_multiple_keepNThenAdd_keep", 1);
settings->setValue("Save/character_multiple_keepNThenAdd_add", " (and %count% of %total%)");
assertPath(profile, img,
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character1 (and 1 of 2)/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character1 (and 1 of 2)/1bc29b36f623ba82aaf6724fd3b16718.jpg");
settings->setValue("Save/character_multiple_keepNThenAdd_keep", 2);
assertPath(profile, img,
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character1 character2/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character1 character2/1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("PathIgnoredTags")
{
profile->setRemovedTags("character1");
img = ImageFactory::build(site, details, profile);
assertPath(profile, img,
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character2/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/character2/1bc29b36f623ba82aaf6724fd3b16718.jpg");
profile->setRemovedTags("character*");
img = ImageFactory::build(site, details, profile);
assertPath(profile, img,
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/unknown/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/unknown/1bc29b36f623ba82aaf6724fd3b16718.jpg");
settings->setValue("Save/character_empty", "");
img = ImageFactory::build(site, details, profile);
assertPath(profile, img,
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%copyright%/%character%/%md5%.%ext%",
"artist1/crossover/1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("PathEmptyDirs")
{
assertPath(profile, img,
"%artist%/%test%/%md5%.%ext%",
"artist1/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%test%/%md5%.%ext%",
"artist1/1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("PathEmptyDirsNetworkDrive")
{
assertPath(profile, img,
"%md5%.%ext%",
"//NetworkDrive/Grabber/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"//NetworkDrive/Grabber", true, true);
"%md5%.%ext%",
"//NetworkDrive/Grabber/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"//NetworkDrive/Grabber", true, true);
}
SECTION("PathKeptTokens")
{
assertPath(profile, img,
"%artist%/%path%/%md5%.%ext%",
"artist1/%path%/1bc29b36f623ba82aaf6724fd3b16718.jpg");
"%artist%/%path%/%md5%.%ext%",
"artist1/%path%/1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("PathFull")
{
assertPath(profile, img,
"%md5%.%ext%",
"tests/directory/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"tests/directory/",
true, true);
"%md5%.%ext%",
"tests/directory/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"tests/directory/",
true, true);
assertPath(profile, img,
"%md5%.%ext%",
"tests/directory/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"tests/directory",
true, true);
"%md5%.%ext%",
"tests/directory/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"tests/directory",
true, true);
assertPath(profile, img,
"/%md5%.%ext%",
"tests/directory/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"tests/directory/",
true, true);
"/%md5%.%ext%",
"tests/directory/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"tests/directory/",
true, true);
assertPath(profile, img,
"/%md5%.%ext%",
"tests/directory/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"tests/directory",
true, true);
"/%md5%.%ext%",
"tests/directory/1bc29b36f623ba82aaf6724fd3b16718.jpg",
"tests/directory",
true, true);
}
SECTION("PathSimpleJavascript")
@ -291,17 +291,17 @@ TEST_CASE("Filename")
SECTION("ExpandTagSimple")
{
assertPath(profile, img,
"<image contains the tag \"tag1\"><\"unknown\" is one of the image tags> %md5%.%ext%",
"image contains the tag tag1 1bc29b36f623ba82aaf6724fd3b16718.jpg");
"<image contains the tag \"tag1\"><\"unknown\" is one of the image tags> %md5%.%ext%",
"image contains the tag tag1 1bc29b36f623ba82aaf6724fd3b16718.jpg");
assertPath(profile, img,
"<image contains the tag \"unknown\"><\"tag2\" is one of the image tags> %md5%.%ext%",
"tag2 is one of the image tags 1bc29b36f623ba82aaf6724fd3b16718.jpg");
"<image contains the tag \"unknown\"><\"tag2\" is one of the image tags> %md5%.%ext%",
"tag2 is one of the image tags 1bc29b36f623ba82aaf6724fd3b16718.jpg");
assertPath(profile, img,
"<image contains the tag \"tag1\"><\"tag2\" is one of the image tags> %md5%.%ext%",
"image contains the tag tag1tag2 is one of the image tags 1bc29b36f623ba82aaf6724fd3b16718.jpg");
"<image contains the tag \"tag1\"><\"tag2\" is one of the image tags> %md5%.%ext%",
"image contains the tag tag1tag2 is one of the image tags 1bc29b36f623ba82aaf6724fd3b16718.jpg");
assertPath(profile, img,
"<image contains the tag \"unknown1\"><\"unknown2\" is one of the image tags> %md5%.%ext%",
"1bc29b36f623ba82aaf6724fd3b16718.jpg");
"<image contains the tag \"unknown1\"><\"unknown2\" is one of the image tags> %md5%.%ext%",
"1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("ExpandTagWithInvalidCharacter")
{
@ -315,11 +315,11 @@ TEST_CASE("Filename")
SECTION("ExpandTagInvert")
{
assertPath(profile, img,
"<image does not contain the tag !\"tag1\"><!\"unknown\" is not one of the image tags> %md5%.%ext%",
"unknown is not one of the image tags 1bc29b36f623ba82aaf6724fd3b16718.jpg");
"<image does not contain the tag !\"tag1\"><!\"unknown\" is not one of the image tags> %md5%.%ext%",
"unknown is not one of the image tags 1bc29b36f623ba82aaf6724fd3b16718.jpg");
assertPath(profile, img,
"<image does not contain the tag !\"unknown\"><!\"tag2\" is not one of the image tags> %md5%.%ext%",
"image does not contain the tag unknown 1bc29b36f623ba82aaf6724fd3b16718.jpg");
"<image does not contain the tag !\"unknown\"><!\"tag2\" is not one of the image tags> %md5%.%ext%",
"image does not contain the tag unknown 1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("ExpandTagMultiple")
{
@ -345,14 +345,14 @@ TEST_CASE("Filename")
SECTION("ExpandTokenSimple")
{
assertPath(profile, img,
"image - <%artist% some text><text %nothing%> %md5%.%ext%",
"image - artist1 some text 1bc29b36f623ba82aaf6724fd3b16718.jpg");
"image - <%artist% some text><text %nothing%> %md5%.%ext%",
"image - artist1 some text 1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("ExpandTokenInvert")
{
assertPath(profile, img,
"image - <!%artist% some text><text !%nothing%> %md5%.%ext%",
"image - text 1bc29b36f623ba82aaf6724fd3b16718.jpg");
"image - <!%artist% some text><text !%nothing%> %md5%.%ext%",
"image - text 1bc29b36f623ba82aaf6724fd3b16718.jpg");
}
SECTION("ExpandTokenComplex")
{
@ -452,9 +452,9 @@ TEST_CASE("Filename")
settings->setValue("Save/replaceblanks", true);
assertPath(profile, img,
"%all:ignorenamespace=general,includenamespace,unsafe,separator=\n%\n\n%general%",
"artist:artist1\ncharacter:character1\ncharacter:character2\ncopyright:copyright1\ncopyright:copyright2\n\ntag1 tag2 tag3 test_tag1 test_tag2 test_tag3",
"", false);
"%all:ignorenamespace=general,includenamespace,unsafe,separator=\n%\n\n%general%",
"artist:artist1\ncharacter:character1\ncharacter:character2\ncopyright:copyright1\ncopyright:copyright2\n\ntag1 tag2 tag3 test_tag1 test_tag2 test_tag3",
"", false);
}
SECTION("PathOptionTagExcludeNamespace")
{
@ -464,8 +464,8 @@ TEST_CASE("Filename")
settings->setValue("Save/replaceblanks", true);
assertPath(profile, img,
"%all:includenamespace,excludenamespace=general character,unsafe%",
"tag1 tag2 tag3 test_tag1 test_tag2 test_tag3 artist:artist1 character1 character2 copyright:copyright1 copyright:copyright2", "", false);
"%all:includenamespace,excludenamespace=general character,unsafe%",
"tag1 tag2 tag3 test_tag1 test_tag2 test_tag3 artist:artist1 character1 character2 copyright:copyright1 copyright:copyright2", "", false);
}
SECTION("PathOptionTagSeparator")
{
@ -483,16 +483,16 @@ TEST_CASE("Filename")
SECTION("PathOptionNumSingle")
{
assertPath(profile, img,
"%id% (%num%).%ext%",
"7331 (1).jpg",
"tests/resources/tmp/");
"%id% (%num%).%ext%",
"7331 (1).jpg",
"tests/resources/tmp/");
}
SECTION("PathOptionNumSingleLength")
{
assertPath(profile, img,
"%id% (%num:length=3%).%ext%",
"7331 (001).jpg",
"tests/resources/tmp/");
"%id% (%num:length=3%).%ext%",
"7331 (001).jpg",
"tests/resources/tmp/");
}
SECTION("PathOptionNumMultiple")
{
@ -500,9 +500,9 @@ TEST_CASE("Filename")
QFile("tests/resources/image_1x1.png").copy("tests/resources/tmp/7331 (2).jpg");
assertPath(profile, img,
"%id% (%num%).%ext%",
"7331 (3).jpg",
"tests/resources/tmp/");
"%id% (%num%).%ext%",
"7331 (3).jpg",
"tests/resources/tmp/");
QFile::remove("tests/resources/tmp/7331 (1).jpg");
QFile::remove("tests/resources/tmp/7331 (2).jpg");
@ -514,35 +514,35 @@ TEST_CASE("Filename")
QFile("tests/resources/image_1x1.png").copy("tests/resources/tmp/7331 (3).png");
assertPath(profile, img,
"%id% (%num%).%ext%",
"7331 (2).jpg",
"tests/resources/tmp/");
"%id% (%num%).%ext%",
"7331 (2).jpg",
"tests/resources/tmp/");
assertPath(profile, img,
"%id% (%num:noext%).%ext%",
"7331 (4).jpg",
"tests/resources/tmp/");
"%id% (%num:noext%).%ext%",
"7331 (4).jpg",
"tests/resources/tmp/");
QFile::remove("tests/resources/tmp/7331 (1).png");
QFile::remove("tests/resources/tmp/7331 (2).png");
}
SECTION("PathOptionNumAboveTen")
{
#if false
int count = 15;
for (int i = 1; i < count; ++i) {
QFile("tests/resources/image_1x1.png").copy("tests/resources/tmp/7331 (" + QString::number(i) + ").jpg");
}
#if false
int count = 15;
for (int i = 1; i < count; ++i) {
QFile("tests/resources/image_1x1.png").copy("tests/resources/tmp/7331 (" + QString::number(i) + ").jpg");
}
assertPath(profile, img,
"%id% (%num%).%ext%",
"7331 (" + QString::number(count) + ").jpg",
"tests/resources/tmp/");
assertPath(profile, img,
"%id% (%num%).%ext%",
"7331 (" + QString::number(count) + ").jpg",
"tests/resources/tmp/");
for (int i = 1; i < count; ++i) {
QFile::remove("tests/resources/tmp/7331 (" + QString::number(i) + ").jpg");
}
#endif
for (int i = 1; i < count; ++i) {
QFile::remove("tests/resources/tmp/7331 (" + QString::number(i) + ").jpg");
}
#endif
}
SECTION("PathOptionSort")

View File

@ -227,16 +227,16 @@ TEST_CASE("Image")
file.remove();
}
#ifdef Q_OS_WIN
SECTION("SaveError")
{
QString path = "Z:/../tests/resources/tmp/";
SECTION("SaveError")
{
QString path = "Z:/../tests/resources/tmp/";
img->setSavePath("tests/resources/image_1x1.png");
QMap<QString, Image::SaveResult> res = img->save(QString("%id%.%ext%"), path);
img->setSavePath("tests/resources/image_1x1.png");
QMap<QString, Image::SaveResult> res = img->save(QString("%id%.%ext%"), path);
REQUIRE(res.count() == 1);
REQUIRE(res.first() == Image::Error);
}
REQUIRE(res.count() == 1);
REQUIRE(res.first() == Image::Error);
}
#endif
SECTION("SaveAlreadyExists")
{

View File

@ -96,19 +96,19 @@ TEST_CASE("Profile")
}
#ifndef Q_OS_WIN
SECTION("RemoveFavoriteThumb")
{
Favorite fav("tag_1", 20, dates[0]);
SECTION("RemoveFavoriteThumb")
{
Favorite fav("tag_1", 20, dates[0]);
QDir(profile->getPath()).mkdir("thumb");
QFile thumb(profile->getPath() + "/thumbs/" + fav.getName(true) + ".png");
thumb.open(QFile::WriteOnly | QFile::Truncate);
thumb.write(QString("test").toUtf8());
thumb.close();
QDir(profile->getPath()).mkdir("thumb");
QFile thumb(profile->getPath() + "/thumbs/" + fav.getName(true) + ".png");
thumb.open(QFile::WriteOnly | QFile::Truncate);
thumb.write(QString("test").toUtf8());
thumb.close();
REQUIRE(thumb.exists());
profile->removeFavorite(fav);
REQUIRE(!thumb.exists());
}
REQUIRE(thumb.exists());
profile->removeFavorite(fav);
REQUIRE(!thumb.exists());
}
#endif
}

View File

@ -47,7 +47,7 @@ TEST_CASE("TagNameFormat")
SECTION("Unknown")
{
TagNameFormat format((TagNameFormat::CaseFormat)123, " ");
TagNameFormat format((TagNameFormat::CaseFormat) 123, " ");
REQUIRE(format.formatted(QStringList()) == QString(""));
REQUIRE(format.formatted(QStringList() << "test") == QString("test"));

View File

@ -5,7 +5,7 @@
TEST_CASE("Updater")
{
ProgramUpdater updater;
SECTION("CompareEqual")
{
REQUIRE(updater.compareVersions("1.0.0", "1.0.0") == 0);

View File

@ -70,7 +70,7 @@ nl_while_brace = remove # "while () {" vs "while () \n {"
nl_switch_brace = force # "switch () {" vs "switch () \n {"
nl_brace_while = remove # "} while" vs "} \n while" - cuddle while
nl_brace_else = remove # "} else" vs "} \n else" - cuddle else
nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{"
nl_fcall_brace = force # "list_for_each() {" vs "list_for_each()\n{"
nl_fdef_brace = force # "int foo() {" vs "int foo()\n{"
# Spaces
@ -101,3 +101,4 @@ sp_after_comma = force
sp_func_def_paren = remove # "int foo (){" vs "int foo(){"
sp_func_call_paren = remove # "foo (" vs "foo("
sp_func_proto_paren = remove # "int foo ();" vs "int foo();"
sp_cpp_lambda_assign = remove # "[ = ]() {}" vs "[=]() {}"