summaryrefslogtreecommitdiff
path: root/archived/projt-launcher/tests/StringUtilsSplitFirst_test.cpp
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 18:51:45 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 18:51:45 +0300
commitd3261e64152397db2dca4d691a990c6bc2a6f4dd (patch)
treefac2f7be638651181a72453d714f0f96675c2b8b /archived/projt-launcher/tests/StringUtilsSplitFirst_test.cpp
parent31b9a8949ed0a288143e23bf739f2eb64fdc63be (diff)
downloadProject-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/StringUtilsSplitFirst_test.cpp')
-rw-r--r--archived/projt-launcher/tests/StringUtilsSplitFirst_test.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/archived/projt-launcher/tests/StringUtilsSplitFirst_test.cpp b/archived/projt-launcher/tests/StringUtilsSplitFirst_test.cpp
new file mode 100644
index 0000000000..2ef1dc175e
--- /dev/null
+++ b/archived/projt-launcher/tests/StringUtilsSplitFirst_test.cpp
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// SPDX-FileCopyrightText: 2026 Project Tick
+// SPDX-FileContributor: Project Tick Team
+
+#include <QRegularExpression>
+#include <QTest>
+
+#include <StringUtils.h>
+
+class StringUtilsSplitFirstTest : public QObject
+{
+ Q_OBJECT
+
+ private slots:
+ void test_splitStringSeparator()
+ {
+ auto p1 = StringUtils::splitFirst("name: value:rest", ": ");
+ QCOMPARE(p1.first, QString("name"));
+ QCOMPARE(p1.second, QString("value:rest"));
+
+ auto p2 = StringUtils::splitFirst("a::b::c", "::");
+ QCOMPARE(p2.first, QString("a"));
+ QCOMPARE(p2.second, QString("b::c"));
+ }
+
+ void test_splitCharSeparator()
+ {
+ auto p = StringUtils::splitFirst("left/right/inner", '/');
+ QCOMPARE(p.first, QString("left"));
+ QCOMPARE(p.second, QString("right/inner"));
+ }
+
+ void test_splitRegexSeparator()
+ {
+ QRegularExpression re("\\d+");
+ auto p1 = StringUtils::splitFirst("abc123def", re);
+ QCOMPARE(p1.first, QString("abc"));
+ QCOMPARE(p1.second, QString("def"));
+
+ auto p2 = StringUtils::splitFirst("no_digits_here", re);
+ QCOMPARE(p2.first, QString("no_digits_here"));
+ QCOMPARE(p2.second, QString(""));
+ }
+};
+
+QTEST_GUILESS_MAIN(StringUtilsSplitFirstTest)
+
+#include "StringUtilsSplitFirst_test.moc"