applied clang format

This commit is contained in:
deeaitch committed 2026-10-01 12:21:40 -04:00
1 parent 39ab7acc08
commit 73d82e9562
10 files changed
+583 -609

No files matched your search

+41 -43
View File
@@ -3,50 +3,48 @@
#include <QCoreApplication>
#include <QDebug>
int main (int argc, char **argv) {
QCoreApplication application (argc, argv);
const QUrl expected (QStringLiteral ("https://git.himro.ca/explore/repos"));
int failures = 0;
const auto check = [&failures] (bool condition, const char *description) {
if (!condition) {
qCritical() << description;
++failures;
int main(int argc, char **argv) {
QCoreApplication application(argc, argv);
const QUrl expected(QStringLiteral("https://git.himro.ca/explore/repos"));
int failures = 0;
const auto check = [&failures](bool condition, const char *description) {
if (!condition) {
qCritical() << description;
++failures;
}
};
for (const auto &text: {
"https://git.himro.ca/explore/repos",
" \nhttps://git.himro.ca/explore/repos\n ",
"'https://git.himro.ca/explore/repos'",
"\"https://git.himro.ca/explore/repos\"",
"<https://git.himro.ca/explore/repos>",
"[https://git.himro.ca/explore/repos](https://git.himro.ca/explore/repos)",
"'[Repositories](https://git.himro.ca/explore/repos)'"}) {
check(ClipboardUrl::parseText(QString::fromUtf8(text)) == expected, text);
}
};
check(ClipboardUrl::parseText(QStringLiteral(
"[Other label](https://git.himro.ca/explore/repos?filter=a%26b#section)")) == QUrl(QStringLiteral("https://git.himro.ca/explore/repos?filter=a%26b#section")),
"Markdown must use the destination and preserve query and fragment");
check(ClipboardUrl::parseText(QStringLiteral("[Link](https://example.com/a_(b))")) == QUrl(QStringLiteral("https://example.com/a_(b)")),
"Parentheses in URL paths must be preserved");
for (const auto &text: {"", "not a URL", "https://", "[Link](https://)"})
check(!ClipboardUrl::parseText(QString::fromUtf8(text)).isValid(), text);
for (const auto &text : {
"https://git.himro.ca/explore/repos",
" \nhttps://git.himro.ca/explore/repos\n ",
"'https://git.himro.ca/explore/repos'",
"\"https://git.himro.ca/explore/repos\"",
"<https://git.himro.ca/explore/repos>",
"[https://git.himro.ca/explore/repos](https://git.himro.ca/explore/repos)",
"'[Repositories](https://git.himro.ca/explore/repos)'"}) {
check (ClipboardUrl::parseText (QString::fromUtf8 (text)) == expected, text);
}
check (ClipboardUrl::parseText (QStringLiteral (
"[Other label](https://git.himro.ca/explore/repos?filter=a%26b#section)"))
== QUrl (QStringLiteral ("https://git.himro.ca/explore/repos?filter=a%26b#section")),
"Markdown must use the destination and preserve query and fragment");
check (ClipboardUrl::parseText (QStringLiteral ("[Link](https://example.com/a_(b))"))
== QUrl (QStringLiteral ("https://example.com/a_(b)")),
"Parentheses in URL paths must be preserved");
for (const auto &text : {"", "not a URL", "https://", "[Link](https://)"})
check (!ClipboardUrl::parseText (QString::fromUtf8 (text)).isValid(), text);
QMimeData mimeData;
mimeData.setText(QStringLiteral("Repositories"));
mimeData.setUrls({expected});
check(ClipboardUrl::fromMimeData(&mimeData) == expected,
"Browser URL MIME data must take precedence over a link label");
mimeData.clear();
mimeData.setText(expected.toString());
check(ClipboardUrl::fromMimeData(&mimeData) == expected, "Plain text fallback");
mimeData.setUrls({QUrl(QStringLiteral("file:///tmp/example"))});
check(ClipboardUrl::fromMimeData(&mimeData) == expected, "Unusable MIME URL fallback");
mimeData.clear();
check(!ClipboardUrl::fromMimeData(&mimeData).isValid(), "Empty clipboard");
check(!ClipboardUrl::fromMimeData(nullptr).isValid(), "Unavailable clipboard");
QMimeData mimeData;
mimeData.setText (QStringLiteral ("Repositories"));
mimeData.setUrls ({expected});
check (ClipboardUrl::fromMimeData (&mimeData) == expected,
"Browser URL MIME data must take precedence over a link label");
mimeData.clear();
mimeData.setText (expected.toString());
check (ClipboardUrl::fromMimeData (&mimeData) == expected, "Plain text fallback");
mimeData.setUrls ({QUrl (QStringLiteral ("file:///tmp/example"))});
check (ClipboardUrl::fromMimeData (&mimeData) == expected, "Unusable MIME URL fallback");
mimeData.clear();
check (!ClipboardUrl::fromMimeData (&mimeData).isValid(), "Empty clipboard");
check (!ClipboardUrl::fromMimeData (nullptr).isValid(), "Unavailable clipboard");
return failures == 0 ? 0 : 1;
return failures == 0 ? 0 : 1;
}