diff options
| author | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:51:45 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:51:45 +0300 |
| commit | d3261e64152397db2dca4d691a990c6bc2a6f4dd (patch) | |
| tree | fac2f7be638651181a72453d714f0f96675c2b8b /archived/projt-launcher/tests/StringUtilsTruncateUrl_test.cpp | |
| parent | 31b9a8949ed0a288143e23bf739f2eb64fdc63be (diff) | |
| download | Project-Tick-d3261e64152397db2dca4d691a990c6bc2a6f4dd.tar.gz Project-Tick-d3261e64152397db2dca4d691a990c6bc2a6f4dd.zip | |
NOISSUE add archived projects
Signed-off-by: Mehmet Samet Duman <yongdohyun@projecttick.org>
Diffstat (limited to 'archived/projt-launcher/tests/StringUtilsTruncateUrl_test.cpp')
| -rw-r--r-- | archived/projt-launcher/tests/StringUtilsTruncateUrl_test.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/archived/projt-launcher/tests/StringUtilsTruncateUrl_test.cpp b/archived/projt-launcher/tests/StringUtilsTruncateUrl_test.cpp new file mode 100644 index 0000000000..9141eeb938 --- /dev/null +++ b/archived/projt-launcher/tests/StringUtilsTruncateUrl_test.cpp @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SPDX-FileCopyrightText: 2026 Project Tick +// SPDX-FileContributor: Project Tick Team + +#include <QTest> +#include <QUrl> + +#include <StringUtils.h> + +class StringUtilsTruncateUrlTest : public QObject +{ + Q_OBJECT + + private slots: + void test_noTruncationWhenLongEnough() + { + QUrl url("https://user:pass@example.com/one/two#frag"); + const QString out = StringUtils::truncateUrlHumanFriendly(url, 200); + QCOMPARE(out, QString("https://example.com/one/two")); + } + + void test_softTruncationKeepsTail() + { + QUrl url("https://example.com/alpha/bravo/charlie/delta"); + const QString out = StringUtils::truncateUrlHumanFriendly(url, 30, false); + + QVERIFY(out.contains("...")); + QVERIFY(out.endsWith("/delta")); + QVERIFY(out.startsWith("https://example.com")); + } + + void test_hardLimitRespected() + { + QUrl url("https://example.com/very/long/path/for/testing/truncation"); + const QString out = StringUtils::truncateUrlHumanFriendly(url, 18, true); + + QVERIFY(out.size() <= 18); + QVERIFY(out.endsWith("...")); + } +}; + +QTEST_GUILESS_MAIN(StringUtilsTruncateUrlTest) + +#include "StringUtilsTruncateUrl_test.moc" |
