From d3261e64152397db2dca4d691a990c6bc2a6f4dd Mon Sep 17 00:00:00 2001 From: Mehmet Samet Duman Date: Thu, 2 Apr 2026 18:51:45 +0300 Subject: NOISSUE add archived projects Signed-off-by: Mehmet Samet Duman --- .../tests/StringUtilsTruncateUrl_test.cpp | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 archived/projt-launcher/tests/StringUtilsTruncateUrl_test.cpp (limited to 'archived/projt-launcher/tests/StringUtilsTruncateUrl_test.cpp') 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 +#include + +#include + +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" -- cgit 0.0.5-2-1-g0f52